]> 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 11:07:34 +0000 (12:07 +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.

(cherry picked from commit f8b7b597e9a73d5c7fa72b337f4b112e8cf7a876)

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

index 73b4c2865ec32fef7a06b23954fad79644aa1afd..28c35646280f22924f7b6a1b19e49828fd40ac66 100755 (executable)
@@ -1069,6 +1069,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 9ff1d215345e86efd77a4a6ad22b30d376510768..c0887111710b9c74747f25720dbea23d75bb4bd1 100644 (file)
@@ -5907,6 +5907,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;
        }