]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix edns subnet, that scope zero queries, when there is a
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 6 Jan 2026 08:32:21 +0000 (09:32 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 6 Jan 2026 08:32:21 +0000 (09:32 +0100)
  subquery without subnet, and the forward-no-cache or
  stub-no-cache option is set, it is not stored in cache due to
  the forward or stub option.

edns-subnet/subnetmod.c

index a2a3f184621b3c18d2292af753259748f44db8f9..5144070a5316017c576a13cb80a8314998a9f0b4 100644 (file)
@@ -162,8 +162,15 @@ int ecs_whitelist_check(struct query_info* qinfo,
                        if(!ecs_is_whitelisted(sn_env->whitelist,
                                addr, addrlen, qinfo->qname, qinfo->qname_len,
                                qinfo->qclass)) {
-                               verbose(VERB_ALGO, "subnet store subquery global, name and addr have no subnet treatment.");
-                               qstate->no_cache_store = 0;
+                               /* The stub or forward can have no_cache set.*/
+                               if(iter_stub_fwd_no_cache(qstate, &qstate->qinfo, NULL, NULL, NULL, 0)) {
+                                       verbose(VERB_ALGO, "subnet subquery is not stored globally, stuborfwd is no_cache");
+                               } else {
+                                       verbose(VERB_ALGO, "subnet store subquery global, name and addr have no subnet treatment.%s",
+                                               (sq->started_no_cache_store?
+                                               " But the subnet module was started with no_cache_store for the super query, and that is still applied to this query":""));
+                                       qstate->no_cache_store = sq->started_no_cache_store;
+                               }
                        }
                }
                return 1;
@@ -580,6 +587,7 @@ generate_sub_request(struct module_qstate *qstate, int id, struct subnet_qstate*
                }
                subsq = (struct subnet_qstate*)subq->minfo[id];
                subsq->is_subquery_nonsubnet = 1;
+               subsq->started_no_cache_store = sq->started_no_cache_store;
 
                /* When the client asks 0.0.0.0/0 and the name is not treated
                 * as subnet, it is to be stored in the global cache.