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);
}
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; }
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) {
}
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"))) {
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;
});
* ``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
/* 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;