]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/caches: lookup direct matches only
authorMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 27 May 2015 23:26:07 +0000 (01:26 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 27 May 2015 23:26:07 +0000 (01:26 +0200)
since the zone cut is looked up after layers now, it
is pointless to search for minimized names from cache,
since this is the same operation as searching for a zone cut

lib/layer/pktcache.c
lib/layer/rrcache.c

index e45ac13510e86b76122e133bbc055b55d15ea4e6..15c85de7d891ab3675e4a8cee5a6c1cc3e7ca678 100644 (file)
@@ -90,23 +90,13 @@ static int loot_cache_pkt(struct kr_cache_txn *txn, knot_pkt_t *pkt, const knot_
        return ret;
 }
 
-/** @internal Try to find a shortcut directly to searched packet, otherwise try to find minimised QNAME. */
+/** @internal Try to find a shortcut directly to searched packet. */
 static int loot_cache(struct kr_cache_txn *txn, knot_pkt_t *pkt, uint8_t tag, struct kr_query *qry)
 {
        uint32_t timestamp = qry->timestamp.tv_sec;
        const knot_dname_t *qname = qry->sname;
        uint16_t rrtype = qry->stype;
-       int ret = loot_cache_pkt(txn, pkt, qname, rrtype, tag, timestamp);
-       if (ret == 0) { /* Signalize minimisation disabled */
-               qry->flags |= QUERY_NO_MINIMIZE;
-       } else { /* Retry with minimised name */
-               qname = knot_pkt_qname(pkt);
-               rrtype = knot_pkt_qtype(pkt);
-               if (!knot_dname_is_equal(qname, qry->sname)) {
-                       ret = loot_cache_pkt(txn, pkt, qname, rrtype, tag, timestamp);
-               }
-       }
-       return ret;
+       return loot_cache_pkt(txn, pkt, qname, rrtype, tag, timestamp);
 }
 
 static int peek(knot_layer_t *ctx, knot_pkt_t *pkt)
@@ -134,7 +124,7 @@ static int peek(knot_layer_t *ctx, knot_pkt_t *pkt)
        kr_cache_txn_abort(&txn);
        if (ret == 0) {
                DEBUG_MSG("=> satisfied from cache\n");
-               qry->flags |= QUERY_CACHED;
+               qry->flags |= QUERY_CACHED|QUERY_NO_MINIMIZE;
                pkt->parsed = pkt->size;
                knot_wire_set_qr(pkt->wire);
                return KNOT_STATE_DONE;
index b907760b0615bd2343b74def60922a8939457633..821da0688b38057d0accfd366b97aaef31546fc5 100644 (file)
@@ -73,23 +73,13 @@ static int loot_cache_set(struct kr_cache_txn *txn, knot_pkt_t *pkt, const knot_
        return ret;
 }
 
-/** @internal Try to find a shortcut directly to searched record, otherwise try to find minimised QNAME. */
+/** @internal Try to find a shortcut directly to searched record. */
 static int loot_cache(struct kr_cache_txn *txn, knot_pkt_t *pkt, struct kr_query *qry)
 {
        const knot_dname_t *qname = qry->sname;
        uint16_t rrclass = qry->sclass;
        uint16_t rrtype = qry->stype;
-       int ret = loot_cache_set(txn, pkt, qname, rrclass, rrtype, qry);
-       if (ret == 0) { /* Signalize minimisation disabled */
-               qry->flags |= QUERY_NO_MINIMIZE;
-       } else { /* Retry with minimised name */
-               qname = knot_pkt_qname(pkt);
-               rrtype = knot_pkt_qtype(pkt);
-               if (!knot_dname_is_equal(qname, qry->sname)) {
-                       ret = loot_cache_set(txn, pkt, qname, rrclass, rrtype, qry);
-               }
-       }
-       return ret;
+       return loot_cache_set(txn, pkt, qname, rrclass, rrtype, qry);
 }
 
 static int peek(knot_layer_t *ctx, knot_pkt_t *pkt)
@@ -115,7 +105,7 @@ static int peek(knot_layer_t *ctx, knot_pkt_t *pkt)
        kr_cache_txn_abort(&txn);
        if (ret == 0) {
                DEBUG_MSG("=> satisfied from cache\n");
-               qry->flags |= QUERY_CACHED;
+               qry->flags |= QUERY_CACHED|QUERY_NO_MINIMIZE;
                pkt->parsed = pkt->size;
                knot_wire_set_qr(pkt->wire);
                knot_wire_set_aa(pkt->wire);