Fix a 'serverquota' counter calculation bug

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 e430ce7039)
This commit is contained in:
Aram Sargsyan
2024-09-12 11:50:28 +00:00
committed by Mark Andrews
parent 6c1fc4ae54
commit ef344cbd5e

View File

@@ -3575,7 +3575,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;
@@ -3735,6 +3735,7 @@ normal_nses:
}
isc_stdtime_get(&now);
all_spilled = true; /* resets to false below after the first success */
INSIST(ISC_LIST_EMPTY(fctx->finds));
INSIST(ISC_LIST_EMPTY(fctx->altfinds));