From: Vladimír Čunát Date: Mon, 7 Jul 2025 12:58:05 +0000 (+0200) Subject: lib/cache: tweak the meaning of .flags.NO_CACHE X-Git-Tag: v6.0.15~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73e0cbbbcb90f0ac5e3959197fa3f6c7d9a562ae;p=thirdparty%2Fknot-resolver.git lib/cache: tweak the meaning of .flags.NO_CACHE This way it should better match docs for the flag, and I think it makes a bit more sense now, at least for the use cases we have in our code now. Also add NEWS for these two commits. --- diff --git a/NEWS b/NEWS index cccb9a640..a89970f1f 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ Bugfixes [system] assertion "env->is_cache" failed in cdb_write - /cache/prefill: fix 6.0.13 regression (!1705) - datamodel: improve file permission check (#933, !1714) +- NO_CACHE flag: fix and tweak its behavior (!1715) Improvements ------------ diff --git a/lib/cache/api.c b/lib/cache/api.c index d542060c9..309a9d6ed 100644 --- a/lib/cache/api.c +++ b/lib/cache/api.c @@ -334,11 +334,19 @@ int cache_peek(kr_layer_t *ctx, knot_pkt_t *pkt) /* We first check various exit-conditions and then call the _real function. */ if (!kr_cache_is_open(&req->ctx->cache) - || qry->flags.NO_CACHE || !check_rrtype(qry->stype, qry) /* LATER: some other behavior for some of these? */ || qry->sclass != KNOT_CLASS_IN) { return ctx->state; /* Already resolved/failed or already tried, etc. */ } + /* Only skip cache if (flagged and) resolving the origin query or its xNAME chain, + * not when resolving dependencies such as nameserver records or DNSSEC chain. */ + if (qry->flags.NO_CACHE) { + const struct kr_query *q = qry; + while (q->cname_parent) + q = q->cname_parent; + if (!q->parent) + return ctx->state; + } if (qry->stype == KNOT_RRTYPE_NSEC) { VERBOSE_MSG(qry, "=> skipping stype NSEC\n");