]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use delegdb for lookup in query_delegation_recurse()
authorColin Vidal <colin@isc.org>
Wed, 18 Feb 2026 15:05:19 +0000 (16:05 +0100)
committerColin Vidal <colin@isc.org>
Mon, 30 Mar 2026 18:41:13 +0000 (20:41 +0200)
When `query.c` finds a zonecut in the main cache (e.g. from stale NS
records), it must still use the correct delegation for recursion. Look
up the delegation DB via `dns_view_bestzonecut()` first; fall back to
`dns_deleg_fromrdataset()` only if no delegation is found.

This might also be done inside `query_lookup()` instead, with the `qctx`
holding a delegset property, but that approach needs further work to
avoid breakage and it is not clear so far if there would be other use
case of it. Current approach is simpler for now.

lib/ns/query.c

index 790db19b5326c64080d7cb5b26be5c2731048917..b25b37c91f60d1f8e34514fbd8b4aaabc22504ab 100644 (file)
@@ -8658,11 +8658,21 @@ query_delegation_recurse(query_ctx_t *qctx) {
                 * Any other recursion.
                 */
                dns_delegset_t *delegset = NULL;
+               dns_fixedname_t ffname;
+               dns_name_t *fname = dns_fixedname_initname(&ffname);
+               isc_result_t tresult;
+
+               tresult = dns_view_bestzonecut(qctx->view, qname, fname, NULL,
+                                              qctx->client->inner.now, 0, true,
+                                              true, &delegset);
+               if (tresult != ISC_R_SUCCESS) {
+                       dns_delegset_fromrdataset(qctx->rdataset, &delegset);
+                       fname = qctx->fname;
+               }
 
-               dns_deleg_fromrdataset(qctx->rdataset, &delegset);
                result = ns_query_recurse(qctx->client, qctx->qtype, qname,
-                                         qctx->fname, delegset,
-                                         qctx->resuming);
+                                         fname, delegset, qctx->resuming);
+
                if (delegset != NULL) {
                        dns_delegset_detach(&delegset);
                }