]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
simplify usage of dns_view_findzonecut()
authorColin Vidal <colin@isc.org>
Wed, 17 Dec 2025 14:27:39 +0000 (15:27 +0100)
committerColin Vidal <colin@isc.org>
Thu, 8 Jan 2026 19:26:32 +0000 (20:26 +0100)
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.

bin/named/server.c
lib/dns/adb.c
lib/dns/include/dns/view.h
lib/dns/resolver.c

index 09caf23d554a6658497e030e4caff6da771bd2c6..e381a99851f19237a7c54c8406183df8478697e2 100644 (file)
@@ -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);
index 0bdf4a9ad96254c8d383deb0180cf686e1c5e743..402c1392f4731680110c544712f78eeb962163cd 100644 (file)
@@ -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) {
index 1c3bbdb06e35a50428a768e80f036d21243eef32..d65a0d07852e37e4b5ac9041245fc2e71aef7218 100644 (file)
@@ -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
index c93f4951cac9e5e33e427eba3ca717bc1f95dd82..53174814219744b924840969a07307b46c900744 100644 (file)
@@ -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);