]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix an ADB quota management error in the resolver
authorAram Sargsyan <aram@isc.org>
Thu, 22 Dec 2022 13:48:33 +0000 (13:48 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Fri, 23 Dec 2022 10:08:00 +0000 (10:08 +0000)
Normally, when a 'resquery_t' object is created in fctx_query(),
we call dns_adb_beginudpfetch() (which increases the ADB quota)
only if it's a UDP query. Then, in fctx_cancelquery(), we call
dns_adb_endudpfetch() to decreases back the ADB quota, again only
if it's a UDP query.

The problem is that a UDP query can become a TCP query, preventing
the quota from adjusting back in fctx_cancelquery() later.

Call dns_adb_beginudpfetch() also when switching the query type
from UDP to TCP.

(cherry picked from commit 53afe1f978c7c46d961a00d2149f333bf6f0b687)

lib/dns/resolver.c

index 6f95acd9b2ff58707d6109e57ca4772be366caa5..1b6a8894e8c936ef375deed5a5bd378cb237d0dd 100644 (file)
@@ -2633,7 +2633,16 @@ resquery_send(resquery_t *query) {
                                hint = dns_adb_getudpsize(fctx->adb,
                                                          query->addrinfo);
                        } else if (tried->count >= 2U) {
-                               query->options |= DNS_FETCHOPT_TCP;
+                               if ((query->options & DNS_FETCHOPT_TCP) == 0) {
+                                       /*
+                                        * Inform the ADB that we're ending a
+                                        * UDP fetch, and turn the query into
+                                        * a TCP query.
+                                        */
+                                       dns_adb_endudpfetch(fctx->adb,
+                                                           query->addrinfo);
+                                       query->options |= DNS_FETCHOPT_TCP;
+                               }
                        }
                }
        }