]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix a 'serverquota' counter calculation bug
authorAram Sargsyan <aram@isc.org>
Thu, 12 Sep 2024 11:50:28 +0000 (11:50 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Mon, 16 Sep 2024 09:31:38 +0000 (09:31 +0000)
The 'all_spilled' local variable in resolver.c:fctx_getaddresses()
is 'true' by default, and only becomes false when there is at least
one successfully found NS address. However, when a 'forward only;'
configuration is used, the code jumps over the part where it looks
for NS addresses and doesn't reset the 'all_spilled' to false, which
results in incorretly increased 'serverquota' statistics variable,
and also in invalid return error code from the function. The result
code error didn't make any differences, because all codes other than
'ISC_R_SUCCESS' or 'DNS_R_WAIT' were treated in the same way, and
the result code was never logged anywhere.

Set the default value of 'all_spilled' to 'false', and only make it
'true' before actually starting to look up NS addresses.

(cherry picked from commit e430ce70390d181eb355c61f1f73c4c9d9943e06)

lib/dns/resolver.c

index 9957663c2d09b70003ba8d2fd7a59a2e87cb3fb3..9fcc1ea73c8ceec043a111e4f4d0ba4596406b56 100644 (file)
@@ -3423,7 +3423,7 @@ fctx_getaddresses(fetchctx_t *fctx, bool badcache) {
        bool all_bad;
        dns_rdata_ns_t ns;
        bool need_alternate = false;
-       bool all_spilled = true;
+       bool all_spilled = false;
        unsigned int no_addresses = 0;
        unsigned int ns_processed = 0;
 
@@ -3592,6 +3592,7 @@ normal_nses:
        }
 
        now = isc_stdtime_now();
+       all_spilled = true; /* resets to false below after the first success */
 
        INSIST(ISC_LIST_EMPTY(fctx->finds));
        INSIST(ISC_LIST_EMPTY(fctx->altfinds));