]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Prevent TCP failures from affecting EDNS stats
authorMichał Kępień <michal@isc.org>
Thu, 31 Oct 2019 07:48:35 +0000 (08:48 +0100)
committerMichał Kępień <michal@isc.org>
Thu, 31 Oct 2019 08:54:05 +0000 (09:54 +0100)
EDNS mechanisms only apply to DNS over UDP.  Thus, errors encountered
while sending DNS queries over TCP must not influence EDNS timeout
statistics.

bin/tests/system/legacy/tests.sh
lib/dns/resolver.c

index a7319840ddc56aa34d51030a483a160d9661bf39..ed784d9615d332c87ef6216ba584193c8166acbf 100755 (executable)
@@ -241,6 +241,18 @@ fi
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
 
+n=`expr $n + 1`
+echo_i "checking that TCP failures do not influence EDNS statistics in the ADB ($n)"
+ret=0
+rndc_dumpdb ns1 -adb || ret=1
+timeouts512=`sed -n "s|.*10\.53\.0\.7.*\[edns \([0-9/][0-9/]*\).*|\1|p" ns1/named_dump.db.test$n | awk -F/ '{print $NF}'`
+if [ $timeouts512 -ne 0 ]; then
+       echo_i "512-byte EDNS timeouts according to ADB: $timeouts512, expected: 0"
+       ret=1
+fi
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=`expr $status + $ret`
+
 $PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} legacy ns1
 copy_setports ns1/named2.conf.in ns1/named.conf
 $PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} legacy ns1
index 11ef066608f4343357a50d0951df348e49ea2dfd..70bfa2232a70579ca50ef2f9b30d7c803c92a783 100644 (file)
@@ -1142,6 +1142,25 @@ resquery_destroy(resquery_t **queryp) {
                empty_bucket(res);
 }
 
+/*%
+ * Update EDNS statistics for a server after not getting a response to a UDP
+ * query sent to it.
+ */
+static void
+update_edns_stats(resquery_t *query) {
+       fetchctx_t *fctx = query->fctx;
+
+       if ((query->options & DNS_FETCHOPT_TCP) != 0) {
+               return;
+       }
+
+       if ((query->options & DNS_FETCHOPT_NOEDNS0) == 0) {
+               dns_adb_ednsto(fctx->adb, query->addrinfo, query->udpsize);
+       } else {
+               dns_adb_timeout(fctx->adb, query->addrinfo);
+       }
+}
+
 static void
 fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
                 isc_time_t *finish, bool no_response,
@@ -1202,11 +1221,7 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp,
                        uint32_t value;
                        uint32_t mask;
 
-                       if ((query->options & DNS_FETCHOPT_NOEDNS0) == 0)
-                               dns_adb_ednsto(fctx->adb, query->addrinfo,
-                                              query->udpsize);
-                       else
-                               dns_adb_timeout(fctx->adb, query->addrinfo);
+                       update_edns_stats(query);
 
                        /*
                         * If "forward first;" is used and a forwarder timed