From: Vladimír Čunát Date: Mon, 6 Apr 2020 11:43:05 +0000 (+0200) Subject: cache: in STUB mode always cache whole packets X-Git-Tag: v5.1.0~8^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=118da7a087b88fa553eaaf3fae670dc755f61f26;p=thirdparty%2Fknot-resolver.git cache: in STUB mode always cache whole packets ... instead of individual records. - iterator in STUB mode can't process individual CNAME steps from cache - perhaps it's more suitable for STUB anyway --- diff --git a/lib/cache/api.c b/lib/cache/api.c index df5c574ab..fcf813743 100644 --- a/lib/cache/api.c +++ b/lib/cache/api.c @@ -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); }