]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/cache: tweak the meaning of .flags.NO_CACHE docs-no-cache-4m9xil/deployments/7209
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 7 Jul 2025 12:58:05 +0000 (14:58 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 16 Jul 2025 16:48:33 +0000 (18:48 +0200)
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.

NEWS
lib/cache/api.c

diff --git a/NEWS b/NEWS
index cccb9a640a55e706ad53dbe518fbc443cf43f34a..a89970f1f6c20fbe6b41dd8d0040f8adde1a73d5 100644 (file)
--- 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
 ------------
index d542060c9e371539a0fefc5b341a81f9b5866006..309a9d6ed75b6dc0384091c540de0cdd4095165e 100644 (file)
@@ -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");