]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
cache: in STUB mode always cache whole packets
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 6 Apr 2020 11:43:05 +0000 (13:43 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 22 Apr 2020 06:58:05 +0000 (08:58 +0200)
... instead of individual records.
- iterator in STUB mode can't process individual CNAME steps from cache
- perhaps it's more suitable for STUB anyway

lib/cache/api.c

index df5c574ab308cd3ac6d0b9ed56b17ca02048d56f..fcf81374323146fe55e43712a418c5c8f2d557b7 100644 (file)
@@ -359,17 +359,20 @@ int cache_stash(kr_layer_t *ctx, knot_pkt_t *pkt)
        if (knot_wire_get_tc(pkt->wire)) {
                return ctx->state;
        }
+       int unauth_cnt = 0;
+       bool needs_pkt = false;
+       if (qry->flags.STUB) {
+               needs_pkt = true;
+               goto stash_packet;
+       }
+
        /* Stash individual records. */
        ranked_rr_array_t *selected[] = kr_request_selected(req);
-       int unauth_cnt = 0;
        trie_t *nsec_pmap = trie_create(&req->pool);
        if (!nsec_pmap) {
                assert(!ENOMEM);
                goto finally;
        }
-       bool needs_pkt = false;
-               /* ^^ DNSSEC_OPTOUT is not fired in cases like `com. A`,
-                * but currently we don't stash separate NSEC3 proving that. */
        for (int psec = KNOT_ANSWER; psec <= KNOT_ADDITIONAL; ++psec) {
                ranked_rr_array_t *arr = selected[psec];
                /* uncached entries are located at the end */
@@ -401,7 +404,7 @@ int cache_stash(kr_layer_t *ctx, knot_pkt_t *pkt)
        trie_it_free(it);
        /* LATER(optim.): typically we also have corresponding NS record in the list,
         * so we might save a cache operation. */
-
+stash_packet:
        if (qry->flags.PKT_IS_SANE && check_dname_for_lf(knot_pkt_qname(pkt), qry)) {
                stash_pkt(pkt, qry, req, needs_pkt);
        }