]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Don't servfail on staleonly lookups
authorMatthijs Mekking <matthijs@isc.org>
Mon, 22 Feb 2021 11:08:49 +0000 (12:08 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Thu, 25 Feb 2021 10:32:17 +0000 (11:32 +0100)
When a staleonly lookup doesn't find a satisfying answer, it should
not try to respond to the client.

This is not true when the initial lookup is staleonly (that is when
'stale-answer-client-timeout' is set to 0), because no resolver fetch
has been created at this point. In this case continue with the lookup
normally.

bin/tests/system/serve-stale/tests.sh
lib/ns/query.c

index 4b85dd358e88221d804ed816959d3e10095c7f43..8ca4cf1511121dfa4290286fd3ab2572356e7ce9 100755 (executable)
@@ -1068,6 +1068,16 @@ status=$((status+ret))
 
 sleep 2
 
+# Check that if we don't have stale data for a domain name, we will
+# not answer anything until the resolver query timeout.
+n=$((n+1))
+echo_i "check notincache.example times out (max-stale-ttl default) ($n)"
+ret=0
+$DIG -p ${PORT} +tries=1 +timeout=3  @10.53.0.3 notfound.example TXT > dig.out.test$n 2>&1
+grep "connection timed out" dig.out.test$n > /dev/null || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=$((status+ret))
+
 echo_i "sending queries for tests $((n+1))-$((n+4))..."
 $DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$((n+1)) &
 $DIG -p ${PORT} @10.53.0.3 othertype.example CAA > dig.out.test$((n+2)) &
index 8dd1a7f3611bd8d1f7bfbfd0e842da660734afeb..52e40922c94e997690f603e76bdd36ce50ebc761 100644 (file)
@@ -5972,6 +5972,15 @@ query_lookup(query_ctx_t *qctx) {
                                }
                        }
                }
+       } else if (stale_only && result != ISC_R_SUCCESS) {
+               /*
+                * This is a staleonly lookup and no stale answer was found
+                * in cache. Treat as we don't have an answer and wait for
+                * the resolver fetch to finish.
+                */
+               if ((qctx->options & DNS_GETDB_STALEFIRST) == 0) {
+                       return (result);
+               }
        } else {
                stale_only = false;
        }