]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Test shorter resolver-query-timeout configuration
authorAram Sargsyan <aram@isc.org>
Thu, 6 Jun 2024 09:20:44 +0000 (09:20 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Thu, 1 Aug 2024 18:30:35 +0000 (18:30 +0000)
Add two new checks which test the shorter than usual
resolver-query-timeout configuration.

bin/tests/system/resolver/ans3/ans.pl
bin/tests/system/resolver/ns1/named.conf.in
bin/tests/system/resolver/tests.sh

index 85d46cd4eb21e9ce3a5ee6e249c1daefe61970fb..02a8c1d6a60297cbd775ab253b48326ad66f4f0f 100644 (file)
@@ -74,6 +74,10 @@ sub handleQuery {
                $packet->push("answer", new Net::DNS::RR($qname . " 300 A 10.53.0.3"));
        } elsif ($qname eq "nodata.example.net") {
                # Do not add a SOA RRset.
+       } elsif ($qname eq "noresponse.example.net") {
+               # Do not response.
+               print "RESPONSE:\n";
+               return "";
        } elsif ($qname eq "nxdomain.example.net") {
                # Do not add a SOA RRset.
                $packet->header->rcode(NXDOMAIN);
@@ -217,8 +221,12 @@ for (;;) {
                        print "TCP request\n";
                        my $result = handleQuery($buf);
                        $len = length($result);
-                       $conn->syswrite(pack("n", $len), 2);
-                       $n = $conn->syswrite($result, $len);
+                       if ($len != 0) {
+                               $conn->syswrite(pack("n", $len), 2);
+                               $n = $conn->syswrite($result, $len);
+                       } else {
+                               $n = 0;
+                       }
                        print "    Sent: $n chars via TCP\n";
                }
                $conn->close;
index fbcb6c1dd3a278f9696c2f8f3915140192918846..d212869fa3e4793454e6021763b139576973a57f 100644 (file)
@@ -28,6 +28,7 @@ options {
                              "gooddname.example.net"; };
        allow-query {!10.53.0.8; any; };
        max-zone-ttl unlimited;
+       resolver-query-timeout 5000; # 5 seconds
        attach-cache "globalcache";
 };
 
index a728806fb3ff6e134bb08feccc886ea6b069ee10..0e6db14457a4d97c2a11a6b228b6667b4464f8ae 100755 (executable)
@@ -43,6 +43,28 @@ grep "status: NOERROR" dig.out.ns1.test${n} >/dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
+# 'resolver-query-timeout' is set to 5 seconds in ns1, so dig with a lower
+# timeout value should give up earlier than that.
+n=$((n + 1))
+echo_i "checking no response handling with a shorter than resolver-query-timeout timeout ($n)"
+ret=0
+dig_with_opts +tcp +tries=1 +timeout=3 noresponse.example.net @10.53.0.1 a >dig.out.ns1.test${n} && ret=1
+grep -F "no servers could be reached" dig.out.ns1.test${n} >/dev/null || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=$((status + ret))
+
+# 'resolver-query-timeout' is set to 5 seconds in ns1, which is lower than the
+# current single query timeout value MAX_SINGLE_QUERY_TIMEOUT of 9 seconds, so
+# the "hung fetch" timer should kick in, interrupt the non-responsive query and
+# send a SERVFAIL answer.
+n=$((n + 1))
+echo_i "checking no response handling with a longer than resolver-query-timeout timeout ($n)"
+ret=0
+dig_with_opts +tcp +tries=1 +timeout=7 noresponse.example.net @10.53.0.1 a >dig.out.ns1.test${n} || ret=1
+grep -F "status: SERVFAIL" dig.out.ns1.test${n} >/dev/null || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=$((status + ret))
+
 n=$((n + 1))
 echo_i "checking handling of bogus referrals ($n)"
 # If the server has the "INSIST(!external)" bug, this query will kill it.