diff --git a/bin/tests/system/resolver/ans3/ans.pl b/bin/tests/system/resolver/ans3/ans.pl index 85d46cd4eb..02a8c1d6a6 100644 --- a/bin/tests/system/resolver/ans3/ans.pl +++ b/bin/tests/system/resolver/ans3/ans.pl @@ -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; diff --git a/bin/tests/system/resolver/ns1/named.conf.in b/bin/tests/system/resolver/ns1/named.conf.in index fbcb6c1dd3..d212869fa3 100644 --- a/bin/tests/system/resolver/ns1/named.conf.in +++ b/bin/tests/system/resolver/ns1/named.conf.in @@ -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"; }; diff --git a/bin/tests/system/resolver/tests.sh b/bin/tests/system/resolver/tests.sh index a728806fb3..0e6db14457 100755 --- a/bin/tests/system/resolver/tests.sh +++ b/bin/tests/system/resolver/tests.sh @@ -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.