]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
Revert "lib/layer: answer both m12n/full names from cache"
authorMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 13 May 2015 10:16:37 +0000 (12:16 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 13 May 2015 10:16:37 +0000 (12:16 +0200)
This reverts commit 3d1ee64186c8f29c98df143b992660dfd95d4805.

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

index 963cb47a79d2edc3bd6f8b234bc95d424303367b..11cd46638ba2199f472f237d4ad86a1387e33b90 100644 (file)
@@ -50,7 +50,7 @@ static const knot_dname_t *minimized_qname(struct kr_query *query, uint16_t *qty
 {
        /* Minimization disabled. */
        const knot_dname_t *qname = query->sname;
-       if (query->flags & (QUERY_NO_MINIMIZE|QUERY_CACHED)) {
+       if (query->flags & QUERY_NO_MINIMIZE) {
                return qname;
        }
 
index 35522c8ff2626a8f2e93af73443eff09e3814fbc..050aec156255e35320b7e1c11b12af6f0289cdd5 100644 (file)
@@ -54,9 +54,10 @@ static void adjust_ttl(knot_rrset_t *rr, uint32_t drift)
        }
 }
 
-static int loot_cache_set(namedb_txn_t *txn, knot_pkt_t *pkt, uint8_t tag, const knot_dname_t *qname,
-                          uint16_t rrtype, uint32_t timestamp)
+static int loot_cache(namedb_txn_t *txn, knot_pkt_t *pkt, uint8_t tag, uint32_t timestamp)
 {
+       const knot_dname_t *qname = knot_pkt_qname(pkt);
+       uint16_t rrtype = knot_pkt_qtype(pkt);
        struct kr_cache_entry *entry;
        entry = kr_cache_peek(txn, tag, qname, rrtype, &timestamp);
        if (!entry) { /* Not in the cache */
@@ -90,24 +91,6 @@ static int loot_cache_set(namedb_txn_t *txn, knot_pkt_t *pkt, uint8_t tag, const
        return ret;
 }
 
-static int loot_cache(namedb_txn_t *txn, knot_pkt_t *pkt, struct kr_query *qry, uint8_t tag)
-{
-       uint32_t timestamp = qry->timestamp.tv_sec;
-       /* Try direct match first */
-       const knot_dname_t *qname = qry->sname;
-       uint16_t rrtype = qry->stype;
-       int ret = loot_cache_set(txn, pkt, tag, qname, rrtype, timestamp);
-       if (ret == kr_error(ENOENT)) {
-               /* Try minimized name second */
-               qname = knot_pkt_qname(pkt);
-               rrtype = knot_pkt_qtype(pkt);
-               if (!knot_dname_is_equal(qname, qry->sname)) {
-                       ret = loot_cache_set(txn, pkt, tag, qname, rrtype, timestamp);
-               }
-       }
-       return ret;
-}
-
 static int peek(knot_layer_t *ctx, knot_pkt_t *pkt)
 {
        struct kr_request *req = ctx->data;
@@ -126,7 +109,8 @@ static int peek(knot_layer_t *ctx, knot_pkt_t *pkt)
        if (kr_cache_txn_begin(cache, &txn, NAMEDB_RDONLY) != 0) {
                return ctx->state;
        }
-       if (loot_cache(&txn, pkt, qry, get_tag(req->answer)) != 0) {
+       uint32_t timestamp = qry->timestamp.tv_sec;
+       if (loot_cache(&txn, pkt, get_tag(req->answer), timestamp) != 0) {
                kr_cache_txn_abort(&txn);
                return ctx->state;
        }
index 8edc48d9fe0e04e3411e0a1160893281aeadbc62..2b23742ae290efffd81af18a5dbf05e3b5fb40ee 100644 (file)
@@ -53,9 +53,11 @@ static int loot_rr(namedb_txn_t *txn, knot_pkt_t *pkt, const knot_dname_t *name,
        return kr_ok();
 }
 
-static int loot_cache_set(namedb_txn_t *txn, knot_pkt_t *pkt, const knot_dname_t *qname,
-                          uint16_t rrclass, uint16_t rrtype, uint32_t timestamp)
+static int loot_cache(namedb_txn_t *txn, knot_pkt_t *pkt, uint32_t timestamp)
 {
+       const knot_dname_t *qname = knot_pkt_qname(pkt);
+       uint16_t rrclass = knot_pkt_qclass(pkt);
+       uint16_t rrtype = knot_pkt_qtype(pkt);
        int ret = loot_rr(txn, pkt, qname, rrtype, rrclass, timestamp);
        if (ret == kr_error(ENOENT) && rrtype != KNOT_RRTYPE_CNAME) { /* Chase CNAME if no direct hit */
                ret = loot_rr(txn, pkt, qname, KNOT_RRTYPE_CNAME, rrclass, timestamp);
@@ -63,25 +65,6 @@ static int loot_cache_set(namedb_txn_t *txn, knot_pkt_t *pkt, const knot_dname_t
        return ret;
 }
 
-static int loot_cache(namedb_txn_t *txn, knot_pkt_t *pkt, struct kr_query *qry)
-{
-       uint32_t timestamp = qry->timestamp.tv_sec;
-       /* Try direct match first */
-       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, timestamp);
-       if (ret == kr_error(ENOENT)) {
-               /* Try minimized name second */
-               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, timestamp);
-               }
-       }
-       return ret;
-}
-
 static int peek(knot_layer_t *ctx, knot_pkt_t *pkt)
 {
        struct kr_request *req = ctx->data;
@@ -101,7 +84,8 @@ static int peek(knot_layer_t *ctx, knot_pkt_t *pkt)
         * it may either be a CNAME chain or direct answer.
         * Only one step of the chain is resolved at a time.
         */
-       int ret = loot_cache(&txn, pkt, qry);
+       uint32_t timestamp = qry->timestamp.tv_sec;
+       int ret = loot_cache(&txn, pkt, timestamp);
        kr_cache_txn_abort(&txn);
        if (ret == 0) {
                DEBUG_MSG("=> satisfied from cache\n");