diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 1b6eaa395a..963c9086a0 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -810,6 +810,7 @@ typedef struct respctx { bool ns_in_answer; /* NS may be in the answer * section */ bool negative; /* is this a negative response? */ + bool force_edns_0; isc_stdtime_t now; /* time info */ isc_time_t tnow; @@ -8418,6 +8419,10 @@ rctx_edns(respctx_t *rctx) { "EDNS version negotiation: rcode != " "BADVERS(16): %u" GREASE_NSID_FMT, query->rmessage->rcode, GREASE_NSID_INFO); + if (query->rmessage->rcode != dns_rcode_nxdomain && + query->rmessage->rcode != dns_rcode_noerror) { + rctx->force_edns_0 = true; + } } /* @@ -10125,6 +10130,12 @@ rctx_badserver(respctx_t *rctx, isc_result_t result) { } query->addrinfo->flags |= FCTX_ADDRINFO_BADCOOKIE; rctx->resend = true; + } else if (rctx->force_edns_0) { + unsigned int flags = DNS_FETCHOPT_EDNSVERSIONSET; + unsigned int mask = DNS_FETCHOPT_EDNSVERSIONMASK | + DNS_FETCHOPT_EDNSVERSIONSET; + dns_adb_changeflags(fctx->adb, query->addrinfo, flags, mask); + rctx->resend = true; } else { rctx->broken_server = DNS_R_UNEXPECTEDRCODE; rctx->next_server = true;