]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Address PR comments of reword and remove rsp payload size check 15532/head
authorOliver Chen <oliver.chen@nokia-sbell.com>
Mon, 9 Jun 2025 01:54:00 +0000 (01:54 +0000)
committerOliver Chen <oliver.chen@nokia-sbell.com>
Wed, 11 Jun 2025 00:11:21 +0000 (00:11 +0000)
pdns/dnsdistdist/dnsdist-settings-definitions.yml
pdns/dnsdistdist/dnsdist.cc
pdns/dnsdistdist/docs/reference/config.rst
regression-tests.dnsdist/test_Caching.py

index 7a60899eeebea3927047abdf6cd6bac42edbc1ac..84858a572b1abedc0f47f4f1c61f3da20f8d9397 100644 (file)
@@ -1939,7 +1939,7 @@ packet_cache:
     - name: "payload_ranks"
       type: "Vec<u16>"
       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"
index e364a326193fc8ebb8a3eca275a5ed93142781c2..2ff8063213e9c7e631ab2607408abc3d6e1efcae 100644 (file)
@@ -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<const char*>(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) {
index c0352669631a6af5a52316da58abed952a935460..8adffc1fb681bba229456f402c410ea50fe3ea88 100644 (file)
@@ -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
 
index 78aa81d2311b817669ccba2503c6b1b6887718cb..8483944232498e6deed5f7277cdde0001fde041e 100644 (file)
@@ -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,