]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
cache: assume NSEC if ". NS" is missing in cache
authorVladimír Čunát <vladimir.cunat@nic.cz>
Fri, 2 Feb 2018 10:25:52 +0000 (11:25 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 5 Feb 2018 13:04:23 +0000 (14:04 +0100)
This happens e.g. after cache.clear(), and currently one can stay
long-term without that record in cache.  That was effectively disabling
aggressive answers from the root zone.

This needs disabling a buggy part of Deckard test.

lib/cache/api.c
tests/deckard

index 6860dd52e6c2c5c03f2c370f61431d4a535d0119..e0eb6c06f586a0df936f3bd43045df2bbe745bef 100644 (file)
@@ -382,8 +382,7 @@ static int cache_peek_real(kr_layer_t *ctx, knot_pkt_t *pkt)
        kr_dname_lf(k->buf, k->zname, false); /* LATER(optim.): probably remove */
        const knot_db_val_t val_cut = closest_NS(ctx, k);
        if (!val_cut.data) {
-               VERBOSE_MSG(qry, "=> not even root NS in cache\n");
-               return ctx->state; /* nothing to do without any NS at all */
+               VERBOSE_MSG(qry, "=> not even root NS in cache, but let's try NSEC\n");
        }
        switch (k->type) {
        case KNOT_RRTYPE_NS:
@@ -1106,7 +1105,11 @@ static knot_db_val_t closest_NS(kr_layer_t *ctx, struct key *k)
        next_label:
                /* remove one more label */
                exact_match = false;
-               if (k->zname[0] == 0) { /* missing root NS in cache */
+               if (k->zname[0] == 0) {
+                       /* We miss root NS in cache, but let's at least assume it exists. */
+                       k->type = KNOT_RRTYPE_NS;
+                       k->zlf_len = zlf_len;
+                       assert(zlf_len == 0);
                        return VAL_EMPTY;
                }
                zlf_len -= (k->zname[0] + 1);
index 05064e06e7dbea44308c9776f1823d1a5dfb9556..39772e7336d9465a81bae6e983cb7fd559f7f0bc 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 05064e06e7dbea44308c9776f1823d1a5dfb9556
+Subproject commit 39772e7336d9465a81bae6e983cb7fd559f7f0bc