]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
minor refactoring of resume_qmin() for clarity
authorEvan Hunt <each@isc.org>
Wed, 28 Jun 2023 16:28:01 +0000 (09:28 -0700)
committerEvan Hunt <each@isc.org>
Thu, 29 Jun 2023 17:14:20 +0000 (10:14 -0700)
make the code flow clearer by enumerating the result codes that
are treated as success conditions for an intermediate minimized
query (ISC_R_SUCCESS, DNS_R_DELEGATION, DNS_R_NXRRSET, etc), rather
than just folding them all into the 'default' branch of a switch
statement.

lib/dns/resolver.c

index afad02d005867aeebff65254ab8056757e8f5689..1e31cf5d34f2526a8f368f88a522b3c96b40c510 100644 (file)
@@ -4051,9 +4051,9 @@ fctx_try(fetchctx_t *fctx, bool retrying, bool badcache) {
                }
 
                /*
-                * Turn on NOFOLLOW in relaxed mode so that QNAME minimisation
+                * Turn on NOFOLLOW in relaxed mode so that QNAME minimization
                 * doesn't cause additional queries to resolve the target of the
-                * QNAME minimisation request when a referral is returned.  This
+                * QNAME minimization request when a referral is returned.  This
                 * will also reduce the impact of mis-matched NS RRsets where
                 * the child's NS RRset is garbage.  If a delegation is
                 * discovered DNS_R_DELEGATION will be returned to resume_qmin.
@@ -4150,32 +4150,51 @@ resume_qmin(void *arg) {
        case ISC_R_SHUTTINGDOWN:
        case ISC_R_CANCELED:
                goto cleanup;
+
        case DNS_R_NXDOMAIN:
        case DNS_R_NCACHENXDOMAIN:
        case DNS_R_FORMERR:
        case DNS_R_REMOTEFORMERR:
        case ISC_R_FAILURE:
-               if ((fctx->options & DNS_FETCHOPT_QMIN_STRICT) == 0) {
-                       /* Disable minimization in relaxed mode */
-                       fctx->qmin_labels = DNS_NAME_MAXLABELS;
-                       /*
-                        * We store the result. If we succeed in the end
-                        * we'll issue a warning that the server is
-                        * broken.
-                        */
-                       fctx->qmin_warning = result;
-               } else {
-                       /* fail in strict mode */
+               if ((fctx->options & DNS_FETCHOPT_QMIN_STRICT) != 0) {
+                       /* These results cause a hard fail in strict mode */
                        goto cleanup;
                }
+
+               /* ...or disable minimization in relaxed mode */
+               fctx->qmin_labels = DNS_NAME_MAXLABELS;
+
+               /*
+                * We store the result. If we succeed in the end
+                * we'll issue a warning that the server is
+                * broken.
+                */
+               fctx->qmin_warning = result;
                break;
-       default:
+
+       case ISC_R_SUCCESS:
+       case DNS_R_DELEGATION:
+       case DNS_R_NXRRSET:
+       case DNS_R_NCACHENXRRSET:
+       case DNS_R_CNAME:
+       case DNS_R_DNAME:
                /*
-                * When DNS_FETCHOPT_NOFOLLOW is set and a delegation
-                * was discovered, DNS_R_DELEGATION is returned and is
-                * processed here.
+                * Any other result will *not* cause a failure in strict
+                * mode, or cause minimization to be disabled in relaxed
+                * mode.
+                *
+                * If DNS_R_DELEGATION is set here, it implies that
+                * DNS_FETCHOPT_NOFOLLOW was set, and a delegation was
+                * discovered but not followed; we will do so now.
                 */
                break;
+
+       default:
+               isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER,
+                             DNS_LOGMODULE_RESOLVER, ISC_LOG_DEBUG(5),
+                             "QNAME minimization: unexpected result %s",
+                             isc_result_totext(result));
+               break;
        }
 
        if (dns_rdataset_isassociated(&fctx->nameservers)) {