From: Otto Moerbeek Date: Fri, 9 May 2025 10:29:40 +0000 (+0200) Subject: Factor out the code to compute the EDNS Error code X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2d2e499cdffbaeaaa592363d13d3c2ebb9387e35;p=thirdparty%2Fpdns.git Factor out the code to compute the EDNS Error code --- diff --git a/pdns/dnsrecords.hh b/pdns/dnsrecords.hh index da1c8cb8d..4dc32d6aa 100644 --- a/pdns/dnsrecords.hh +++ b/pdns/dnsrecords.hh @@ -1301,6 +1301,10 @@ struct EDNSOpts uint8_t d_extRCode, d_version; [[nodiscard]] vector>::const_iterator getFirstOption(uint16_t optionCode) const; + [[nodiscard]] uint16_t getCombinedERCode(uint8_t rcode) const + { + return (static_cast(d_extRCode) << 4) | rcode; + } }; //! Convenience function that fills out EDNS0 options, and returns true if there are any diff --git a/pdns/recursordist/lwres.cc b/pdns/recursordist/lwres.cc index 6903ddc00..234c86577 100644 --- a/pdns/recursordist/lwres.cc +++ b/pdns/recursordist/lwres.cc @@ -497,7 +497,7 @@ static std::pair incomingCookie(const OptLog& log, const } found->setSupport(CookieEntry::Support::Supported, now.tv_sec); // check extended error code - uint16_t ercode = (edo.d_extRCode << 4) | lwr.d_rcode; + uint16_t ercode = edo.getCombinedERCode(lwr.d_rcode); if (ercode == ERCode::BADCOOKIE) { lwr.d_validpacket = true; ++t_Counters.at(rec::Counter::cookieRetry);