From: Otto Date: Wed, 3 Mar 2021 10:21:10 +0000 (+0100) Subject: Formatting fixes in recursordist X-Git-Tag: dnsdist-1.6.0-alpha2~5^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F10138%2Fhead;p=thirdparty%2Fpdns.git Formatting fixes in recursordist --- diff --git a/pdns/recursordist/aggressive_nsec.cc b/pdns/recursordist/aggressive_nsec.cc index b1b2215ccf..f5a123bece 100644 --- a/pdns/recursordist/aggressive_nsec.cc +++ b/pdns/recursordist/aggressive_nsec.cc @@ -192,8 +192,7 @@ void AggressiveNSECCache::prune(time_t now) d_entriesCount -= erased; - if (!emptyEntries.empty()) - { + if (!emptyEntries.empty()) { WriteLock rl(d_lock); for (const auto& entry : emptyEntries) { d_zones.remove(entry); @@ -349,8 +348,7 @@ bool AggressiveNSECCache::getNSECBefore(time_t now, std::shared_ptrd_owner != name && !it->d_owner.canonCompare(name)))) - { + while (!end && !wrapped && (it == idx.end() || (it->d_owner != name && !it->d_owner.canonCompare(name)))) { if (it == idx.begin()) { end = true; break; @@ -404,7 +402,7 @@ bool AggressiveNSECCache::getNSEC3(time_t now, std::shared_ptr& recordSet, std::vector> signatures, const DNSName& owner, bool doDNSSEC, std::vector& ret, DNSResourceRecord::Place place=DNSResourceRecord::AUTHORITY) +static void addToRRSet(const time_t now, std::vector& recordSet, std::vector> signatures, const DNSName& owner, bool doDNSSEC, std::vector& ret, DNSResourceRecord::Place place = DNSResourceRecord::AUTHORITY) { uint32_t ttl = 0; @@ -459,7 +457,10 @@ static void addRecordToRRSet(time_t now, const DNSName& owner, const QType& type } } -#define LOG(x) if (g_dnssecLOG) { g_log <& ret, int& res, bool doDNSSEC, ZoneEntry::CacheEntry& nextCloser, const DNSName& wildcardName) { @@ -469,7 +470,7 @@ bool AggressiveNSECCache::synthesizeFromNSEC3Wildcard(time_t now, const DNSName& std::vector> wcSignatures; if (g_recCache->get(now, wildcardName, type, true, &wcSet, ComboAddress("127.0.0.1"), false, boost::none, doDNSSEC ? &wcSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) { - LOG("Unfortunately we don't have a valid entry for "<> wcSignatures; if (g_recCache->get(now, wildcardName, type, true, &wcSet, ComboAddress("127.0.0.1"), false, boost::none, doDNSSEC ? &wcSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) { - LOG("Unfortunately we don't have a valid entry for "<(exactNSEC3.d_record); if (!nsec3 || nsec3->d_iterations != iterations || nsec3->d_salt != salt) { - LOG(" but the content is not valid, or has a different salt or iterations count"<d_zone, doDNSSEC, ret); @@ -545,7 +546,7 @@ bool AggressiveNSECCache::getNSEC3Denial(time_t now, std::shared_ptr(closestNSEC3.d_record); if (!nsec3 || nsec3->d_iterations != iterations || nsec3->d_salt != salt) { - LOG(" but the content is not valid, or has a different salt or iterations count"<(nextCloserEntry.d_record); if (!nextCloserNsec3 || nextCloserNsec3->d_iterations != iterations || nextCloserNsec3->d_salt != salt) { - LOG("The NSEC3 covering the next closer is not valid, or has a different salt or iterations count, bailing out"<(wcEntry.d_record); if (!nsec3 || nsec3->d_iterations != iterations || nsec3->d_salt != salt) { - LOG(" but the content is not valid, or has a different salt or iterations count"<(wcEntry.d_record); if (!nsec3 || nsec3->d_iterations != iterations || nsec3->d_salt != salt) { - LOG("The content of the NSEC3 covering the wildcard is not valid, or has a different salt or iterations count"<> 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, zoneEntry->d_zone, QType::SOA, true, &soaSet, who, false, routingTag, doDNSSEC ? &soaSignatures : nullptr, nullptr, nullptr, &cachedState) <= 0 || cachedState != vState::Secure) { - LOG("No valid SOA found for "<d_zone<<", which is the best match for "<d_zone << ", which is the best match for " << name << endl); return false; } @@ -676,9 +677,9 @@ bool AggressiveNSECCache::getDenial(time_t now, const DNSName& name, const QType bool covered = false; bool needWildcard = false; - LOG("Looking for a NSEC before "<(wcEntry.d_record); @@ -717,21 +718,21 @@ bool AggressiveNSECCache::getDenial(time_t now, const DNSName& name, const QType if (denial == dState::NODENIAL || denial == dState::INCONCLUSIVE) { if (wcEntry.d_owner == wc) { - LOG(" proving that the wildcard does exist"<& fp, const struct timeval& now) +size_t AggressiveNSECCache::dumpToFile(std::unique_ptr& fp, const struct timeval& now) { size_t ret = 0; diff --git a/pdns/recursordist/aggressive_nsec.hh b/pdns/recursordist/aggressive_nsec.hh index 14d9c3893c..1773f73aab 100644 --- a/pdns/recursordist/aggressive_nsec.hh +++ b/pdns/recursordist/aggressive_nsec.hh @@ -38,7 +38,8 @@ class AggressiveNSECCache { public: - AggressiveNSECCache(uint64_t entries): d_maxEntries(entries) + AggressiveNSECCache(uint64_t entries) : + d_maxEntries(entries) { } @@ -73,23 +74,29 @@ public: } void prune(time_t now); - size_t dumpToFile(std::unique_ptr& fp, const struct timeval& now); + size_t dumpToFile(std::unique_ptr& fp, const struct timeval& now); private: - struct ZoneEntry { ZoneEntry() { } - ZoneEntry(const DNSName& zone, const std::string& salt, uint16_t iterations, bool nsec3): d_zone(zone), d_salt(salt), d_iterations(iterations), d_nsec3(nsec3) + ZoneEntry(const DNSName& zone, const std::string& salt, uint16_t iterations, bool nsec3) : + d_zone(zone), d_salt(salt), d_iterations(iterations), d_nsec3(nsec3) { } - struct HashedTag {}; - struct SequencedTag {}; - struct OrderedTag {}; + struct HashedTag + { + }; + struct SequencedTag + { + }; + struct OrderedTag + { + }; struct CacheEntry { @@ -103,17 +110,14 @@ private: typedef multi_index_container< CacheEntry, - indexed_by < + indexed_by< ordered_unique, - member, - CanonDNSNameCompare - >, - sequenced >, + member, + CanonDNSNameCompare>, + sequenced>, hashed_non_unique, - member - > - > - > cache_t; + member>>> + cache_t; cache_t d_entries; DNSName d_zone; diff --git a/pdns/recursordist/test-aggressive_nsec_cc.cc b/pdns/recursordist/test-aggressive_nsec_cc.cc index 82882a99fd..0bc47811ea 100644 --- a/pdns/recursordist/test-aggressive_nsec_cc.cc +++ b/pdns/recursordist/test-aggressive_nsec_cc.cc @@ -978,7 +978,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_rollover) nrc.d_salt = oldSalt; nrc.d_nexthash = hashed; incrementHash(nrc.d_nexthash); - for (const auto& type : { QType::A }) { + for (const auto& type : {QType::A}) { nrc.set(type); } @@ -1007,7 +1007,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_rollover) nrc.d_salt = newSalt; nrc.d_nexthash = hashed; incrementHash(nrc.d_nexthash); - for (const auto& type : { QType::A }) { + for (const auto& type : {QType::A}) { nrc.set(type); } @@ -1037,7 +1037,7 @@ BOOST_AUTO_TEST_CASE(test_aggressive_nsec3_rollover) nrc.d_salt = newSalt; nrc.d_nexthash = hashed; incrementHash(nrc.d_nexthash); - for (const auto& type : { QType::A }) { + for (const auto& type : {QType::A}) { nrc.set(type); } diff --git a/pdns/recursordist/test-histogram_hh.cc b/pdns/recursordist/test-histogram_hh.cc index 66e03e2409..b0570d6d05 100644 --- a/pdns/recursordist/test-histogram_hh.cc +++ b/pdns/recursordist/test-histogram_hh.cc @@ -32,7 +32,8 @@ BOOST_AUTO_TEST_SUITE(histogram_hh) -BOOST_AUTO_TEST_CASE(test_simple) { +BOOST_AUTO_TEST_CASE(test_simple) +{ auto h = pdns::AtomicHistogram("myname-", {1, 3, 5, 10, 100}); h(0); @@ -46,18 +47,18 @@ BOOST_AUTO_TEST_CASE(test_simple) { auto data = h.getRawData(); BOOST_CHECK_EQUAL(data.size(), 6U); - uint64_t expected[] = { 3, 1, 1, 0, 1, 2}; + uint64_t expected[] = {3, 1, 1, 0, 1, 2}; size_t i = 0; for (auto e : expected) { - BOOST_CHECK_EQUAL(data[i++].d_count, e); + BOOST_CHECK_EQUAL(data[i++].d_count, e); } auto c = h.getCumulativeCounts(); BOOST_CHECK_EQUAL(data.size(), 6U); - uint64_t cexpected[] = { 3, 4, 5, 5, 6, 8}; + uint64_t cexpected[] = {3, 4, 5, 5, 6, 8}; i = 0; for (auto e : cexpected) { - BOOST_CHECK_EQUAL(c[i++], e); + BOOST_CHECK_EQUAL(c[i++], e); } } diff --git a/pdns/recursordist/test-syncres_cc8.cc b/pdns/recursordist/test-syncres_cc8.cc index ff1d0a4fbb..996214b18f 100644 --- a/pdns/recursordist/test-syncres_cc8.cc +++ b/pdns/recursordist/test-syncres_cc8.cc @@ -484,7 +484,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_wildcard_with_cname) /* add a NSEC proving that a wildcard exists, without a CNAME type */ recordContents.clear(); signatureContents.clear(); - addNSECRecordToLW(DNSName("*.example.org."), DNSName("+.example.org"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC }, 600, records); + addNSECRecordToLW(DNSName("*.example.org."), DNSName("+.example.org"), {QType::A, QType::TXT, QType::RRSIG, QType::NSEC}, 600, records); recordContents.insert(records.at(0).d_content); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1))); @@ -504,7 +504,7 @@ BOOST_AUTO_TEST_CASE(test_nsec_wildcard_with_cname) /* now we replace the wildcard by one with a CNAME */ recordContents.clear(); signatureContents.clear(); - addNSECRecordToLW(DNSName("*.example.org."), DNSName("+.example.org"), {QType::CNAME, QType::RRSIG, QType::NSEC }, 600, records); + addNSECRecordToLW(DNSName("*.example.org."), DNSName("+.example.org"), {QType::CNAME, QType::RRSIG, QType::NSEC}, 600, records); recordContents.insert(records.at(0).d_content); addRRSIG(keys, records, DNSName("example.org."), 300); signatureContents.push_back(getRR(records.at(1)));