]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use stale data also if we are not resuming
authorMatthijs Mekking <matthijs@isc.org>
Tue, 19 Jan 2021 08:04:29 +0000 (09:04 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Mon, 8 Feb 2021 15:07:43 +0000 (16:07 +0100)
Before this change, BIND will only fallback to using stale data if
there was an actual attempt to resolve the query. Then on a timeout,
the stale data from cache becomes eligible.

This commit changes this so that on any unexpected error stale data
becomes eligble (you would still have to have 'stale-answer-enable'
enabled of course).

If there is no stale data, this may return in an error again, so don't
loop on stale data lookup attempts. If the DNS_DBFIND_STALEOK flag is
set, this means we already tried to lookup stale data, so if that is
the case, don't use stale again.

(cherry picked from commit c6fd02aed534e21989fafd7b45b132a21c24fdbc)

lib/ns/query.c

index 124653afc15f43543cd71a684a61e42e04e68b9e..08ff43d7ec15440a51a44ee22ff24497de056117 100644 (file)
@@ -7147,6 +7147,14 @@ root_key_sentinel_return_servfail(query_ctx_t *qctx, isc_result_t result) {
  */
 static bool
 query_usestale(query_ctx_t *qctx) {
+       if ((qctx->client->query.dboptions & DNS_DBFIND_STALEOK) != 0) {
+               /*
+                * Query was already using stale, if that didn't work the
+                * last time, it won't work this time either.
+                */
+               return (false);
+       }
+
        qctx_clean(qctx);
        qctx_freedata(qctx);
 
@@ -7257,7 +7265,7 @@ query_gotanswer(query_ctx_t *qctx, isc_result_t res) {
                         "query_gotanswer: unexpected error: %s",
                         isc_result_totext(result));
                CCTRACE(ISC_LOG_ERROR, errmsg);
-               if (qctx->resuming && query_usestale(qctx)) {
+               if (query_usestale(qctx)) {
                        /*
                         * If serve-stale is enabled, query_usestale() already
                         * set up 'qctx' for looking up a stale response.