From 190db5c21945d2aec18692978abfe60bd460732a Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 6 Jun 2025 15:14:13 +0200 Subject: [PATCH] dnsdist: Do not waste CPU cycles handling EDNS twice on self-generated answers Signed-off-by: Remi Gacogne --- pdns/dnsdistdist/dnsdist-self-answers.cc | 5 ++++- pdns/dnsdistdist/dnsdist.cc | 2 +- pdns/dnsdistdist/dnsdist.hh | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pdns/dnsdistdist/dnsdist-self-answers.cc b/pdns/dnsdistdist/dnsdist-self-answers.cc index 4e0b66084e..be608fbd6e 100644 --- a/pdns/dnsdistdist/dnsdist-self-answers.cc +++ b/pdns/dnsdistdist/dnsdist-self-answers.cc @@ -94,6 +94,7 @@ bool generateAnswerFromCNAME(DNSQuestion& dnsQuestion, const DNSName& cname, con addEDNS(dnsQuestion.getMutableData(), dnsQuestion.getMaximumSize(), dnssecOK, dnsdist::configuration::getCurrentRuntimeConfiguration().d_payloadSizeSelfGenAnswers, 0); } + dnsQuestion.d_selfGeneratedHandledEDNS = true; return true; } @@ -164,6 +165,7 @@ bool generateAnswerFromIPAddresses(DNSQuestion& dnsQuestion, const std::vectorid; dnsQuestion.getMutableData() = packet; - dnsQuestion.d_selfGeneratedFromPacket = true; + dnsQuestion.d_selfGeneratedHandledEDNS = true; dnsdist::PacketMangling::editDNSHeaderFromPacket(dnsQuestion.getMutableData(), [questionId](dnsheader& header) { header.id = questionId; return true; diff --git a/pdns/dnsdistdist/dnsdist.cc b/pdns/dnsdistdist/dnsdist.cc index b96617e0a5..ff05ffdc21 100644 --- a/pdns/dnsdistdist/dnsdist.cc +++ b/pdns/dnsdistdist/dnsdist.cc @@ -326,7 +326,7 @@ static bool fixUpQueryTurnedResponse(DNSQuestion& dnsQuestion, const uint16_t or return true; }); - if (dnsQuestion.d_selfGeneratedFromPacket) { + if (dnsQuestion.d_selfGeneratedHandledEDNS) { return true; } return addEDNSToQueryTurnedResponse(dnsQuestion); diff --git a/pdns/dnsdistdist/dnsdist.hh b/pdns/dnsdistdist/dnsdist.hh index 06b32ade6f..2d10591eab 100644 --- a/pdns/dnsdistdist/dnsdist.hh +++ b/pdns/dnsdistdist/dnsdist.hh @@ -184,7 +184,7 @@ public: bool ecsOverride; bool useECS{true}; bool asynchronous{false}; - bool d_selfGeneratedFromPacket{false}; + bool d_selfGeneratedHandledEDNS{false}; }; struct DownstreamState; -- 2.47.2