From: bert hubert Date: Wed, 31 Jan 2018 15:59:03 +0000 (+0100) Subject: Fix ECS-based cache entry refresh code X-Git-Tag: dnsdist-1.3.0~78^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9c681bf96bae3be671bb086efbfc99b09f3031b;p=pdns Fix ECS-based cache entry refresh code This would lead to us not refreshing ECS-varying answers in the cache, and therefore an even more depressed cache rate. Thanks to @liordot who found the issue & provided a fix in #6241. --- diff --git a/pdns/recursor_cache.cc b/pdns/recursor_cache.cc index d3245420f..ea9a4612f 100644 --- a/pdns/recursor_cache.cc +++ b/pdns/recursor_cache.cc @@ -93,7 +93,6 @@ MemRecursorCache::cache_t::const_iterator MemRecursorCache::getEntryUsingECSInde /* we have nothing more specific for you */ break; } - auto key = boost::make_tuple(qname, qtype, best); auto entry = d_cache.find(key); if (entry == d_cache.end()) { @@ -264,23 +263,23 @@ bool MemRecursorCache::attemptToRefreshNSTTL(const QType& qt, const vector& content, const vector>& signatures, const std::vector>& authorityRecs, bool auth, boost::optional ednsmask, vState state) { d_cachecachevalid = false; - + // cerr<<"Replacing "<toString() : "everyone") << endl; auto key = boost::make_tuple(qname, qt.getCode(), ednsmask ? *ednsmask : Netmask()); bool isNew = false; cache_t::iterator stored = d_cache.find(key); if (stored == d_cache.end()) { stored = d_cache.insert(CacheEntry(key, CacheEntry::records_t(), auth)).first; isNew = true; + } - /* don't bother building an ecsIndex if we don't have any netmask-specific entries */ - if (ednsmask && !ednsmask->empty()) { - auto ecsIndexKey = boost::make_tuple(qname, qt.getCode()); - auto ecsIndex = d_ecsIndex.find(ecsIndexKey); - if (ecsIndex == d_ecsIndex.end()) { - ecsIndex = d_ecsIndex.insert(ECSIndexEntry(qname, qt.getCode())).first; - } - ecsIndex->addMask(*ednsmask); + /* don't bother building an ecsIndex if we don't have any netmask-specific entries */ + if (ednsmask && !ednsmask->empty()) { + auto ecsIndexKey = boost::make_tuple(qname, qt.getCode()); + auto ecsIndex = d_ecsIndex.find(ecsIndexKey); + if (ecsIndex == d_ecsIndex.end()) { + ecsIndex = d_ecsIndex.insert(ECSIndexEntry(qname, qt.getCode())).first; } + ecsIndex->addMask(*ednsmask); } time_t maxTTD=std::numeric_limits::max();