]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Skip EDNS padding content by default in the packet cache
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 1 Sep 2025 16:29:57 +0000 (18:29 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 1 Sep 2025 16:29:57 +0000 (18:29 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-cache.hh
pdns/dnsdistdist/dnsdist-configuration-yaml.cc
pdns/dnsdistdist/dnsdist-lua-bindings-packetcache.cc
pdns/dnsdistdist/dnsdist-settings-definitions.yml
pdns/dnsdistdist/docs/reference/config.rst

index 64e19883c3535ae8d7e77ffd55fcd2705b78bd63..8efc1701c56a2d47c18b65bffec6758eef0c11a3 100644 (file)
@@ -37,7 +37,7 @@ class DNSDistPacketCache : boost::noncopyable
 public:
   struct CacheSettings
   {
-    std::unordered_set<uint16_t> d_optionsToSkip{EDNSOptionCode::COOKIE};
+    std::unordered_set<uint16_t> d_optionsToSkip{EDNSOptionCode::COOKIE, EDNSOptionCode::PADDING};
     std::vector<uint16_t> d_payloadRanks{};
     size_t d_maxEntries{0};
     size_t d_maximumEntrySize{4096};
index b124b85c2e76555b044677a2150becf3829a9e01..94e3a0a0c4982e2565e7cf0dd649984d2cc50462 100644 (file)
@@ -1158,8 +1158,12 @@ bool loadConfigurationFromFile(const std::string& fileName, [[maybe_unused]] boo
         .d_keepStaleData = cache.keep_stale_data,
       };
       std::unordered_set<uint16_t> ranks;
-      for (const auto& option : cache.options_to_skip) {
-        settings.d_optionsToSkip.insert(pdns::checked_stoi<uint16_t>(std::string(option)));
+      if (!cache.options_to_skip.empty()) {
+        settings.d_optionsToSkip.clear();
+        settings.d_optionsToSkip.insert(EDNSOptionCode::COOKIE);
+        for (const auto& option : cache.options_to_skip) {
+          settings.d_optionsToSkip.insert(pdns::checked_stoi<uint16_t>(std::string(option)));
+        }
       }
       if (cache.cookie_hashing) {
         settings.d_optionsToSkip.erase(EDNSOptionCode::COOKIE);
index 6441128f72aeeaa79aec3a0d548542ab9c60ab26..9e08e3794f8ac0f22ed74b6b7d0f51baef920fb4 100644 (file)
@@ -62,6 +62,8 @@ void setupLuaBindingsPacketCache(LuaContext& luaCtx, bool client)
     }
 
     if (getOptionalValue<decltype(skipOptions)>(vars, "skipOptions", skipOptions) > 0) {
+      settings.d_optionsToSkip.clear();
+      settings.d_optionsToSkip.insert(EDNSOptionCode::COOKIE);
       for (const auto& option : skipOptions) {
         settings.d_optionsToSkip.insert(option.second);
       }
index 879386af0a174dc0a6b097a06dfd62d5e88c2d2b..556623387d5fff0860c965577105d7ffaf963c12 100644 (file)
@@ -1952,8 +1952,8 @@ packet_cache:
       description: "The maximum size, in bytes, of a DNS packet that can be inserted into the packet cache"
     - name: "options_to_skip"
       type: "Vec<String>"
-      default: ""
-      description: "Extra list of EDNS option codes to skip when hashing the packet (if ``cookie_hashing`` above is false, EDNS cookie option number will be added to this list internally)"
+      default: "10, 12"
+      description: "Extra list of EDNS option codes to skip when hashing the packet (if ``cookie_hashing`` above is true, EDNS cookie option number (10) will be removed from this list internally)"
     - name: "payload_ranks"
       type: "Vec<u16>"
       default: "[]"
index 329e364c3255bab075dd93fec52b716b3983572f..d25fc8fe952bfe77a135637cfd68d30a42bb8dd4 100644 (file)
@@ -1053,6 +1053,9 @@ See :doc:`../guides/cache` for a how to.
   .. versionchanged:: 2.0.0
     ``payloadRanks`` parameter added.
 
+  .. versionchanged:: 2.0.1
+    ``skipOptions`` now includes 12 (PADDING) by default.
+
   Creates a new :class:`PacketCache` with the settings specified.
 
   :param int maxEntries: The maximum number of entries in this cache
@@ -1071,7 +1074,7 @@ See :doc:`../guides/cache` for a how to.
   * ``temporaryFailureTTL=60``: int - On a SERVFAIL or REFUSED from the backend, cache for this amount of seconds.
   * ``truncatedTTL=0``: int - On a truncated (TC=1, no records) response from the backend, cache for this amount of seconds. 0, the default, means that truncated answers are not cached.
   * ``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).
+  * ``skipOptions={12}``: 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 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.