]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: experiment: authRecs a shared pointer of DNSRecs instead of a vec of shared...
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 13 Nov 2024 15:05:04 +0000 (16:05 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 18 Dec 2024 08:55:50 +0000 (09:55 +0100)
pdns/recursordist/rec-zonetocache.cc
pdns/recursordist/recursor_cache.cc
pdns/recursordist/recursor_cache.hh
pdns/recursordist/reczones-helpers.cc
pdns/recursordist/syncres.cc
pdns/recursordist/syncres.hh
pdns/recursordist/test-recursorcache_cc.cc
pdns/recursordist/test-syncres_cc.cc
pdns/recursordist/test-syncres_cc2.cc

index f7fb5dc1c23b4771d4e7eb254ff026dea06a4c92..63829270ba0b05c30619b53bf277212b8853d7bb 100644 (file)
@@ -420,8 +420,8 @@ 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,
-                            std::vector<std::shared_ptr<DNSRecord>>(), auth, d_zone);
+        g_recCache->replace(d_now, qname, qtype, v, sigsrr, nullptr,
+                            auth, d_zone);
       }
       break;
     }
index c919b6cf57dae40fd0633cff94ba834877ac7fa6..486d285d3d3a8108bab7c6e088acd83b1caa9ab9 100644 (file)
@@ -172,7 +172,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<DNSRecord>* res, vector<std::shared_ptr<const RRSIGRecordContent>>* signatures, std::vector<std::shared_ptr<DNSRecord>>* authorityRecs, bool* variable, boost::optional<vState>& 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<DNSRecord>* res, vector<std::shared_ptr<const RRSIGRecordContent>>* signatures, std::shared_ptr<std::vector<DNSRecord>>* authorityRecs, bool* variable, boost::optional<vState>& 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 +215,7 @@ time_t MemRecursorCache::handleHit(time_t now, MapCombo::LockedContent& content,
   }
 
   if (authorityRecs != nullptr) {
-    authorityRecs->insert(authorityRecs->end(), entry->d_authorityRecs.begin(), entry->d_authorityRecs.end());
+    *authorityRecs = entry->d_authorityRecs ? entry->d_authorityRecs : std::make_shared<vector<DNSRecord>>();
   }
 
   updateDNSSECValidationStateFromCache(state, entry->d_state);
@@ -382,7 +382,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<DNSRecord>* res, const ComboAddress& who, const OptTag& routingTag, vector<std::shared_ptr<const RRSIGRecordContent>>* signatures, std::vector<std::shared_ptr<DNSRecord>>* 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<DNSRecord>* res, const ComboAddress& who, const OptTag& routingTag, vector<std::shared_ptr<const RRSIGRecordContent>>* signatures, std::shared_ptr<std::vector<DNSRecord>>* 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 +585,7 @@ bool MemRecursorCache::replace(CacheEntry&& entry)
   return false;
 }
 
-void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qtype, const vector<DNSRecord>& content, const vector<shared_ptr<const RRSIGRecordContent>>& signatures, const std::vector<std::shared_ptr<DNSRecord>>& authorityRecs, bool auth, const DNSName& authZone, boost::optional<Netmask> ednsmask, const OptTag& routingTag, vState state, boost::optional<ComboAddress> from, bool refresh, time_t ttl_time)
+void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qtype, const vector<DNSRecord>& content, const vector<shared_ptr<const RRSIGRecordContent>>& signatures, const std::shared_ptr<std::vector<DNSRecord>>& authorityRecs, bool auth, const DNSName& authZone, boost::optional<Netmask> ednsmask, const OptTag& routingTag, vState state, boost::optional<ComboAddress> from, bool refresh, time_t ttl_time)
 {
   auto& shard = getMap(qname);
   auto lockedShard = shard.lock();
@@ -646,7 +646,12 @@ void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qty
   }
 
   cacheEntry.d_signatures = signatures;
-  cacheEntry.d_authorityRecs = authorityRecs;
+  if (authorityRecs && !authorityRecs->empty()) {
+    cacheEntry.d_authorityRecs = authorityRecs;
+  }
+  else {
+    cacheEntry.d_authorityRecs = nullptr;
+  }
   cacheEntry.d_records.clear();
   cacheEntry.d_authZone = authZone;
   if (from) {
@@ -1019,15 +1024,15 @@ void MemRecursorCache::getRecordSet(T& message, U recordSet)
   for (const auto& record : recordSet->d_signatures) {
     message.add_bytes(PBCacheEntry::repeated_bytes_sig, record->serialize(recordSet->d_qname, true));
   }
-  for (const auto& authRec : recordSet->d_authorityRecs) {
+  for (const auto& authRec : *recordSet->d_authorityRecs) {
     protozero::pbf_builder<PBAuthRecord> auth(message, PBCacheEntry::repeated_message_authRecord);
-    auth.add_bytes(PBAuthRecord::required_bytes_name, authRec->d_name.toString());
-    auth.add_bytes(PBAuthRecord::required_bytes_rdata, authRec->getContent()->serialize(authRec->d_name, true));
-    auth.add_uint32(PBAuthRecord::required_uint32_type, authRec->d_type);
-    auth.add_uint32(PBAuthRecord::required_uint32_class, authRec->d_class);
-    auth.add_uint32(PBAuthRecord::required_uint32_ttl, authRec->d_ttl);
-    auth.add_uint32(PBAuthRecord::required_uint32_place, authRec->d_place);
-    auth.add_uint32(PBAuthRecord::required_uint32_clen, authRec->d_clen);
+    auth.add_bytes(PBAuthRecord::required_bytes_name, authRec.d_name.toString());
+    auth.add_bytes(PBAuthRecord::required_bytes_rdata, authRec.getContent()->serialize(authRec.d_name, true));
+    auth.add_uint32(PBAuthRecord::required_uint32_type, authRec.d_type);
+    auth.add_uint32(PBAuthRecord::required_uint32_class, authRec.d_class);
+    auth.add_uint32(PBAuthRecord::required_uint32_ttl, authRec.d_ttl);
+    auth.add_uint32(PBAuthRecord::required_uint32_place, authRec.d_place);
+    auth.add_uint32(PBAuthRecord::required_uint32_clen, authRec.d_clen);
   }
   message.add_bytes(PBCacheEntry::required_bytes_authZone, recordSet->d_authZone.toString());
   encodeComboAddress(message, PBCacheEntry::required_message_from, recordSet->d_from);
@@ -1092,7 +1097,7 @@ size_t MemRecursorCache::getRecordSets(size_t perShard, size_t maxSize, std::str
   return count;
 }
 
-static void putAuthRecord(protozero::pbf_message<PBCacheEntry>& message, const DNSName& qname, std::vector<std::shared_ptr<DNSRecord>>& authRecs)
+static void putAuthRecord(protozero::pbf_message<PBCacheEntry>& message, const DNSName& qname, std::shared_ptr<std::vector<DNSRecord>>& authRecs)
 {
   protozero::pbf_message<PBAuthRecord> auth = message.get_message();
   DNSRecord authRecord;
@@ -1125,7 +1130,7 @@ static void putAuthRecord(protozero::pbf_message<PBCacheEntry>& message, const D
       break;
     }
   }
-  authRecs.emplace_back(std::make_shared<DNSRecord>(authRecord));
+  authRecs->emplace_back(authRecord);
 }
 
 template <typename T>
@@ -1145,6 +1150,9 @@ bool MemRecursorCache::putRecordSet(T& message)
       break;
     }
     case PBCacheEntry::repeated_message_authRecord:
+      if (!cacheEntry.d_authorityRecs) {
+        cacheEntry.d_authorityRecs = std::make_shared<std::vector<DNSRecord>>();
+      }
       putAuthRecord(message, cacheEntry.d_qname, cacheEntry.d_authorityRecs);
       break;
     case PBCacheEntry::required_bytes_name:
index 5941315827c7f9fbb1519744048f243537cd1d7d..a096ccf610fc32125ee9970d142f1e74126c1c95 100644 (file)
@@ -73,9 +73,9 @@ 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<DNSRecord>* res, const ComboAddress& who, const OptTag& routingTag = boost::none, vector<std::shared_ptr<const RRSIGRecordContent>>* signatures = nullptr, std::vector<std::shared_ptr<DNSRecord>>* authorityRecs = nullptr, bool* variable = nullptr, vState* state = nullptr, bool* wasAuth = nullptr, DNSName* fromAuthZone = nullptr, ComboAddress* fromAuthIP = nullptr);
+  [[nodiscard]] time_t get(time_t, const DNSName& qname, QType qtype, Flags flags, vector<DNSRecord>* res, const ComboAddress& who, const OptTag& routingTag = boost::none, vector<std::shared_ptr<const RRSIGRecordContent>>* signatures = nullptr, std::shared_ptr<std::vector<DNSRecord>>* 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<DNSRecord>& content, const vector<shared_ptr<const RRSIGRecordContent>>& signatures, const std::vector<std::shared_ptr<DNSRecord>>& authorityRecs, bool auth, const DNSName& authZone, boost::optional<Netmask> ednsmask = boost::none, const OptTag& routingTag = boost::none, vState state = vState::Indeterminate, boost::optional<ComboAddress> from = boost::none, bool refresh = false, time_t ttl_time = time(nullptr));
+  void replace(time_t, const DNSName& qname, QType qtype, const vector<DNSRecord>& content, const vector<shared_ptr<const RRSIGRecordContent>>& signatures, const std::shared_ptr<std::vector<DNSRecord>>& authorityRecs, bool auth, const DNSName& authZone, boost::optional<Netmask> ednsmask = boost::none, const OptTag& routingTag = boost::none, vState state = vState::Indeterminate, boost::optional<ComboAddress> 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 +135,7 @@ private:
 
     records_t d_records;
     std::vector<std::shared_ptr<const RRSIGRecordContent>> d_signatures;
-    std::vector<std::shared_ptr<DNSRecord>> d_authorityRecs;
+    std::shared_ptr<std::vector<DNSRecord>> d_authorityRecs;
     DNSName d_qname;
     DNSName d_authZone;
     ComboAddress d_from;
@@ -347,7 +347,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<DNSRecord>* res, vector<std::shared_ptr<const RRSIGRecordContent>>* signatures, std::vector<std::shared_ptr<DNSRecord>>* authorityRecs, bool* variable, boost::optional<vState>& 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<DNSRecord>* res, vector<std::shared_ptr<const RRSIGRecordContent>>* signatures, std::shared_ptr<std::vector<DNSRecord>>* authorityRecs, bool* variable, boost::optional<vState>& state, bool* wasAuth, DNSName* authZone, ComboAddress* fromAuthIP);
   static void updateStaleEntry(time_t now, OrderedTagIterator_t& entry);
   static void handleServeStaleBookkeeping(time_t, bool, OrderedTagIterator_t&);
 };
index 82ed158f179d6355c448cb5e10c759c5a48d7b91..0e29d6f5c323136ca0c5d184132ff55bb6c191b0 100644 (file)
@@ -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, {}, {}, true, g_rootdnsname, boost::none, boost::none, state, from);
+    g_recCache->replace(now, name, qtype, aset, {}, nullptr, true, g_rootdnsname, boost::none, boost::none, state, from);
   }
 }
 
index b8a24c5c8506c3f49efadd7b2ae86a8f845eec67..0b7a2577bc68de6469bef4dd799f2eb364e40f64 100644 (file)
@@ -2556,7 +2556,7 @@ bool SyncRes::doCNAMECacheCheck(const DNSName& qname, const QType qtype, vector<
 {
   vector<DNSRecord> cset;
   vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
-  vector<std::shared_ptr<DNSRecord>> authorityRecs;
+  std::shared_ptr<vector<DNSRecord>> authorityRecs = std::make_shared<vector<DNSRecord>>();
   bool wasAuth = false;
   uint32_t capTTL = std::numeric_limits<uint32_t>::max();
   DNSName foundName;
@@ -2652,7 +2652,7 @@ bool SyncRes::doCNAMECacheCheck(const DNSName& qname, const QType qtype, vector<
       dnsRecord.d_ttl = std::min(dnsRecord.d_ttl, capTTL);
       const uint32_t ttl = dnsRecord.d_ttl;
       if (!alreadyPresent) {
-        ret.reserve(ret.size() + 2 + signatures.size() + authorityRecs.size());
+        ret.reserve(ret.size() + 2 + signatures.size() + authorityRecs->size());
         ret.push_back(dnsRecord);
 
         for (const auto& signature : signatures) {
@@ -2666,8 +2666,8 @@ bool SyncRes::doCNAMECacheCheck(const DNSName& qname, const QType qtype, vector<
           ret.push_back(sigdr);
         }
 
-        for (const auto& rec : authorityRecs) {
-          DNSRecord authDR(*rec);
+        for (const auto& rec : *authorityRecs) {
+          DNSRecord authDR(rec);
           authDR.d_ttl = ttl;
           ret.push_back(authDR);
         }
@@ -2999,7 +2999,7 @@ bool SyncRes::doCacheCheck(const DNSName& qname, const DNSName& authname, bool w
   bool found = false;
   bool expired = false;
   vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
-  vector<std::shared_ptr<DNSRecord>> authorityRecs;
+  std::shared_ptr<vector<DNSRecord>> authorityRecs = std::make_shared<vector<DNSRecord>>();
   uint32_t ttl = 0;
   uint32_t capTTL = std::numeric_limits<uint32_t>::max();
   bool wasCachedAuth{};
@@ -3087,7 +3087,7 @@ bool SyncRes::doCacheCheck(const DNSName& qname, const DNSName& authname, bool w
       }
     }
 
-    ret.reserve(ret.size() + signatures.size() + authorityRecs.size());
+    ret.reserve(ret.size() + signatures.size() + authorityRecs->size());
 
     for (const auto& signature : signatures) {
       DNSRecord dnsRecord;
@@ -3100,8 +3100,8 @@ bool SyncRes::doCacheCheck(const DNSName& qname, const DNSName& authname, bool w
       ret.push_back(dnsRecord);
     }
 
-    for (const auto& rec : authorityRecs) {
-      DNSRecord dnsRecord(*rec);
+    for (const auto& rec : *authorityRecs) {
+      DNSRecord dnsRecord(rec);
       dnsRecord.d_ttl = ttl;
       ret.push_back(dnsRecord);
     }
@@ -3606,7 +3606,7 @@ bool SyncRes::validationEnabled()
   return g_dnssecmode != DNSSECMode::Off && g_dnssecmode != DNSSECMode::ProcessNoValidate;
 }
 
-uint32_t SyncRes::computeLowestTTD(const std::vector<DNSRecord>& records, const std::vector<std::shared_ptr<const RRSIGRecordContent>>& signatures, uint32_t signaturesTTL, const std::vector<std::shared_ptr<DNSRecord>>& authorityRecs) const
+uint32_t SyncRes::computeLowestTTD(const std::vector<DNSRecord>& records, const std::vector<std::shared_ptr<const RRSIGRecordContent>>& signatures, uint32_t signaturesTTL, const std::shared_ptr<std::vector<DNSRecord>>& authorityRecs) const
 {
   uint32_t lowestTTD = std::numeric_limits<uint32_t>::max();
   for (const auto& record : records) {
@@ -3628,12 +3628,12 @@ uint32_t SyncRes::computeLowestTTD(const std::vector<DNSRecord>& 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<uint32_t>(entry->d_ttl + d_now.tv_sec));
+    lowestTTD = min(lowestTTD, static_cast<uint32_t>(entry.d_ttl + d_now.tv_sec));
 
-    if (entry->d_type == QType::RRSIG && validationEnabled()) {
-      auto rrsig = getRR<RRSIGRecordContent>(*entry);
+    if (entry.d_type == QType::RRSIG && validationEnabled()) {
+      auto rrsig = getRR<RRSIGRecordContent>(entry);
       if (rrsig) {
         if (isRRSIGNotExpired(d_now.tv_sec, *rrsig)) {
           // we don't decrement d_sigexpire by 'now' because we actually want a TTD, not a TTL */
@@ -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::vector<std::shared_ptr<DNSRecord>> authorityRecs;
+  std::shared_ptr<std::vector<DNSRecord>> authorityRecs = std::make_shared<std::vector<DNSRecord>>();
   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.push_back(std::make_shared<DNSRecord>(rec));
+        authorityRecs->emplace_back(rec);
       }
       else if (rec.d_type == QType::RRSIG) {
         auto rrsig = getRR<RRSIGRecordContent>(rec);
         if (rrsig && nsecTypes.count(rrsig->d_type) != 0) {
-          authorityRecs.push_back(std::make_shared<DNSRecord>(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 : std::vector<std::shared_ptr<DNSRecord>>(), 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 : 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);
 
         // 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
index 6b31b300a2362842c0f82a15a43bbba986c1f0de..fac3b8c95ddf2a435ac9d499dd01c31d2d99a083 100644 (file)
@@ -678,7 +678,7 @@ private:
   boost::optional<Netmask> getEDNSSubnetMask(const DNSName& name, const ComboAddress& rem);
 
   static bool validationEnabled();
-  uint32_t computeLowestTTD(const std::vector<DNSRecord>& records, const std::vector<std::shared_ptr<const RRSIGRecordContent>>& signatures, uint32_t signaturesTTL, const std::vector<std::shared_ptr<DNSRecord>>& authorityRecs) const;
+  uint32_t computeLowestTTD(const std::vector<DNSRecord>& records, const std::vector<std::shared_ptr<const RRSIGRecordContent>>& signatures, uint32_t signaturesTTL, const std::shared_ptr<std::vector<DNSRecord>>& 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<DNSRecord>& records, const std::vector<std::shared_ptr<const RRSIGRecordContent>>& signatures);
   vState validateDNSKeys(const DNSName& zone, const std::vector<DNSRecord>& dnskeys, const std::vector<std::shared_ptr<const RRSIGRecordContent>>& signatures, unsigned int depth, const string& prefix);
index 2404060622360ee9735367a54a06909da8244c5d..2ef01e2f785437a85ec6350dbfb059e03f13ad55 100644 (file)
@@ -21,7 +21,7 @@ static void simple(time_t now)
   MemRecursorCache MRC;
 
   std::vector<DNSRecord> records;
-  std::vector<std::shared_ptr<DNSRecord>> authRecords;
+  std::shared_ptr<std::vector<DNSRecord>> authRecords;
   std::vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
   const DNSName authZone(".");
 
@@ -444,7 +444,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheGhost)
   MemRecursorCache MRC;
 
   std::vector<DNSRecord> records;
-  std::vector<std::shared_ptr<DNSRecord>> authRecords;
+  std::shared_ptr<std::vector<DNSRecord>> authRecords;
   std::vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
   time_t now = time(nullptr);
 
@@ -488,7 +488,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheReplaceAuthByNonAuthMargin)
   MemRecursorCache MRC;
 
   std::vector<DNSRecord> records;
-  std::vector<std::shared_ptr<DNSRecord>> authRecords;
+  std::shared_ptr<std::vector<DNSRecord>> authRecords;
   std::vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
   time_t now = time(nullptr);
 
@@ -535,7 +535,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_ExpungingExpiredEntries)
 
   std::vector<DNSRecord> records;
   std::vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
-  std::vector<std::shared_ptr<DNSRecord>> authRecs;
+  std::shared_ptr<std::vector<DNSRecord>> 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<DNSRecord> records;
   std::vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
-  std::vector<std::shared_ptr<DNSRecord>> authRecs;
+  std::shared_ptr<std::vector<DNSRecord>> 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<DNSRecord> records;
-  std::vector<std::shared_ptr<DNSRecord>> authRecords;
+  std::shared_ptr<std::vector<DNSRecord>> authRecords;
   std::vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
   time_t now = time(nullptr);
   std::vector<DNSRecord> retrieved;
@@ -970,7 +970,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCache_Wipe)
   const DNSName power("powerdns.com.");
   const DNSName authZone(".");
   std::vector<DNSRecord> records;
-  std::vector<std::shared_ptr<DNSRecord>> authRecords;
+  std::shared_ptr<std::vector<DNSRecord>> authRecords;
   std::vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
   time_t now = time(nullptr);
   std::vector<DNSRecord> retrieved;
@@ -1059,7 +1059,7 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheTagged)
   MemRecursorCache MRC;
 
   const DNSName authZone(".");
-  std::vector<std::shared_ptr<DNSRecord>> authRecords;
+  std::shared_ptr<std::vector<DNSRecord>> authRecords;
   std::vector<std::shared_ptr<const RRSIGRecordContent>> 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::vector<std::shared_ptr<DNSRecord>> authRecords;
+  std::shared_ptr<std::vector<DNSRecord>> authRecords = std::make_shared<std::vector<DNSRecord>>();
   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<ARecordContent>(ComboAddress("1::2:3:4")));
-  authRecords.emplace_back(std::make_shared<DNSRecord>(dr));
+  authRecords->emplace_back(dr);
 
   std::vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
   signatures.emplace_back(std::dynamic_pointer_cast<RRSIGRecordContent>(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<DNSRecord> retrieved;
-      std::vector<std::shared_ptr<DNSRecord>> authRecs;
+      std::shared_ptr<std::vector<DNSRecord>> authRecs;
       std::vector<std::shared_ptr<const RRSIGRecordContent>> sigs;
       bool variable = false;
       vState state = vState::Indeterminate;
@@ -1353,9 +1353,9 @@ BOOST_AUTO_TEST_CASE(test_RecursorCacheDumpAndRestore)
         BOOST_CHECK_EQUAL(getRR<ARecordContent>(retrieved.at(0))->getCA().toString(), dr0Content.toString());
         BOOST_CHECK_EQUAL(sigs.size(), 1U);
         BOOST_CHECK_EQUAL(sigs.at(0)->getZoneRepresentation(), signatures.at(0)->getZoneRepresentation());
-        BOOST_CHECK_EQUAL(authRecs.size(), 1U);
+        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);
index 49d593503dbfd91119c24e4c7f5e97c5f2afdf4f..1228e582aed32adc78c47ba494f280c3e426a40a 100644 (file)
@@ -102,18 +102,18 @@ bool primeHints(time_t now)
     arr.setContent(std::make_shared<ARecordContent>(ComboAddress(rootIps4[c - 'a'])));
     vector<DNSRecord> aset;
     aset.push_back(arr);
-    g_recCache->replace(now, DNSName(templ), QType(QType::A), aset, vector<std::shared_ptr<const RRSIGRecordContent>>(), vector<std::shared_ptr<DNSRecord>>(), false, g_rootdnsname);
+    g_recCache->replace(now, DNSName(templ), QType(QType::A), aset, vector<std::shared_ptr<const RRSIGRecordContent>>(), nullptr, false, g_rootdnsname);
     if (!rootIps6[c - 'a'].empty()) {
       aaaarr.setContent(std::make_shared<AAAARecordContent>(ComboAddress(rootIps6[c - 'a'])));
 
       vector<DNSRecord> aaaaset;
       aaaaset.push_back(aaaarr);
-      g_recCache->replace(now, DNSName(templ), QType(QType::AAAA), aaaaset, vector<std::shared_ptr<const RRSIGRecordContent>>(), vector<std::shared_ptr<DNSRecord>>(), false, g_rootdnsname);
+      g_recCache->replace(now, DNSName(templ), QType(QType::AAAA), aaaaset, vector<std::shared_ptr<const RRSIGRecordContent>>(), nullptr, false, g_rootdnsname);
     }
 
     nsset.push_back(nsrr);
   }
-  g_recCache->replace(now, g_rootdnsname, QType(QType::NS), nsset, vector<std::shared_ptr<const RRSIGRecordContent>>(), vector<std::shared_ptr<DNSRecord>>(), false, g_rootdnsname); // and stuff in the cache
+  g_recCache->replace(now, g_rootdnsname, QType(QType::NS), nsset, vector<std::shared_ptr<const RRSIGRecordContent>>(), nullptr, false, g_rootdnsname); // and stuff in the cache
   return true;
 }
 
index dc0fc76d58ae45e48f393f71d368ca427b5b2e77..b3c373589b1e3ff70224d456fd37c14502883600 100644 (file)
@@ -1465,7 +1465,7 @@ BOOST_AUTO_TEST_CASE(test_flawed_nsset)
   std::vector<shared_ptr<const RRSIGRecordContent>> 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, vector<std::shared_ptr<DNSRecord>>(), true, g_rootdnsname, boost::optional<Netmask>());
+  g_recCache->replace(now, target, QType(QType::NS), records, sigs, nullptr, true, g_rootdnsname, boost::optional<Netmask>());
 
   vector<DNSRecord> 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<shared_ptr<const RRSIGRecordContent>> sigs;
 
   addRecordToList(records, target, QType::A, "192.0.2.1", DNSResourceRecord::ANSWER, now + 3600);
-  g_recCache->replace(now, target, QType(QType::A), records, sigs, vector<std::shared_ptr<DNSRecord>>(), true, g_rootdnsname, boost::optional<Netmask>());
+  g_recCache->replace(now, target, QType(QType::A), records, sigs, nullptr, true, g_rootdnsname, boost::optional<Netmask>());
 
   vector<DNSRecord> 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<shared_ptr<const RRSIGRecordContent>> 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, vector<std::shared_ptr<DNSRecord>>(), true, g_rootdnsname, boost::optional<Netmask>());
+  g_recCache->replace(now - 3600, target, QType(QType::A), records, sigs, nullptr, true, g_rootdnsname, boost::optional<Netmask>());
 
   vector<DNSRecord> ret;
   int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);