From: Remi Gacogne Date: Fri, 6 Jun 2025 13:14:13 +0000 (+0200) Subject: dnsdist: Do not waste CPU cycles handling EDNS twice on self-generated answers X-Git-Tag: dnsdist-2.0.0-beta1~23^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F15602%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Do not waste CPU cycles handling EDNS twice on self-generated answers Signed-off-by: Remi Gacogne --- 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;