From dd7dde5743715dc0dec2defbb92b1a8637977bf9 Mon Sep 17 00:00:00 2001
From: Matthijs Mekking <matthijs@isc.org>
Date: Tue, 2 Aug 2022 14:21:40 +0200
Subject: [PATCH] Don't enable serve-stale on duplicate queries

When checking if we should enable serve-stale, add an early out case
when the result is an error signalling a duplicate query or a query
that would be dropped.

(cherry picked from commit 059a4c2f4d9d3cff371842f43208d021509314fa)
---
 lib/ns/query.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/ns/query.c b/lib/ns/query.c
index d0f025dbb9a..1bf36fea283 100644
--- a/lib/ns/query.c
+++ b/lib/ns/query.c
@@ -7230,6 +7230,14 @@ query_usestale(query_ctx_t *qctx, isc_result_t result) {
 		return (false);
 	}
 
+	if (result == DNS_R_DUPLICATE || result == DNS_R_DROP) {
+		/*
+		 * Don't enable serve-stale if the result signals a duplicate
+		 * query or query that is being dropped.
+		 */
+		return (false);
+	}
+
 	qctx_clean(qctx);
 	qctx_freedata(qctx);
 
-- 
GitLab

