From: Colin Vidal Date: Wed, 17 Dec 2025 14:27:39 +0000 (+0100) Subject: simplify usage of dns_view_findzonecut() X-Git-Tag: v9.21.18~34^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0d7bddc6cdaa42225744c564007bc81e2d1938b;p=thirdparty%2Fbind9.git simplify usage of dns_view_findzonecut() As `dns_view_findzonecut()` only returns either ISC_R_SUCCESS or DNS_R_NXDOMAIN, and since it automatically disassociates the rdatasets in case of failure, some call sites are simplified. --- diff --git a/bin/named/server.c b/bin/named/server.c index 09caf23d554..e381a99851f 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -6598,20 +6598,19 @@ tat_send(void *arg) { domain, &nameservers, NULL, NULL, 0, 0, 0, NULL, NULL, NULL, tat->loop, tat_done, tat, NULL, &tat->rdataset, &tat->sigrdataset, &tat->fetch); + + /* + * dns_resolver_createfetch() will create its own copy of + * nameservers. + */ + dns_rdataset_cleanup(&nameservers); } /* * 'domain' holds the dns_name_t pointer inside a dst_key_t structure. * dns_resolver_createfetch() creates its own copy of 'domain' if it * succeeds. Thus, 'domain' is not freed here. - * - * Even if dns_view_findzonecut() returned something else than - * ISC_R_SUCCESS, it still could have associated 'nameservers'. - * dns_resolver_createfetch() creates its own copy of 'nameservers' if - * it succeeds. Thus, we need to check whether 'nameservers' is - * associated and release it if it is. */ - dns_rdataset_cleanup(&nameservers); if (result != ISC_R_SUCCESS) { dns_view_detach(&tat->view); diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 0bdf4a9ad96..402c1392f47 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -2738,12 +2738,8 @@ fetch_name(dns_adbname_t *adbname, bool start_at_zone, bool no_validation, DP(ENTER_LEVEL, "fetch_name: starting at zone for name %p", adbname); name = dns_fixedname_initname(&fixed); - result = dns_view_findzonecut(adb->view, adbname->name, name, - NULL, 0, 0, true, false, - &rdataset, NULL); - if (result != ISC_R_SUCCESS && result != DNS_R_HINT) { - goto cleanup; - } + CHECK(dns_view_findzonecut(adb->view, adbname->name, name, NULL, + 0, 0, true, false, &rdataset, NULL)); nameservers = &rdataset; options |= DNS_FETCHOPT_UNSHARED; } else if (adb->view->qminimization) { diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index 1c3bbdb06e3..d65a0d07852 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -724,9 +724,9 @@ dns_view_findzonecut(dns_view_t *view, const dns_name_t *name, * * Returns: * - *\li #ISC_R_SUCCESS Success. - * - *\li Many other results are possible. + *\li #ISC_R_SUCCESS If a delegation is found; + *\li #DNS_R_NXDOMAIN If no delegation is found; 'rdataset' and 'sigrdataset' + * are disassociated. */ isc_result_t diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index c93f4951cac..53174814219 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -4501,22 +4501,8 @@ resume_qmin(void *arg) { &fctx->nameservers, NULL); FCTXTRACEN("resume_qmin findzonecut", fname, result); - /* - * DNS_R_NXDOMAIN here means we have not loaded the root zone - * mirror yet - but DNS_R_NXDOMAIN is not a valid return value - * when doing recursion, we need to patch it. - * - * CNAME or DNAME means zone were added with that record - * after the start of a recursion. It means we do not have - * initialized correct hevent->foundname and have to fail. - */ - if (result == DNS_R_NXDOMAIN || result == DNS_R_CNAME || - result == DNS_R_DNAME) - { - result = DNS_R_SERVFAIL; - } - if (result != ISC_R_SUCCESS) { + result = DNS_R_SERVFAIL; goto cleanup; } fcount_decr(fctx);