From: Oliver Chen Date: Mon, 9 Jun 2025 01:54:00 +0000 (+0000) Subject: Address PR comments of reword and remove rsp payload size check X-Git-Tag: dnsdist-2.0.0-beta1~36^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c13e71f31bc328c8498cbb432dac6ab8556bbc4;p=thirdparty%2Fpdns.git Address PR comments of reword and remove rsp payload size check --- diff --git a/pdns/dnsdistdist/dnsdist-settings-definitions.yml b/pdns/dnsdistdist/dnsdist-settings-definitions.yml index 7a60899eee..84858a572b 100644 --- a/pdns/dnsdistdist/dnsdist-settings-definitions.yml +++ b/pdns/dnsdistdist/dnsdist-settings-definitions.yml @@ -1939,7 +1939,7 @@ packet_cache: - name: "payload_ranks" type: "Vec" default: "[]" - description: "List of payload size used when hashing the packet. The list will be sorted in ascend order and searched to find a lower bound value for the payload size in the packet. If found then it will be used for packet hashing. Values less than 512 or greater than ``maximum_entry_size`` above will be discarded. This option is to enable cache entry sharing between clients using different payload sizes when needed" + description: "List of payload size used when hashing the packet. The list will be sorted in ascending order and searched to find a lower bound value for the payload size in the packet. If found then it will be used for packet hashing. Values less than 512 or greater than ``maximum_entry_size`` above will be discarded. This option is to enable cache entry sharing between clients using different payload sizes when needed" proxy_protocol: description: "Proxy Protocol-related settings" diff --git a/pdns/dnsdistdist/dnsdist.cc b/pdns/dnsdistdist/dnsdist.cc index e364a32619..2ff8063213 100644 --- a/pdns/dnsdistdist/dnsdist.cc +++ b/pdns/dnsdistdist/dnsdist.cc @@ -639,15 +639,7 @@ void handleResponseSent(const DNSName& qname, const QType& qtype, double udiff, static void handleResponseTC4UDPClient(uint16_t udpPayloadSize, PacketBuffer& response, DNSResponse& dnsResponse) { - if (udpPayloadSize == 0) { - uint16_t zValue = 0; - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) - getEDNSUDPPayloadSizeAndZ(reinterpret_cast(response.data()), response.size(), &udpPayloadSize, &zValue); - if (udpPayloadSize < 512) { - udpPayloadSize = 512; - } - } - if (response.size() > udpPayloadSize) { + if (udpPayloadSize > 0 && response.size() > udpPayloadSize) { vinfolog("Got a response of size %d while the initial UDP payload size was %d, truncating", response.size(), udpPayloadSize); truncateTC(dnsResponse.getMutableData(), dnsResponse.getMaximumSize(), dnsResponse.ids.qname.wirelength(), dnsdist::configuration::getCurrentRuntimeConfiguration().d_addEDNSToSelfGeneratedResponses); dnsdist::PacketMangling::editDNSHeaderFromPacket(dnsResponse.getMutableData(), [](dnsheader& header) { diff --git a/pdns/dnsdistdist/docs/reference/config.rst b/pdns/dnsdistdist/docs/reference/config.rst index c035266963..8adffc1fb6 100644 --- a/pdns/dnsdistdist/docs/reference/config.rst +++ b/pdns/dnsdistdist/docs/reference/config.rst @@ -1065,7 +1065,7 @@ See :doc:`../guides/cache` for a how to. * ``cookieHashing=false``: bool - If true, EDNS Cookie values will be hashed, resulting in separate entries for different cookies in the packet cache. This is required if the backend is sending answers with EDNS Cookies, otherwise a client might receive an answer with the wrong cookie. * ``skipOptions={}``: Extra list of EDNS option codes to skip when hashing the packet (if ``cookieHashing`` above is false, EDNS cookie option number will be added to this list internally). * ``maximumEntrySize=4096``: int - The maximum size, in bytes, of a DNS packet that can be inserted into the packet cache. Default is 4096 bytes, which was the fixed size before 1.9.0, and is also a hard limit for UDP responses. - * ``payloadRanks={}``: List of payload size used when hashing the packet. The list will be sorted in ascend order and searched to find a lower bound value for the payload size in the packet. If found then it will be used for packet hashing. Values less than 512 or greater than ``maximumEntrySize`` above will be discarded. This option is to enable cache entry sharing between clients using different payload sizes when needed. + * ``payloadRanks={}``: List of payload size used when hashing the packet. The list will be sorted in ascending order and searched to find a lower bound value for the payload size in the packet. If found then it will be used for packet hashing. Values less than 512 or greater than ``maximumEntrySize`` above will be discarded. This option is to enable cache entry sharing between clients using different payload sizes when needed. .. class:: PacketCache diff --git a/regression-tests.dnsdist/test_Caching.py b/regression-tests.dnsdist/test_Caching.py index 78aa81d231..8483944232 100644 --- a/regression-tests.dnsdist/test_Caching.py +++ b/regression-tests.dnsdist/test_Caching.py @@ -544,7 +544,7 @@ class TestCaching(DNSDistTest): if len(content) > 0: content = content + ', ' content = content + (str(i)*50) - # pad up to 4096 + # pad up to 4096 (less 11 for EDNS) content = content + 'A'*31 rrset = dns.rrset.from_text(name,