]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
rctx_resend() increment query counters
authorColin Vidal <colin@isc.org>
Tue, 7 Apr 2026 20:18:58 +0000 (22:18 +0200)
committerMichał Kępień <michal@isc.org>
Thu, 7 May 2026 11:21:59 +0000 (13:21 +0200)
Calls to `rctx_resend()` are done internally within the resolver, in
flow which are not supposed to happens more than once. For instance,
if some query fails, and a specific flag "F" wasn't set, then set the
flag and try again. This wouldn't occur more than once because if the
query fails the next attempt, the flag "F" would be set already, so the
resolver would move to the next server (or give up).

However, a subtle bug missing checking a flag, for instance, could lead
to an unbounded loop re-trying to query the same server. This is now
impossible as `rctx_resend()` also increment the query counters (so if
such case occurs, it would stop once the maximum limit is reached).

The dns_resstatscounter_retry are also only incremented if the
`fctx_query()` succeeds, similar to as is done in `fctx_try()`.

(cherry picked from commit f3e74304889a2e8b69c8e88fc9a383589decda32)

lib/dns/resolver.c

index 406ea6c56f78ee3e24206a407b17e47099a25e6b..0915da4fef44a7dbc3966d31f3a1fe16f106be7d 100644 (file)
@@ -10089,9 +10089,9 @@ rctx_nextserver(respctx_t *rctx, dns_message_t *message,
  * rctx_resend():
  *
  * Resend the query, probably with the options changed. Calls
- * fctx_query(), passing rctx->retryopts (which is based on
- * query->options, but may have been updated since the last time
- * fctx_query() was called).
+ * fctx_query(), unless query counter limits are hit, passing
+ * rctx->retryopts (which is based on query->options, but may have
+ * been updated since the last time fctx_query() was called).
  */
 static void
 rctx_resend(respctx_t *rctx, dns_adbaddrinfo_t *addrinfo) {
@@ -10099,8 +10099,15 @@ rctx_resend(respctx_t *rctx, dns_adbaddrinfo_t *addrinfo) {
        isc_result_t result;
 
        FCTXTRACE("resend");
-       inc_stats(fctx->res, dns_resstatscounter_retry);
+
+       CHECK(incr_query_counters(fctx));
+
        result = fctx_query(fctx, addrinfo, rctx->retryopts);
+       if (result == ISC_R_SUCCESS) {
+               inc_stats(fctx->res, dns_resstatscounter_retry);
+       }
+
+cleanup:
        if (result != ISC_R_SUCCESS) {
                fctx_done_detach(&rctx->fctx, result);
        }