fix: usr: Fix a statistics channel counter bug when 'forward only' zones are used

When resolving a zone with a 'forward only' policy, and
finding out that all the forwarders are marked as "bad",
the 'ServerQuota' counter of the statistics channel was
incorrectly increased. This has been fixed.

Closes #1793

Merge branch '1793-serverquota-counter-bug-with-forward-only' into 'main'

See merge request isc-projects/bind9!9493
This commit is contained in:
Arаm Sаrgsyаn 2024-09-16 09:30:56 +00:00
commit b82957376d
4 changed files with 14 additions and 1 deletions

View file

@ -19,6 +19,7 @@ rm -f ./*/named.memstats
rm -f ./*/named.run ./*/named.run.prev ./*/ans.run
rm -f ./*/named_dump.db
rm -f ./ans*/query.log
rm -f ./statschannel.out.*
rm -f ./dig.out.*
rm -f ./ns*/managed-keys.bind*
rm -f ./ns*/trusted.conf

View file

@ -29,6 +29,8 @@ options {
trust-anchors { };
statistics-channels { inet 10.53.0.4 port @EXTRAPORT1@ allow { localhost; }; };
zone "." {
type hint;
file "root.db";

View file

@ -164,6 +164,15 @@ grep "SERVFAIL" dig.out.$n.f2 >/dev/null || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
# GL#1793
n=$((n + 1))
echo_i "checking that the 'serverquota' counter isn't increased because of the SERVFAIL in the previous check ($n)"
ret=0
"${CURL}" "http://10.53.0.4:${EXTRAPORT1}/json/v1" 2>/dev/null >statschannel.out.$n
grep -F "ServerQuota" statschannel.out.$n >/dev/null && ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "checking for negative caching of forwarder response ($n)"
# prime the cache, shutdown the forwarder then check that we can

View file

@ -3417,7 +3417,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;
@ -3586,6 +3586,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));