From 118da7a087b88fa553eaaf3fae670dc755f61f26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Mon, 6 Apr 2020 13:43:05 +0200 Subject: [PATCH] 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 --- lib/cache/api.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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); } -- 2.47.2