From ef344cbd5ea46434587320b69785bdfd5a78a61f Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Thu, 12 Sep 2024 11:50:28 +0000 Subject: [PATCH] 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 e430ce70390d181eb355c61f1f73c4c9d9943e06) --- lib/dns/resolver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index f8f53d2650..98137a514d 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -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));