return false;
}
-static void addToRRSet(const time_t now, std::vector<DNSRecord>& recordSet, std::vector<std::shared_ptr<const RRSIGRecordContent>> signatures, const DNSName& owner, bool doDNSSEC, std::vector<DNSRecord>& ret, DNSResourceRecord::Place place = DNSResourceRecord::AUTHORITY)
+static void addToRRSet(const time_t now, std::vector<DNSRecord>& recordSet, const MemRecursorCache::SigRecs& signatures, const DNSName& owner, bool doDNSSEC, std::vector<DNSRecord>& ret, DNSResourceRecord::Place place = DNSResourceRecord::AUTHORITY)
{
uint32_t ttl = 0;
}
if (doDNSSEC) {
- for (auto& signature : signatures) {
+ for (const auto& signature : *signatures) {
DNSRecord dr;
dr.d_type = QType::RRSIG;
dr.d_name = owner;
dr.d_ttl = ttl;
- dr.setContent(std::move(signature));
+ dr.setContent(signature);
dr.d_place = place;
dr.d_class = QClass::IN;
ret.push_back(std::move(dr));
vState cachedState;
std::vector<DNSRecord> wcSet;
- std::vector<std::shared_ptr<const RRSIGRecordContent>> wcSignatures;
+ MemRecursorCache::SigRecs wcSignatures;
if (g_recCache->get(now, wildcardName, type, MemRecursorCache::RequireAuth, &wcSet, ComboAddress("127.0.0.1"), boost::none, doDNSSEC ? &wcSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) {
VLOG(log, name << ": Unfortunately we don't have a valid entry for " << wildcardName << ", so we cannot synthesize from that wildcard" << endl);
vState cachedState;
std::vector<DNSRecord> wcSet;
- std::vector<std::shared_ptr<const RRSIGRecordContent>> wcSignatures;
+ MemRecursorCache::SigRecs wcSignatures;
if (g_recCache->get(now, wildcardName, type, MemRecursorCache::RequireAuth, &wcSet, ComboAddress("127.0.0.1"), boost::none, doDNSSEC ? &wcSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) {
VLOG(log, name << ": Unfortunately we don't have a valid entry for " << wildcardName << ", so we cannot synthesize from that wildcard" << endl);
return false;
}
- addToRRSet(now, wcSet, std::move(wcSignatures), name, doDNSSEC, ret, DNSResourceRecord::ANSWER);
+ addToRRSet(now, wcSet, wcSignatures, name, doDNSSEC, ret, DNSResourceRecord::ANSWER);
// coverity[store_truncates_time_t]
addRecordToRRSet(nsec.d_owner, QType::NSEC, nsec.d_ttd - now, nsec.d_record, nsec.d_signatures, doDNSSEC, ret);
return true;
}
-bool AggressiveNSECCache::getNSEC3Denial(time_t now, std::shared_ptr<LockGuarded<AggressiveNSECCache::ZoneEntry>>& zoneEntry, std::vector<DNSRecord>& soaSet, std::vector<std::shared_ptr<const RRSIGRecordContent>>& soaSignatures, const DNSName& name, const QType& type, std::vector<DNSRecord>& ret, int& res, bool doDNSSEC, const OptLog& log, pdns::validation::ValidationContext& validationContext)
+bool AggressiveNSECCache::getNSEC3Denial(time_t now, std::shared_ptr<LockGuarded<AggressiveNSECCache::ZoneEntry>>& zoneEntry, std::vector<DNSRecord>& soaSet, const MemRecursorCache::SigRecs& soaSignatures, const DNSName& name, const QType& type, std::vector<DNSRecord>& ret, int& res, bool doDNSSEC, const OptLog& log, pdns::validation::ValidationContext& validationContext)
{
DNSName zone;
std::string salt;
vState cachedState;
std::vector<DNSRecord> soaSet;
- std::vector<std::shared_ptr<const RRSIGRecordContent>> soaSignatures;
+ MemRecursorCache::SigRecs soaSignatures;
/* we might not actually need the SOA if we find a matching wildcard, but let's not bother for now */
if (g_recCache->get(now, zone, QType::SOA, MemRecursorCache::RequireAuth, &soaSet, who, routingTag, doDNSSEC ? &soaSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) {
VLOG(log, name << ": No valid SOA found for " << zone << ", which is the best match for " << name << endl);
return false;
}
- ret.reserve(ret.size() + soaSet.size() + soaSignatures.size() + /* NSEC */ 1 + entry.d_signatures.size() + (needWildcard ? (/* NSEC */ 1 + wcEntry.d_signatures.size()) : 0));
+ ret.reserve(ret.size() + soaSet.size() + soaSignatures->size() + /* NSEC */ 1 + entry.d_signatures.size() + (needWildcard ? (/* NSEC */ 1 + wcEntry.d_signatures.size()) : 0));
- addToRRSet(now, soaSet, std::move(soaSignatures), zone, doDNSSEC, ret);
+ addToRRSet(now, soaSet, soaSignatures, zone, doDNSSEC, ret);
// coverity[store_truncates_time_t]
addRecordToRRSet(entry.d_owner, QType::NSEC, entry.d_ttd - now, entry.d_record, entry.d_signatures, doDNSSEC, ret);
#include "stat_t.hh"
#include "logger.hh"
#include "validate.hh"
+#include "recursor_cache.hh"
class AggressiveNSECCache
{
std::shared_ptr<LockGuarded<ZoneEntry>> getBestZone(const DNSName& zone);
bool getNSECBefore(time_t now, std::shared_ptr<LockGuarded<ZoneEntry>>& zoneEntry, const DNSName& name, ZoneEntry::CacheEntry& entry);
bool getNSEC3(time_t now, std::shared_ptr<LockGuarded<ZoneEntry>>& zoneEntry, const DNSName& name, ZoneEntry::CacheEntry& entry);
- bool getNSEC3Denial(time_t now, std::shared_ptr<LockGuarded<ZoneEntry>>& zoneEntry, std::vector<DNSRecord>& soaSet, std::vector<std::shared_ptr<const RRSIGRecordContent>>& soaSignatures, const DNSName& name, const QType& type, std::vector<DNSRecord>& ret, int& res, bool doDNSSEC, const OptLog&, pdns::validation::ValidationContext& validationContext);
+ bool getNSEC3Denial(time_t now, std::shared_ptr<LockGuarded<ZoneEntry>>& zoneEntry, std::vector<DNSRecord>& soaSet, const MemRecursorCache::SigRecs& soaSignatures, const DNSName& name, const QType& type, std::vector<DNSRecord>& ret, int& res, bool doDNSSEC, const OptLog&, pdns::validation::ValidationContext& validationContext);
bool synthesizeFromNSEC3Wildcard(time_t now, const DNSName& name, const QType& type, std::vector<DNSRecord>& ret, int& res, bool doDNSSEC, ZoneEntry::CacheEntry& nextCloser, const DNSName& wildcardName, const OptLog&);
bool synthesizeFromNSECWildcard(time_t now, const DNSName& name, const QType& type, std::vector<DNSRecord>& ret, int& res, bool doDNSSEC, ZoneEntry::CacheEntry& nsec, const DNSName& wildcardName, const OptLog&);
bool MemRecursorCache::s_limitQTypeAny = true;
const MemRecursorCache::AuthRecs MemRecursorCache::s_emptyAuthRecs = std::make_shared<MemRecursorCache::AuthRecsVec>();
+const MemRecursorCache::SigRecs MemRecursorCache::s_emptySigRecs = std::make_shared<MemRecursorCache::SigRecsVec>();
void MemRecursorCache::resetStaticsForTests()
{
}
}
-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, AuthRecs* authorityRecs, bool* variable, boost::optional<vState>& state, bool* wasAuth, DNSName* fromAuthZone, ComboAddress* fromAuthIP)
+time_t MemRecursorCache::handleHit(time_t now, MapCombo::LockedContent& content, OrderedTagIterator_t& entry, const DNSName& qname, uint32_t& origTTL, vector<DNSRecord>* res, SigRecs* signatures, AuthRecs* 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) {
}
if (signatures != nullptr) {
- signatures->insert(signatures->end(), entry->d_signatures.begin(), entry->d_signatures.end());
+ if (*signatures && !(*signatures)->empty() && entry->d_signatures && !entry->d_signatures->empty()) {
+ // Return a new vec if we need to append to a non-empty vector
+ SigRecsVec vec(**signatures);
+ vec.insert(vec.end(), entry->d_signatures->cbegin(), entry->d_signatures->cend());
+ *signatures = std::make_shared<SigRecsVec>(vec);
+ }
+ else {
+ assert(*signatures == nullptr || (*signatures)->empty());
+ *signatures = entry->d_signatures ? entry->d_signatures : s_emptySigRecs;
+ }
}
if (authorityRecs != nullptr) {
+ // XXX Might need to be adapted like sigs to handle a non-empty incoming authorityRecs
+ assert(*authorityRecs == nullptr || (*authorityRecs)->empty());
*authorityRecs = entry->d_authorityRecs ? entry->d_authorityRecs : s_emptyAuthRecs;
}
}
// 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, AuthRecs* 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, SigRecs* 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;
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 AuthRecsVec& 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 SigRecsVec& signatures, const AuthRecsVec& 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();
cacheEntry.d_auth = true;
}
- cacheEntry.d_signatures = signatures;
+ if (!signatures.empty()) {
+ cacheEntry.d_signatures = std::make_shared<const SigRecsVec>(signatures);
+ }
+ else {
+ cacheEntry.d_signatures = nullptr;
+ }
if (!authorityRecs.empty()) {
cacheEntry.d_authorityRecs = std::make_shared<const AuthRecsVec>(authorityRecs);
}
fprintf(filePtr.get(), "; error printing '%s'\n", recordSet.d_qname.empty() ? "EMPTY" : recordSet.d_qname.toString().c_str());
}
}
- for (const auto& sig : recordSet.d_signatures) {
- count++;
- try {
- fprintf(filePtr.get(), "%s %" PRIu32 " %" PRId64 " IN RRSIG %s ; %s\n", recordSet.d_qname.toString().c_str(), recordSet.d_orig_ttl, static_cast<int64_t>(recordSet.d_ttd - now), sig->getZoneRepresentation().c_str(), recordSet.d_netmask.empty() ? "" : recordSet.d_netmask.toString().c_str());
- }
- catch (...) {
- fprintf(filePtr.get(), "; error printing '%s'\n", recordSet.d_qname.empty() ? "EMPTY" : recordSet.d_qname.toString().c_str());
+ if (recordSet.d_signatures) {
+ for (const auto& sig : *recordSet.d_signatures) {
+ count++;
+ try {
+ fprintf(filePtr.get(), "%s %" PRIu32 " %" PRId64 " IN RRSIG %s ; %s\n", recordSet.d_qname.toString().c_str(), recordSet.d_orig_ttl, static_cast<int64_t>(recordSet.d_ttd - now), sig->getZoneRepresentation().c_str(), recordSet.d_netmask.empty() ? "" : recordSet.d_netmask.toString().c_str());
+ }
+ catch (...) {
+ fprintf(filePtr.get(), "; error printing '%s'\n", recordSet.d_qname.empty() ? "EMPTY" : recordSet.d_qname.toString().c_str());
+ }
}
}
}
for (const auto& record : recordSet->d_records) {
message.add_bytes(PBCacheEntry::repeated_bytes_record, record->serialize(recordSet->d_qname, true));
}
- for (const auto& record : recordSet->d_signatures) {
+ 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) {
template <typename T>
bool MemRecursorCache::putRecordSet(T& message)
{
- std::vector<DNSRecord> authRecs;
+ AuthRecsVec authRecs;
+ SigRecsVec sigRecs;
CacheEntry cacheEntry{{g_rootdnsname, QType::A, boost::none, Netmask()}, false};
while (message.next()) {
switch (message.tag()) {
break;
}
case PBCacheEntry::repeated_bytes_sig: {
+ if (!cacheEntry.d_signatures) {
+ cacheEntry.d_signatures = std::make_shared<SigRecsVec>();
+ }
auto ptr = DNSRecordContent::deserialize(cacheEntry.d_qname, QType::RRSIG, message.get_bytes());
- cacheEntry.d_signatures.emplace_back(std::dynamic_pointer_cast<RRSIGRecordContent>(ptr));
+ sigRecs.emplace_back(std::dynamic_pointer_cast<RRSIGRecordContent>(ptr));
break;
}
case PBCacheEntry::repeated_message_authRecord:
if (!cacheEntry.d_authorityRecs) {
- cacheEntry.d_authorityRecs = std::make_shared<std::vector<DNSRecord>>();
+ cacheEntry.d_authorityRecs = std::make_shared<AuthRecsVec>();
}
putAuthRecord(message, cacheEntry.d_qname, authRecs);
break;
}
}
if (!authRecs.empty()) {
- cacheEntry.d_authorityRecs = std::make_shared<const std::vector<DNSRecord>>(authRecs);
+ cacheEntry.d_authorityRecs = std::make_shared<const AuthRecsVec>(authRecs);
+ }
+ if (!sigRecs.empty()) {
+ cacheEntry.d_signatures = std::make_shared<const SigRecsVec>(sigRecs);
}
return replace(std::move(cacheEntry));
}
using AuthRecs = std::shared_ptr<const AuthRecsVec>; // const to avoid modifying the vector, which would be bad for shared data
const static AuthRecs s_emptyAuthRecs;
- [[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, AuthRecs* authorityRecs = nullptr, bool* variable = nullptr, vState* state = nullptr, bool* wasAuth = nullptr, DNSName* fromAuthZone = nullptr, ComboAddress* fromAuthIP = nullptr);
+ using SigRecsVec = std::vector<std::shared_ptr<const RRSIGRecordContent>>;
+ using SigRecs = std::shared_ptr<const SigRecsVec>;
+ const static SigRecs s_emptySigRecs;
- void replace(time_t, const DNSName& qname, QType qtype, const vector<DNSRecord>& content, const vector<shared_ptr<const RRSIGRecordContent>>& signatures, const AuthRecsVec& 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));
+ [[nodiscard]] time_t get(time_t, const DNSName& qname, QType qtype, Flags flags, vector<DNSRecord>* res, const ComboAddress& who, const OptTag& routingTag = boost::none, SigRecs* 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<DNSRecord>& content, const SigRecsVec& signatures, const AuthRecsVec& 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);
bool shouldReplace(time_t now, bool auth, vState state, bool refresh);
records_t d_records;
- std::vector<std::shared_ptr<const RRSIGRecordContent>> d_signatures;
+ SigRecs d_signatures;
AuthRecs d_authorityRecs;
DNSName d_qname;
DNSName d_authZone;
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, AuthRecs* 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, SigRecs* signatures, AuthRecs* 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&);
};
bool SyncRes::doCNAMECacheCheck(const DNSName& qname, const QType qtype, vector<DNSRecord>& ret, unsigned int depth, const string& prefix, int& res, Context& context, bool wasAuthZone, bool wasForwardRecurse, bool checkForDups) // NOLINT(readability-function-cognitive-complexity)
{
vector<DNSRecord> cset;
- vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
+ MemRecursorCache::SigRecs signatures = MemRecursorCache::s_emptySigRecs;
MemRecursorCache::AuthRecs authorityRecs = MemRecursorCache::s_emptyAuthRecs;
bool wasAuth = false;
uint32_t capTTL = std::numeric_limits<uint32_t>::max();
if (!wasAuthZone && shouldValidate() && (wasAuth || wasForwardRecurse) && context.state == vState::Indeterminate && d_requireAuthData) {
/* This means we couldn't figure out the state when this entry was cached */
- vState recordState = getValidationStatus(foundName, !signatures.empty(), qtype == QType::DS, depth, prefix);
+ vState recordState = getValidationStatus(foundName, !signatures->empty(), qtype == QType::DS, depth, prefix);
if (recordState == vState::Secure) {
LOG(prefix << qname << ": Got vState::Indeterminate state from the " << foundQT.toString() << " cache, validating.." << endl);
- context.state = SyncRes::validateRecordsWithSigs(depth, prefix, qname, qtype, foundName, foundQT, cset, signatures);
+ context.state = SyncRes::validateRecordsWithSigs(depth, prefix, qname, qtype, foundName, foundQT, cset, *signatures);
if (context.state != vState::Indeterminate) {
LOG(prefix << qname << ": Got vState::Indeterminate state from the " << foundQT.toString() << " cache, new validation result is " << context.state << endl);
if (vStateIsBogus(context.state)) {
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) {
+ for (const auto& signature : *signatures) {
DNSRecord sigdr;
sigdr.d_type = QType::RRSIG;
sigdr.d_name = foundName;
struct CacheEntry
{
vector<DNSRecord> records;
- vector<shared_ptr<const RRSIGRecordContent>> signatures;
+ MemRecursorCache::SigRecsVec signatures;
time_t d_ttl_time{0};
uint32_t signaturesTTL{std::numeric_limits<uint32_t>::max()};
};
}
}
-static void reapSignaturesForValidation(std::map<QType, CacheEntry>& entries, const vector<std::shared_ptr<const RRSIGRecordContent>>& signatures)
+static void reapSignaturesForValidation(std::map<QType, CacheEntry>& entries, const MemRecursorCache::SigRecs& signatures)
{
- for (const auto& sig : signatures) {
+ for (const auto& sig : *signatures) {
entries[sig->d_type].signatures.push_back(sig);
}
}
vector<DNSRecord> cset;
bool found = false;
bool expired = false;
- vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
+ MemRecursorCache::SigRecs signatures = MemRecursorCache::s_emptySigRecs;
MemRecursorCache::AuthRecs authorityRecs = MemRecursorCache::s_emptyAuthRecs;
uint32_t ttl = 0;
uint32_t capTTL = std::numeric_limits<uint32_t>::max();
if (!wasAuthZone && shouldValidate() && (wasCachedAuth || wasForwardRecurse) && cachedState == vState::Indeterminate && d_requireAuthData) {
/* This means we couldn't figure out the state when this entry was cached */
- vState recordState = getValidationStatus(qname, !signatures.empty(), qtype == QType::DS, depth, prefix);
+ vState recordState = getValidationStatus(qname, !signatures->empty(), qtype == QType::DS, depth, prefix);
if (recordState == vState::Secure) {
LOG(prefix << sqname << ": Got vState::Indeterminate state from the cache, validating.." << endl);
- if (sqt == QType::DNSKEY && sqname == getSigner(signatures)) {
- cachedState = validateDNSKeys(sqname, cset, signatures, depth, prefix);
+ if (sqt == QType::DNSKEY && sqname == getSigner(*signatures)) {
+ cachedState = validateDNSKeys(sqname, cset, *signatures, depth, prefix);
}
else {
if (sqt == QType::ANY) {
}
}
else {
- cachedState = SyncRes::validateRecordsWithSigs(depth, prefix, qname, qtype, sqname, sqt, cset, signatures);
+ cachedState = SyncRes::validateRecordsWithSigs(depth, prefix, qname, qtype, sqname, sqt, cset, *signatures);
}
}
}
}
}
- ret.reserve(ret.size() + signatures.size() + authorityRecs->size());
+ ret.reserve(ret.size() + signatures->size() + authorityRecs->size());
- for (const auto& signature : signatures) {
+ for (const auto& signature : *signatures) {
DNSRecord dnsRecord;
dnsRecord.d_type = QType::RRSIG;
dnsRecord.d_name = sqname;
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 MemRecursorCache::AuthRecsVec& authorityRecs) const
+uint32_t SyncRes::computeLowestTTD(const std::vector<DNSRecord>& records, const MemRecursorCache::SigRecsVec& signatures, uint32_t signaturesTTL, const MemRecursorCache::AuthRecsVec& authorityRecs) const
{
uint32_t lowestTTD = std::numeric_limits<uint32_t>::max();
for (const auto& record : records) {
return result;
}
-vState SyncRes::validateDNSKeys(const DNSName& zone, const std::vector<DNSRecord>& dnskeys, const std::vector<std::shared_ptr<const RRSIGRecordContent>>& signatures, unsigned int depth, const string& prefix)
+vState SyncRes::validateDNSKeys(const DNSName& zone, const std::vector<DNSRecord>& dnskeys, const MemRecursorCache::SigRecsVec& signatures, unsigned int depth, const string& prefix)
{
dsset_t dsSet;
if (signatures.empty()) {
return vState::BogusUnableToGetDNSKEYs;
}
-vState SyncRes::validateRecordsWithSigs(unsigned int depth, const string& prefix, const DNSName& qname, const QType qtype, const DNSName& name, const QType type, const std::vector<DNSRecord>& records, const std::vector<std::shared_ptr<const RRSIGRecordContent>>& signatures)
+vState SyncRes::validateRecordsWithSigs(unsigned int depth, const string& prefix, const DNSName& qname, const QType qtype, const DNSName& name, const QType type, const std::vector<DNSRecord>& records, const MemRecursorCache::SigRecsVec& signatures)
{
skeyset_t keys;
if (signatures.empty()) {
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 MemRecursorCache::AuthRecsVec& authorityRecs) const;
+ uint32_t computeLowestTTD(const std::vector<DNSRecord>& records, const MemRecursorCache::SigRecsVec& 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<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);
+ vState validateRecordsWithSigs(unsigned int depth, const string& prefix, const DNSName& qname, QType qtype, const DNSName& name, QType type, const std::vector<DNSRecord>& records, const MemRecursorCache::SigRecsVec& signatures);
+ vState validateDNSKeys(const DNSName& zone, const std::vector<DNSRecord>& dnskeys, const MemRecursorCache::SigRecsVec& signatures, unsigned int depth, const string& prefix);
vState getDNSKeys(const DNSName& signer, skeyset_t& keys, bool& servFailOccurred, unsigned int depth, const string& prefix);
dState getDenialValidationState(const NegCache::NegCacheEntry& negEntry, dState expectedState, bool referralToUnsigned, const string& prefix);
void updateDenialValidationState(const DNSName& qname, vState& neValidationState, const DNSName& neName, vState& state, dState denialState, dState expectedState, bool isDS, unsigned int depth, const string& prefix);
for (size_t counter = 0; counter < expected + 10; counter++) {
std::vector<DNSRecord> retrieved;
MemRecursorCache::AuthRecs authRecs;
- std::vector<std::shared_ptr<const RRSIGRecordContent>> sigs;
+ MemRecursorCache::SigRecs sigs;
bool variable = false;
vState state = vState::Indeterminate;
bool wasAuth = false;
matches++;
BOOST_CHECK_EQUAL(retrieved.size(), rset0.size());
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(sigs->size(), 1U);
+ 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());
/* check that the record in the answer section has not been cached */
const ComboAddress who;
vector<DNSRecord> cached;
- vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
+ MemRecursorCache::SigRecs signatures;
BOOST_REQUIRE_GT(g_recCache->get(now, target, QType(QType::A), MemRecursorCache::None, &cached, who, boost::none, &signatures), 0);
}
/* check that the entry has not been cached for longer than the RRSIG validity */
const ComboAddress who;
vector<DNSRecord> cached;
- vector<std::shared_ptr<const RRSIGRecordContent>> signatures;
+ MemRecursorCache::SigRecs signatures;
BOOST_REQUIRE_EQUAL(g_recCache->get(tnow, target, QType(QType::A), MemRecursorCache::RequireAuth, &cached, who, boost::none, &signatures), 1);
BOOST_REQUIRE_EQUAL(cached.size(), 1U);
- BOOST_REQUIRE_EQUAL(signatures.size(), 1U);
+ BOOST_REQUIRE_EQUAL(signatures->size(), 1U);
BOOST_CHECK_EQUAL((cached[0].d_ttl - tnow), 1);
/* again, to test the cache */