]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
remove DNSDistPacketCache::setCookieHashing and clarify documentation and code about...
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Wed, 6 Oct 2021 10:14:12 +0000 (12:14 +0200)
committerCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Wed, 6 Oct 2021 10:14:12 +0000 (12:14 +0200)
pdns/dnsdist-cache.cc
pdns/dnsdist-cache.hh
pdns/dnsdistdist/dnsdist-lua-bindings-packetcache.cc
pdns/dnsdistdist/docs/reference/config.rst
pdns/fuzz_dnsdistcache.cc

index 4d14e2f24a90c15853a7be9f28258216d16c8e92..d023dee942391de0b43f929768ced3fe1e09466f 100644 (file)
@@ -480,23 +480,7 @@ uint64_t DNSDistPacketCache::dump(int fd)
   return count;
 }
 
-bool DNSDistPacketCache::isCookieHashingEnabled() const
+void DNSDistPacketCache::setSkippedOptions(const std::unordered_set<uint16_t>& optionsToSkip)
 {
-  return d_optionsToSkip.count(EDNSOptionCode::COOKIE) == 0;
-}
-
-void DNSDistPacketCache::setCookieHashing(bool hashing)
-{
-  if (hashing) {
-    d_optionsToSkip.erase(EDNSOptionCode::COOKIE);
-  } else {
-    d_optionsToSkip.insert(EDNSOptionCode::COOKIE);
-  }
-}
-
-void DNSDistPacketCache::skipOptions(const std::unordered_set<uint16_t>& optionsToSkip)
-{
-  bool cookieHasingEnabled = isCookieHashingEnabled();
   d_optionsToSkip = optionsToSkip;
-  setCookieHashing(cookieHasingEnabled);
 }
index a9462420e604e4985a2636d9c09768f3cd3ccd10..3309459ecb9b16b3dcea5817b5ab0bf53ef916bd 100644 (file)
@@ -55,9 +55,7 @@ public:
   uint64_t getTTLTooShorts() const { return d_ttlTooShorts; }
   uint64_t getEntriesCount();
   uint64_t dump(int fd);
-  bool isCookieHashingEnabled() const;
-  void setCookieHashing(bool hashing);
-  void skipOptions(const std::unordered_set<uint16_t>& optionsToSkip);
+  void setSkippedOptions(const std::unordered_set<uint16_t>& optionsToSkip);
 
   bool isECSParsingEnabled() const { return d_parseECS; }
 
index feddcef7401bed401d14036dcfa9fb5594568c79..f77051e41759b16bf5a79ddd205187ce99bec6bf 100644 (file)
@@ -45,8 +45,7 @@ void setupLuaBindingsPacketCache(LuaContext& luaCtx, bool client)
       bool dontAge = false;
       bool deferrableInsertLock = true;
       bool ecsParsing = false;
-      bool cookieHashing = false;
-      std::unordered_set<uint16_t> optionsToSkip{};
+      std::unordered_set<uint16_t> optionsToSkip{EDNSOptionCode::COOKIE};
 
       if (vars) {
 
@@ -91,7 +90,9 @@ void setupLuaBindingsPacketCache(LuaContext& luaCtx, bool client)
         }
 
         if (vars->count("cookieHashing")) {
-          cookieHashing = boost::get<bool>((*vars)["cookieHashing"]);
+          if (boost::get<bool>((*vars)["cookieHashing"])) {
+            optionsToSkip.erase(EDNSOptionCode::COOKIE);
+          }
         }
         if (vars->count("skipOptions")) {
           for (auto option: boost::get<std::vector<std::pair<int, uint16_t>>>(vars->at("skipOptions"))) {
@@ -114,8 +115,7 @@ void setupLuaBindingsPacketCache(LuaContext& luaCtx, bool client)
       auto res = std::make_shared<DNSDistPacketCache>(maxEntries, maxTTL, minTTL, tempFailTTL, maxNegativeTTL, staleTTL, dontAge, numberOfShards, deferrableInsertLock, ecsParsing);
 
       res->setKeepStaleData(keepStaleData);
-      res->setCookieHashing(cookieHashing);
-      res->skipOptions(optionsToSkip);
+      res->setSkippedOptions(optionsToSkip);
 
       return res;
     });
index 2a010057f1c67b89bb34f95dfd2be2a25a69c706..e001042d9e22ad339c7e4ee80a24188ef86491f7 100644 (file)
@@ -797,7 +797,7 @@ See :doc:`../guides/cache` for a how to.
   * ``staleTTL=60``: int - When the backend servers are not reachable, and global configuration ``setStaleCacheEntriesTTL`` is set appropriately, TTL that will be used when a stale cache entry is returned.
   * ``temporaryFailureTTL=60``: int - On a SERVFAIL or REFUSED from the backend, cache for this amount of seconds..
   * ``cookieHashing=false``: bool - Whether 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 (see ``cookieHashing`` above).
+  * ``skipOptions={}``: Extra list of EDNS option codes to skip when hashing the packet (if ``cookieHashing`` above is false, EDNS cookie option number will already be added to this list).
 
 .. class:: PacketCache
 
index eb68950bddd132b71ffad458966a4c154d8f2edb..c224449533e057a36e44f78bb984be77eb35c9fe 100644 (file)
@@ -32,12 +32,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
 
   /* dnsdist's version */
   DNSDistPacketCache pcSkipCookies(10000);
+  // By default, cookies are not hashed
   pcSkipCookies.setECSParsingEnabled(true);
-  pcSkipCookies.setCookieHashing(false);
 
   DNSDistPacketCache pcHashCookies(10000);
   pcHashCookies.setECSParsingEnabled(true);
-  pcHashCookies.setCookieHashing(true);
+  // Do not skip cookies
+  pcHashCookies.setSkippedOptions({});
 
   try {
     uint16_t qtype;