From: Otto Moerbeek Date: Fri, 15 Nov 2024 10:00:45 +0000 (+0100) Subject: Improvement: use const vector plus names for the various types used X-Git-Tag: dnsdist-2.0.0-alpha1~195^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d8e16f30952b85c8624bd47d6ab7cf402d770b98;p=thirdparty%2Fpdns.git Improvement: use const vector plus names for the various types used --- diff --git a/pdns/recursordist/rec-zonetocache.cc b/pdns/recursordist/rec-zonetocache.cc index 63829270ba..2c667c2ed0 100644 --- a/pdns/recursordist/rec-zonetocache.cc +++ b/pdns/recursordist/rec-zonetocache.cc @@ -420,7 +420,7 @@ void ZoneData::ZoneToCache(const RecZoneToCache::Config& config) bool auth = isRRSetAuth(qname, qtype); // Same decision as updateCacheFromRecords() (we do not test for NSEC since we skip those completely) if (auth || (qtype == QType::NS || qtype == QType::A || qtype == QType::AAAA || qtype == QType::DS)) { - g_recCache->replace(d_now, qname, qtype, v, sigsrr, nullptr, + g_recCache->replace(d_now, qname, qtype, v, sigsrr, {}, auth, d_zone); } break; diff --git a/pdns/recursordist/recursor_cache.cc b/pdns/recursordist/recursor_cache.cc index 486d285d3d..380275a535 100644 --- a/pdns/recursordist/recursor_cache.cc +++ b/pdns/recursordist/recursor_cache.cc @@ -76,6 +76,8 @@ uint16_t MemRecursorCache::s_maxServedStaleExtensions; uint16_t MemRecursorCache::s_maxRRSetSize = 256; bool MemRecursorCache::s_limitQTypeAny = true; +const MemRecursorCache::AuthRecs MemRecursorCache::s_emptyAuthRecs = std::make_shared(); + void MemRecursorCache::resetStaticsForTests() { s_maxServedStaleExtensions = 0; @@ -172,7 +174,7 @@ static void ptrAssign(T* ptr, const T& value) } } -time_t MemRecursorCache::handleHit(time_t now, MapCombo::LockedContent& content, MemRecursorCache::OrderedTagIterator_t& entry, const DNSName& qname, uint32_t& origTTL, vector* res, vector>* signatures, std::shared_ptr>* authorityRecs, bool* variable, boost::optional& state, bool* wasAuth, DNSName* fromAuthZone, ComboAddress* fromAuthIP) +time_t MemRecursorCache::handleHit(time_t now, MapCombo::LockedContent& content, MemRecursorCache::OrderedTagIterator_t& entry, const DNSName& qname, uint32_t& origTTL, vector* res, vector>* signatures, AuthRecs* authorityRecs, bool* variable, boost::optional& state, bool* wasAuth, DNSName* fromAuthZone, ComboAddress* fromAuthIP) { // MUTEX SHOULD BE ACQUIRED (as indicated by the reference to the content which is protected by a lock) if (entry->d_tooBig) { @@ -215,7 +217,7 @@ time_t MemRecursorCache::handleHit(time_t now, MapCombo::LockedContent& content, } if (authorityRecs != nullptr) { - *authorityRecs = entry->d_authorityRecs ? entry->d_authorityRecs : std::make_shared>(); + *authorityRecs = entry->d_authorityRecs ? entry->d_authorityRecs : s_emptyAuthRecs; } updateDNSSECValidationStateFromCache(state, entry->d_state); @@ -382,7 +384,7 @@ time_t MemRecursorCache::fakeTTD(MemRecursorCache::OrderedTagIterator_t& entry, } // returns -1 for no hits -time_t MemRecursorCache::get(time_t now, const DNSName& qname, const QType qtype, Flags flags, vector* res, const ComboAddress& who, const OptTag& routingTag, vector>* signatures, std::shared_ptr>* authorityRecs, bool* variable, vState* state, bool* wasAuth, DNSName* fromAuthZone, ComboAddress* fromAuthIP) // NOLINT(readability-function-cognitive-complexity) +time_t MemRecursorCache::get(time_t now, const DNSName& qname, const QType qtype, Flags flags, vector* res, const ComboAddress& who, const OptTag& routingTag, vector>* signatures, AuthRecs* authorityRecs, bool* variable, vState* state, bool* wasAuth, DNSName* fromAuthZone, ComboAddress* fromAuthIP) // NOLINT(readability-function-cognitive-complexity) { bool requireAuth = (flags & RequireAuth) != 0; bool refresh = (flags & Refresh) != 0; @@ -585,7 +587,7 @@ bool MemRecursorCache::replace(CacheEntry&& entry) return false; } -void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qtype, const vector& content, const vector>& signatures, const std::shared_ptr>& authorityRecs, bool auth, const DNSName& authZone, boost::optional ednsmask, const OptTag& routingTag, vState state, boost::optional from, bool refresh, time_t ttl_time) +void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qtype, const vector& content, const vector>& signatures, const AuthRecsVec& authorityRecs, bool auth, const DNSName& authZone, boost::optional ednsmask, const OptTag& routingTag, vState state, boost::optional from, bool refresh, time_t ttl_time) { auto& shard = getMap(qname); auto lockedShard = shard.lock(); @@ -646,8 +648,8 @@ void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qty } cacheEntry.d_signatures = signatures; - if (authorityRecs && !authorityRecs->empty()) { - cacheEntry.d_authorityRecs = authorityRecs; + if (!authorityRecs.empty()) { + cacheEntry.d_authorityRecs = std::make_shared(authorityRecs); } else { cacheEntry.d_authorityRecs = nullptr; @@ -1097,7 +1099,7 @@ size_t MemRecursorCache::getRecordSets(size_t perShard, size_t maxSize, std::str return count; } -static void putAuthRecord(protozero::pbf_message& message, const DNSName& qname, std::shared_ptr>& authRecs) +static void putAuthRecord(protozero::pbf_message& message, const DNSName& qname, std::vector& authRecs) { protozero::pbf_message auth = message.get_message(); DNSRecord authRecord; @@ -1130,12 +1132,13 @@ static void putAuthRecord(protozero::pbf_message& message, const D break; } } - authRecs->emplace_back(authRecord); + authRecs.emplace_back(authRecord); } template bool MemRecursorCache::putRecordSet(T& message) { + std::vector authRecs; CacheEntry cacheEntry{{g_rootdnsname, QType::A, boost::none, Netmask()}, false}; while (message.next()) { switch (message.tag()) { @@ -1153,7 +1156,7 @@ bool MemRecursorCache::putRecordSet(T& message) if (!cacheEntry.d_authorityRecs) { cacheEntry.d_authorityRecs = std::make_shared>(); } - putAuthRecord(message, cacheEntry.d_qname, cacheEntry.d_authorityRecs); + putAuthRecord(message, cacheEntry.d_qname, authRecs); break; case PBCacheEntry::required_bytes_name: cacheEntry.d_qname = DNSName(message.get_bytes()); @@ -1199,6 +1202,9 @@ bool MemRecursorCache::putRecordSet(T& message) break; } } + if (!authRecs.empty()) { + cacheEntry.d_authorityRecs = std::make_shared>(authRecs); + } return replace(std::move(cacheEntry)); } diff --git a/pdns/recursordist/recursor_cache.hh b/pdns/recursordist/recursor_cache.hh index a096ccf610..43822af5cd 100644 --- a/pdns/recursordist/recursor_cache.hh +++ b/pdns/recursordist/recursor_cache.hh @@ -73,9 +73,18 @@ public: static constexpr Flags Refresh = 1 << 1; static constexpr Flags ServeStale = 1 << 2; - [[nodiscard]] time_t get(time_t, const DNSName& qname, QType qtype, Flags flags, vector* res, const ComboAddress& who, const OptTag& routingTag = boost::none, vector>* signatures = nullptr, std::shared_ptr>* authorityRecs = nullptr, bool* variable = nullptr, vState* state = nullptr, bool* wasAuth = nullptr, DNSName* fromAuthZone = nullptr, ComboAddress* fromAuthIP = nullptr); + // The type used to pass auth record data to replace(); If the vector is non-empty, the cache will + // store a shared pointer to the copied data. The shared pointer will be returned by get(). There + // are optimizations: an empty vector will be stored as a nullptr, but get() will return a pointer + // to an already existing empty vector in that case, this is more convenient for the caller, since + // it avoid checking for nullptr, just iterate as for the non-empty case. + using AuthRecsVec = std::vector; + using AuthRecs = std::shared_ptr; // const to avoid modifying the vector, which would be bad for shared data + const static AuthRecs s_emptyAuthRecs; - void replace(time_t, const DNSName& qname, QType qtype, const vector& content, const vector>& signatures, const std::shared_ptr>& authorityRecs, bool auth, const DNSName& authZone, boost::optional ednsmask = boost::none, const OptTag& routingTag = boost::none, vState state = vState::Indeterminate, boost::optional from = boost::none, bool refresh = false, time_t ttl_time = time(nullptr)); + [[nodiscard]] time_t get(time_t, const DNSName& qname, QType qtype, Flags flags, vector* res, const ComboAddress& who, const OptTag& routingTag = boost::none, vector>* signatures = nullptr, AuthRecs* authorityRecs = nullptr, bool* variable = nullptr, vState* state = nullptr, bool* wasAuth = nullptr, DNSName* fromAuthZone = nullptr, ComboAddress* fromAuthIP = nullptr); + + void replace(time_t, const DNSName& qname, QType qtype, const vector& content, const vector>& signatures, const AuthRecsVec& authorityRecs, bool auth, const DNSName& authZone, boost::optional ednsmask = boost::none, const OptTag& routingTag = boost::none, vState state = vState::Indeterminate, boost::optional from = boost::none, bool refresh = false, time_t ttl_time = time(nullptr)); void doPrune(time_t now, size_t keep); uint64_t doDump(int fileDesc, size_t maxCacheEntries); @@ -135,7 +144,7 @@ private: records_t d_records; std::vector> d_signatures; - std::shared_ptr> d_authorityRecs; + AuthRecs d_authorityRecs; DNSName d_qname; DNSName d_authZone; ComboAddress d_from; @@ -347,7 +356,7 @@ private: static Entries getEntries(MapCombo::LockedContent& map, const DNSName& qname, QType qtype, const OptTag& rtag); static cache_t::const_iterator getEntryUsingECSIndex(MapCombo::LockedContent& map, time_t now, const DNSName& qname, QType qtype, bool requireAuth, const ComboAddress& who, bool serveStale); - static time_t handleHit(time_t now, MapCombo::LockedContent& content, OrderedTagIterator_t& entry, const DNSName& qname, uint32_t& origTTL, vector* res, vector>* signatures, std::shared_ptr>* authorityRecs, bool* variable, boost::optional& state, bool* wasAuth, DNSName* authZone, ComboAddress* fromAuthIP); + static time_t handleHit(time_t now, MapCombo::LockedContent& content, OrderedTagIterator_t& entry, const DNSName& qname, uint32_t& origTTL, vector* res, vector>* signatures, AuthRecs* authorityRecs, bool* variable, boost::optional& state, bool* wasAuth, DNSName* authZone, ComboAddress* fromAuthIP); static void updateStaleEntry(time_t now, OrderedTagIterator_t& entry); static void handleServeStaleBookkeeping(time_t, bool, OrderedTagIterator_t&); }; diff --git a/pdns/recursordist/reczones-helpers.cc b/pdns/recursordist/reczones-helpers.cc index 0e29d6f5c3..82ed158f17 100644 --- a/pdns/recursordist/reczones-helpers.cc +++ b/pdns/recursordist/reczones-helpers.cc @@ -41,7 +41,7 @@ static void putIntoCache(time_t now, QType qtype, vState state, const ComboAddre // Put non-default root hints into cache as authoritative. As argued below in // putDefaultHintsIntoCache, this is actually wrong, but people might depend on it by having // root-hints that refer to servers that aren't actually capable or willing to serve root data. - g_recCache->replace(now, name, qtype, aset, {}, nullptr, true, g_rootdnsname, boost::none, boost::none, state, from); + g_recCache->replace(now, name, qtype, aset, {}, {}, true, g_rootdnsname, boost::none, boost::none, state, from); } } diff --git a/pdns/recursordist/syncres.cc b/pdns/recursordist/syncres.cc index 0b7a2577bc..b62add31b9 100644 --- a/pdns/recursordist/syncres.cc +++ b/pdns/recursordist/syncres.cc @@ -2556,7 +2556,7 @@ bool SyncRes::doCNAMECacheCheck(const DNSName& qname, const QType qtype, vector< { vector cset; vector> signatures; - std::shared_ptr> authorityRecs = std::make_shared>(); + MemRecursorCache::AuthRecs authorityRecs = MemRecursorCache::s_emptyAuthRecs; bool wasAuth = false; uint32_t capTTL = std::numeric_limits::max(); DNSName foundName; @@ -2999,7 +2999,7 @@ bool SyncRes::doCacheCheck(const DNSName& qname, const DNSName& authname, bool w bool found = false; bool expired = false; vector> signatures; - std::shared_ptr> authorityRecs = std::make_shared>(); + MemRecursorCache::AuthRecs authorityRecs = MemRecursorCache::s_emptyAuthRecs; uint32_t ttl = 0; uint32_t capTTL = std::numeric_limits::max(); bool wasCachedAuth{}; @@ -3606,7 +3606,7 @@ bool SyncRes::validationEnabled() return g_dnssecmode != DNSSECMode::Off && g_dnssecmode != DNSSECMode::ProcessNoValidate; } -uint32_t SyncRes::computeLowestTTD(const std::vector& records, const std::vector>& signatures, uint32_t signaturesTTL, const std::shared_ptr>& authorityRecs) const +uint32_t SyncRes::computeLowestTTD(const std::vector& records, const std::vector>& signatures, uint32_t signaturesTTL, const MemRecursorCache::AuthRecsVec& authorityRecs) const { uint32_t lowestTTD = std::numeric_limits::max(); for (const auto& record : records) { @@ -3628,7 +3628,7 @@ uint32_t SyncRes::computeLowestTTD(const std::vector& records, const } } - for (const auto& entry : *authorityRecs) { + for (const auto& entry : authorityRecs) { /* be careful, this is still a TTL here */ lowestTTD = min(lowestTTD, static_cast(entry.d_ttl + d_now.tv_sec)); @@ -4536,7 +4536,7 @@ RCode::rcodes_ SyncRes::updateCacheFromRecords(unsigned int depth, const string& fixupAnswer(prefix, lwr, qname, qtype, auth, wasForwarded, rdQuery); sanitizeRecords(prefix, lwr, qname, qtype, auth, wasForwarded, rdQuery); - std::shared_ptr> authorityRecs = std::make_shared>(); + MemRecursorCache::AuthRecsVec authorityRecs; bool isCNAMEAnswer = false; bool isDNAMEAnswer = false; DNSName seenAuth; @@ -4633,12 +4633,12 @@ RCode::rcodes_ SyncRes::updateCacheFromRecords(unsigned int depth, const string& } if (nsecTypes.count(rec.d_type) != 0) { - authorityRecs->emplace_back(rec); + authorityRecs.emplace_back(rec); } else if (rec.d_type == QType::RRSIG) { auto rrsig = getRR(rec); if (rrsig && nsecTypes.count(rrsig->d_type) != 0) { - authorityRecs->emplace_back(rec); + authorityRecs.emplace_back(rec); } } } @@ -4711,7 +4711,7 @@ RCode::rcodes_ SyncRes::updateCacheFromRecords(unsigned int depth, const string& // supplant for (auto& entry : tcache) { - if ((entry.second.records.size() + entry.second.signatures.size() + authorityRecs->size()) > 1) { // need to group the ttl to be the minimum of the RRSET (RFC 2181, 5.2) + if ((entry.second.records.size() + entry.second.signatures.size() + authorityRecs.size()) > 1) { // need to group the ttl to be the minimum of the RRSET (RFC 2181, 5.2) uint32_t lowestTTD = computeLowestTTD(entry.second.records, entry.second.signatures, entry.second.signaturesTTL, authorityRecs); for (auto& record : entry.second.records) { @@ -4882,7 +4882,7 @@ RCode::rcodes_ SyncRes::updateCacheFromRecords(unsigned int depth, const string& thisRRNeedsWildcardProof = true; } } - g_recCache->replace(d_now.tv_sec, tCacheEntry->first.name, tCacheEntry->first.type, tCacheEntry->second.records, tCacheEntry->second.signatures, thisRRNeedsWildcardProof ? authorityRecs : nullptr, tCacheEntry->first.type == QType::DS ? true : isAA, auth, tCacheEntry->first.place == DNSResourceRecord::ANSWER ? ednsmask : boost::none, d_routingTag, recordState, remoteIP, d_refresh, tCacheEntry->second.d_ttl_time); + g_recCache->replace(d_now.tv_sec, tCacheEntry->first.name, tCacheEntry->first.type, tCacheEntry->second.records, tCacheEntry->second.signatures, thisRRNeedsWildcardProof ? authorityRecs : *MemRecursorCache::s_emptyAuthRecs, tCacheEntry->first.type == QType::DS ? true : isAA, auth, tCacheEntry->first.place == DNSResourceRecord::ANSWER ? ednsmask : boost::none, d_routingTag, recordState, remoteIP, d_refresh, tCacheEntry->second.d_ttl_time); // Delete potential negcache entry. When a record recovers with serve-stale the negcache entry can cause the wrong entry to // be served, as negcache entries are checked before record cache entries diff --git a/pdns/recursordist/syncres.hh b/pdns/recursordist/syncres.hh index fac3b8c95d..5385332110 100644 --- a/pdns/recursordist/syncres.hh +++ b/pdns/recursordist/syncres.hh @@ -678,7 +678,7 @@ private: boost::optional getEDNSSubnetMask(const DNSName& name, const ComboAddress& rem); static bool validationEnabled(); - uint32_t computeLowestTTD(const std::vector& records, const std::vector>& signatures, uint32_t signaturesTTL, const std::shared_ptr>& authorityRecs) const; + uint32_t computeLowestTTD(const std::vector& records, const std::vector>& signatures, uint32_t signaturesTTL, const MemRecursorCache::AuthRecsVec& authorityRecs) const; void updateValidationState(const DNSName& qname, vState& state, vState stateUpdate, const string& prefix); vState validateRecordsWithSigs(unsigned int depth, const string& prefix, const DNSName& qname, QType qtype, const DNSName& name, QType type, const std::vector& records, const std::vector>& signatures); vState validateDNSKeys(const DNSName& zone, const std::vector& dnskeys, const std::vector>& signatures, unsigned int depth, const string& prefix); diff --git a/pdns/recursordist/test-recursorcache_cc.cc b/pdns/recursordist/test-recursorcache_cc.cc index 2ef01e2f78..5f8478089a 100644 --- a/pdns/recursordist/test-recursorcache_cc.cc +++ b/pdns/recursordist/test-recursorcache_cc.cc @@ -21,7 +21,7 @@ static void simple(time_t now) MemRecursorCache MRC; std::vector records; - std::shared_ptr> authRecords; + MemRecursorCache::AuthRecsVec authRecords; std::vector> signatures; const DNSName authZone("."); @@ -444,7 +444,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheGhost) MemRecursorCache MRC; std::vector records; - std::shared_ptr> authRecords; + MemRecursorCache::AuthRecsVec authRecords; std::vector> signatures; time_t now = time(nullptr); @@ -488,7 +488,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheReplaceAuthByNonAuthMargin) MemRecursorCache MRC; std::vector records; - std::shared_ptr> authRecords; + MemRecursorCache::AuthRecsVec authRecords; std::vector> signatures; time_t now = time(nullptr); @@ -535,7 +535,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries) std::vector records; std::vector> signatures; - std::shared_ptr> authRecs; + MemRecursorCache::AuthRecsVec authRecs; const DNSName authZone("."); BOOST_CHECK_EQUAL(MRC.size(), 0U); time_t now = time(nullptr); @@ -630,7 +630,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingValidEntries) std::vector records; std::vector> signatures; - std::shared_ptr> authRecs; + MemRecursorCache::AuthRecsVec authRecs; const DNSName authZone("."); BOOST_CHECK_EQUAL(MRC.size(), 0U); time_t now = time(nullptr); @@ -810,7 +810,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheECSIndex) const DNSName power("powerdns.com."); const DNSName authZone("."); std::vector records; - std::shared_ptr> authRecords; + MemRecursorCache::AuthRecsVec authRecords; std::vector> signatures; time_t now = time(nullptr); std::vector retrieved; @@ -970,7 +970,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_Wipe) const DNSName power("powerdns.com."); const DNSName authZone("."); std::vector records; - std::shared_ptr> authRecords; + MemRecursorCache::AuthRecsVec authRecords; std::vector> signatures; time_t now = time(nullptr); std::vector retrieved; @@ -1059,7 +1059,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged) MemRecursorCache MRC; const DNSName authZone("."); - std::shared_ptr> authRecords; + MemRecursorCache::AuthRecsVec authRecords; std::vector> signatures; time_t now = time(nullptr); time_t ttd = now + 30; @@ -1293,14 +1293,14 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheDumpAndRestore) MemRecursorCache MRC; const DNSName authZone("."); - std::shared_ptr> authRecords = std::make_shared>(); + MemRecursorCache::AuthRecsVec authRecords; DNSRecord dr; dr.d_place = DNSResourceRecord::ANSWER; dr.d_name = DNSName("hi"); dr.d_type = QType::AAAA; dr.d_ttl = 3600; dr.setContent(std::make_shared(ComboAddress("1::2:3:4"))); - authRecords->emplace_back(dr); + authRecords.emplace_back(dr); std::vector> signatures; signatures.emplace_back(std::dynamic_pointer_cast(RRSIGRecordContent::make("DNSKEY 8 0 172800 20241111000000 20241021000000 20326 . alCFgDZS+0l5zcpQ/7R+5OFeCrk9KGkNP2F9ynXIXG6QigPj/9qjm0xx ItRJUUim+SrJywAmLKe+48oTUeSRyDKVVg3LGDekLKcIVz0EBqTL2y44 usDlUlxqx5O0LQVHy4h/hm9+dCXFiSBWoV0LcAplV9OYWhxi+CxmxZU5 8vK6eVAde8E2JHdeDuy23WF5lxYEg1q7ehEt5EdRvZ7hZzfawEFR3Qv3 WMootO2eBAAneIe94daJP/i1iwQJ4p+bGVCZ4sJk+Pk9J7lwEQq6Ghkd SpLsRxArUhvoVgtnh0LkAV7TsajYk8K2JRt7wHNDbBV6+Vdq2bh7ZPGv LiGkIQ=="))); @@ -1340,7 +1340,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheDumpAndRestore) for (size_t counter = 0; counter < expected + 10; counter++) { std::vector retrieved; - std::shared_ptr> authRecs; + MemRecursorCache::AuthRecs authRecs; std::vector> sigs; bool variable = false; vState state = vState::Indeterminate; @@ -1355,7 +1355,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheDumpAndRestore) BOOST_CHECK_EQUAL(sigs.at(0)->getZoneRepresentation(), signatures.at(0)->getZoneRepresentation()); BOOST_CHECK_EQUAL(authRecs->size(), 1U); - BOOST_CHECK_EQUAL(authRecs->at(0).toString(), authRecords->at(0).toString()); + BOOST_CHECK_EQUAL(authRecs->at(0).toString(), authRecords.at(0).toString()); BOOST_CHECK_EQUAL(state, vState::Insecure); BOOST_CHECK_EQUAL(wasAuth, true); BOOST_CHECK_EQUAL(fromZone, authZone); diff --git a/pdns/recursordist/test-syncres_cc.cc b/pdns/recursordist/test-syncres_cc.cc index 1228e582ae..25ff8e09e0 100644 --- a/pdns/recursordist/test-syncres_cc.cc +++ b/pdns/recursordist/test-syncres_cc.cc @@ -102,18 +102,18 @@ bool primeHints(time_t now) arr.setContent(std::make_shared(ComboAddress(rootIps4[c - 'a']))); vector aset; aset.push_back(arr); - g_recCache->replace(now, DNSName(templ), QType(QType::A), aset, vector>(), nullptr, false, g_rootdnsname); + g_recCache->replace(now, DNSName(templ), QType(QType::A), aset, vector>(), {}, false, g_rootdnsname); if (!rootIps6[c - 'a'].empty()) { aaaarr.setContent(std::make_shared(ComboAddress(rootIps6[c - 'a']))); vector aaaaset; aaaaset.push_back(aaaarr); - g_recCache->replace(now, DNSName(templ), QType(QType::AAAA), aaaaset, vector>(), nullptr, false, g_rootdnsname); + g_recCache->replace(now, DNSName(templ), QType(QType::AAAA), aaaaset, vector>(), {}, false, g_rootdnsname); } nsset.push_back(nsrr); } - g_recCache->replace(now, g_rootdnsname, QType(QType::NS), nsset, vector>(), nullptr, false, g_rootdnsname); // and stuff in the cache + g_recCache->replace(now, g_rootdnsname, QType(QType::NS), nsset, vector>(), {}, false, g_rootdnsname); // and stuff in the cache return true; } diff --git a/pdns/recursordist/test-syncres_cc2.cc b/pdns/recursordist/test-syncres_cc2.cc index b3c373589b..1a2d30a700 100644 --- a/pdns/recursordist/test-syncres_cc2.cc +++ b/pdns/recursordist/test-syncres_cc2.cc @@ -1465,7 +1465,7 @@ BOOST_AUTO_TEST_CASE(test_flawed_nsset) std::vector> sigs; addRecordToList(records, target, QType::NS, "pdns-public-ns1.powerdns.com.", DNSResourceRecord::AUTHORITY, now + 3600); - g_recCache->replace(now, target, QType(QType::NS), records, sigs, nullptr, true, g_rootdnsname, boost::optional()); + g_recCache->replace(now, target, QType(QType::NS), records, sigs, {}, true, g_rootdnsname, boost::optional()); vector ret; int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret); @@ -1571,7 +1571,7 @@ BOOST_AUTO_TEST_CASE(test_cache_hit) std::vector> sigs; addRecordToList(records, target, QType::A, "192.0.2.1", DNSResourceRecord::ANSWER, now + 3600); - g_recCache->replace(now, target, QType(QType::A), records, sigs, nullptr, true, g_rootdnsname, boost::optional()); + g_recCache->replace(now, target, QType(QType::A), records, sigs, {}, true, g_rootdnsname, boost::optional()); vector ret; int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret); @@ -1760,7 +1760,7 @@ BOOST_AUTO_TEST_CASE(test_cache_expired_ttl) std::vector> sigs; addRecordToList(records, target, QType::A, "192.0.2.42", DNSResourceRecord::ANSWER, now - 60); - g_recCache->replace(now - 3600, target, QType(QType::A), records, sigs, nullptr, true, g_rootdnsname, boost::optional()); + g_recCache->replace(now - 3600, target, QType(QType::A), records, sigs, {}, true, g_rootdnsname, boost::optional()); vector ret; int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret); diff --git a/pdns/recursordist/test-syncres_cc3.cc b/pdns/recursordist/test-syncres_cc3.cc index 8f683ac388..c78997e360 100644 --- a/pdns/recursordist/test-syncres_cc3.cc +++ b/pdns/recursordist/test-syncres_cc3.cc @@ -1342,6 +1342,7 @@ BOOST_AUTO_TEST_CASE(test_forward_zone_recurse_rd_dnssec_cname_wildcard_expanded res = testSR->beginResolve(target, QType(QType::A), QClass::IN, ret); BOOST_CHECK_EQUAL(res, RCode::NoError); BOOST_CHECK_EQUAL(testSR->getValidationState(), vState::Insecure); + BOOST_CHECK(MemRecursorCache::s_emptyAuthRecs->empty()); BOOST_REQUIRE_EQUAL(ret.size(), 5U); BOOST_CHECK_EQUAL(queriesCount, 5U); }