From 1f0fb39af85b4def1ff386f76ec3e8d1b36f0481 Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Tue, 18 May 2021 21:18:56 +0200 Subject: [PATCH] Rename domaincache to zonecache, also ttl to refreshinterval --- docs/settings.rst | 24 +++---- modules/bindbackend/bindbackend2.cc | 4 +- modules/remotebackend/Makefile.am | 2 +- .../remotebackend/test-remotebackend-http.cc | 4 +- .../remotebackend/test-remotebackend-json.cc | 4 +- .../remotebackend/test-remotebackend-pipe.cc | 4 +- .../remotebackend/test-remotebackend-post.cc | 4 +- .../remotebackend/test-remotebackend-unix.cc | 4 +- .../test-remotebackend-zeromq.cc | 4 +- pdns/Makefile.am | 8 +-- ...{auth-domaincache.cc => auth-zonecache.cc} | 68 +++++++++---------- ...{auth-domaincache.hh => auth-zonecache.hh} | 28 ++++---- pdns/common_startup.cc | 20 +++--- pdns/common_startup.hh | 2 +- pdns/pdnsutil.cc | 4 +- pdns/receiver.cc | 4 +- ...ncache_cc.cc => test-auth-zonecache_cc.cc} | 36 +++++----- pdns/test-ueberbackend_cc.cc | 46 ++++++------- pdns/testrunner.cc | 4 +- pdns/ueberbackend.cc | 36 +++++----- pdns/ueberbackend.hh | 2 +- regression-tests/backends/gsql-common | 2 +- regression-tests/backends/gsqlite3-master | 2 +- regression-tests/backends/ldap-master | 2 +- regression-tests/tests/bind-add-zone/command | 2 +- 25 files changed, 159 insertions(+), 161 deletions(-) rename pdns/{auth-domaincache.cc => auth-zonecache.cc} (62%) rename pdns/{auth-domaincache.hh => auth-zonecache.hh} (78%) rename pdns/{test-auth-domaincache_cc.cc => test-auth-zonecache_cc.cc} (74%) diff --git a/docs/settings.rst b/docs/settings.rst index 9a3774aeb9..4e6ff0fbaf 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -171,18 +171,6 @@ Maximum time in seconds for inbound AXFR to start or be idle after starting. Also AXFR a zone from a master with a lower serial. -.. _setting-domain-cache-ttl: - -``domain-cache-ttl`` --------------------- - -- Integer -- Default: 0 - -Seconds to cache a list of all known domains. A value of 0 will disable the cache. - -If your backends do not respond to unknown domains, it is suggested to enable :ref:`setting-consistent-backends` and set this option to `60`. - .. _setting-cache-ttl: ``cache-ttl`` @@ -1894,3 +1882,15 @@ checking for updates to zones. Specifies the maximum number of received megabytes allowed on an incoming AXFR/IXFR update, to prevent resource exhaustion. A value of 0 means no restriction. + +.. _setting-zone-cache-refresh-interval: + +``zone-cache-refresh-interval`` +------------------------------- + +- Integer +- Default: 0 + +Seconds to cache a list of all known zones. A value of 0 will disable the cache. + +If your backends do not respond to unknown or dynamically generated zones, it is suggested to enable :ref:`setting-consistent-backends` and set this option to `60`. diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 750125276f..80c693532d 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -53,7 +53,7 @@ #include "pdns/misc.hh" #include "pdns/dynlistener.hh" #include "pdns/lock.hh" -#include "pdns/auth-domaincache.hh" +#include "pdns/auth-zonecache.hh" /* All instances of this backend share one s_state, which is indexed by zone name and zone id. @@ -704,7 +704,7 @@ string Bind2Backend::DLAddDomainHandler(const vector& parts, Utility::pi safePutBBDomainInfo(bbd); - g_domainCache.add(domainname, bbd.d_id); // make new domain visible + g_zoneCache.add(domainname, bbd.d_id); // make new zone visible g_log << Logger::Warning << "Zone " << domainname << " loaded" << endl; return "Loaded zone " + domainname.toLogString() + " from " + filename; diff --git a/modules/remotebackend/Makefile.am b/modules/remotebackend/Makefile.am index f0218cfc44..c544005905 100644 --- a/modules/remotebackend/Makefile.am +++ b/modules/remotebackend/Makefile.am @@ -95,9 +95,9 @@ BUILT_SOURCES = ../../pdns/dnslabeltext.cc libtestremotebackend_la_SOURCES = \ ../../pdns/arguments.hh ../../pdns/arguments.cc \ - ../../pdns/auth-domaincache.cc ../../pdns/auth-domaincache.hh \ ../../pdns/auth-packetcache.cc ../../pdns/auth-packetcache.hh \ ../../pdns/auth-querycache.cc ../../pdns/auth-querycache.hh \ + ../../pdns/auth-zonecache.cc ../../pdns/auth-zonecache.hh \ ../../pdns/base32.cc \ ../../pdns/base64.cc \ ../../pdns/dns.hh ../../pdns/dns.cc \ diff --git a/modules/remotebackend/test-remotebackend-http.cc b/modules/remotebackend/test-remotebackend-http.cc index babf135990..bcfb51e7c5 100644 --- a/modules/remotebackend/test-remotebackend-http.cc +++ b/modules/remotebackend/test-remotebackend-http.cc @@ -32,14 +32,14 @@ #include "pdns/arguments.hh" #include "pdns/json.hh" #include "pdns/statbag.hh" -#include "pdns/auth-domaincache.hh" #include "pdns/auth-packetcache.hh" #include "pdns/auth-querycache.hh" +#include "pdns/auth-zonecache.hh" StatBag S; -AuthDomainCache g_domainCache; AuthPacketCache PC; AuthQueryCache QC; +AuthZoneCache g_zoneCache; ArgvMap& arg() { static ArgvMap arg; diff --git a/modules/remotebackend/test-remotebackend-json.cc b/modules/remotebackend/test-remotebackend-json.cc index 87a8234ef1..266b73aca6 100644 --- a/modules/remotebackend/test-remotebackend-json.cc +++ b/modules/remotebackend/test-remotebackend-json.cc @@ -31,14 +31,14 @@ #include "pdns/arguments.hh" #include "pdns/json.hh" #include "pdns/statbag.hh" -#include "pdns/auth-domaincache.hh" #include "pdns/auth-packetcache.hh" #include "pdns/auth-querycache.hh" +#include "pdns/auth-zonecache.hh" StatBag S; -AuthDomainCache g_domainCache; AuthPacketCache PC; AuthQueryCache QC; +AuthZoneCache g_zoneCache; ArgvMap& arg() { static ArgvMap arg; diff --git a/modules/remotebackend/test-remotebackend-pipe.cc b/modules/remotebackend/test-remotebackend-pipe.cc index a32dfd0019..e293a48ad8 100644 --- a/modules/remotebackend/test-remotebackend-pipe.cc +++ b/modules/remotebackend/test-remotebackend-pipe.cc @@ -40,14 +40,14 @@ #include "pdns/dnsrecords.hh" #include "pdns/json.hh" #include "pdns/statbag.hh" -#include "pdns/auth-domaincache.hh" #include "pdns/auth-packetcache.hh" #include "pdns/auth-querycache.hh" +#include "pdns/auth-zonecache.hh" StatBag S; -AuthDomainCache g_domainCache; AuthPacketCache PC; AuthQueryCache QC; +AuthZoneCache g_zoneCache; ArgvMap& arg() { static ArgvMap arg; diff --git a/modules/remotebackend/test-remotebackend-post.cc b/modules/remotebackend/test-remotebackend-post.cc index 0f80df4851..10e5e09932 100644 --- a/modules/remotebackend/test-remotebackend-post.cc +++ b/modules/remotebackend/test-remotebackend-post.cc @@ -31,14 +31,14 @@ #include "pdns/arguments.hh" #include "pdns/json.hh" #include "pdns/statbag.hh" -#include "pdns/auth-domaincache.hh" #include "pdns/auth-packetcache.hh" #include "pdns/auth-querycache.hh" +#include "pdns/auth-zonecache.hh" StatBag S; -AuthDomainCache g_domainCache; AuthPacketCache PC; AuthQueryCache QC; +AuthZoneCache g_zoneCache; ArgvMap& arg() { static ArgvMap arg; diff --git a/modules/remotebackend/test-remotebackend-unix.cc b/modules/remotebackend/test-remotebackend-unix.cc index 7a0142aa75..5ccdf1aef6 100644 --- a/modules/remotebackend/test-remotebackend-unix.cc +++ b/modules/remotebackend/test-remotebackend-unix.cc @@ -40,14 +40,14 @@ #include "pdns/dnsrecords.hh" #include "pdns/json.hh" #include "pdns/statbag.hh" -#include "pdns/auth-domaincache.hh" #include "pdns/auth-packetcache.hh" #include "pdns/auth-querycache.hh" +#include "pdns/auth-zonecache.hh" StatBag S; -AuthDomainCache g_domainCache; AuthPacketCache PC; AuthQueryCache QC; +AuthZoneCache g_zoneCache; ArgvMap& arg() { static ArgvMap arg; diff --git a/modules/remotebackend/test-remotebackend-zeromq.cc b/modules/remotebackend/test-remotebackend-zeromq.cc index 01fed7f67c..dc346b7035 100644 --- a/modules/remotebackend/test-remotebackend-zeromq.cc +++ b/modules/remotebackend/test-remotebackend-zeromq.cc @@ -39,14 +39,14 @@ #include "pdns/dnsrecords.hh" #include "pdns/json.hh" #include "pdns/statbag.hh" -#include "pdns/auth-domaincache.hh" #include "pdns/auth-packetcache.hh" #include "pdns/auth-querycache.hh" +#include "pdns/auth-zonecache.hh" StatBag S; -AuthDomainCache g_domainCache; AuthPacketCache PC; AuthQueryCache QC; +AuthZoneCache g_zoneCache; ArgvMap& arg() { static ArgvMap arg; diff --git a/pdns/Makefile.am b/pdns/Makefile.am index d8f6dd3ac4..7fa3b20418 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -185,9 +185,9 @@ pdns_server_SOURCES = \ ascii.hh \ auth-caches.cc auth-caches.hh \ auth-carbon.cc \ - auth-domaincache.cc auth-domaincache.hh \ auth-packetcache.cc auth-packetcache.hh \ auth-querycache.cc auth-querycache.hh \ + auth-zonecache.cc auth-zonecache.hh \ axfr-retriever.cc axfr-retriever.hh \ backends/gsql/gsqlbackend.cc backends/gsql/gsqlbackend.hh \ backends/gsql/ssql.hh \ @@ -322,9 +322,9 @@ endif pdnsutil_SOURCES = \ arguments.cc \ auth-caches.cc auth-caches.hh \ - auth-domaincache.cc auth-domaincache.hh \ auth-packetcache.cc auth-packetcache.hh \ auth-querycache.cc auth-querycache.hh \ + auth-zonecache.cc auth-zonecache.hh \ backends/gsql/gsqlbackend.cc backends/gsql/gsqlbackend.hh \ backends/gsql/ssql.hh \ base32.cc \ @@ -1306,9 +1306,9 @@ pdns.conf-dist: pdns_server testrunner_SOURCES = \ arguments.cc \ auth-caches.cc auth-caches.hh \ - auth-domaincache.cc auth-domaincache.hh \ auth-packetcache.cc auth-packetcache.hh \ auth-querycache.cc auth-querycache.hh \ + auth-zonecache.cc auth-zonecache.hh \ base32.cc \ base64.cc \ bindlexer.l \ @@ -1353,7 +1353,7 @@ testrunner_SOURCES = \ stubresolver.hh stubresolver.cc \ svc-records.cc svc-records.hh \ test-arguments_cc.cc \ - test-auth-domaincache_cc.cc \ + test-auth-zonecache_cc.cc \ test-base32_cc.cc \ test-base64_cc.cc \ test-bindparser_cc.cc \ diff --git a/pdns/auth-domaincache.cc b/pdns/auth-zonecache.cc similarity index 62% rename from pdns/auth-domaincache.cc rename to pdns/auth-zonecache.cc index d3c55bbf5c..c4c6d6d22c 100644 --- a/pdns/auth-domaincache.cc +++ b/pdns/auth-zonecache.cc @@ -23,28 +23,26 @@ #include "config.h" #endif -#include "auth-domaincache.hh" +#include "auth-zonecache.hh" #include "logger.hh" #include "statbag.hh" #include "arguments.hh" #include "cachecleaner.hh" extern StatBag S; -AuthDomainCache::AuthDomainCache(size_t mapsCount) : +AuthZoneCache::AuthZoneCache(size_t mapsCount) : d_maps(mapsCount) { - S.declare("domain-cache-hit", "Number of domain cache hits"); - S.declare("domain-cache-miss", "Number of domain cache misses"); - S.declare("domain-cache-size", "Number of entries in the domain cache", StatType::gauge); + S.declare("zone-cache-hit", "Number of zone cache hits"); + S.declare("zone-cache-miss", "Number of zone cache misses"); + S.declare("zone-cache-size", "Number of entries in the zone cache", StatType::gauge); - d_statnumhit = S.getPointer("domain-cache-hit"); - d_statnummiss = S.getPointer("domain-cache-miss"); - d_statnumentries = S.getPointer("domain-cache-size"); - - d_ttl = 0; + d_statnumhit = S.getPointer("zone-cache-hit"); + d_statnummiss = S.getPointer("zone-cache-miss"); + d_statnumentries = S.getPointer("zone-cache-size"); } -AuthDomainCache::~AuthDomainCache() +AuthZoneCache::~AuthZoneCache() { try { vector locks; @@ -57,13 +55,13 @@ AuthDomainCache::~AuthDomainCache() } } -bool AuthDomainCache::getEntry(const DNSName& domain, int& zoneId) +bool AuthZoneCache::getEntry(const DNSName& zone, int& zoneId) { - auto& mc = getMap(domain); + auto& mc = getMap(zone); bool found = false; { ReadLock rl(mc.d_mut); - auto iter = mc.d_map.find(domain); + auto iter = mc.d_map.find(zone); if (iter != mc.d_map.end()) { found = true; zoneId = iter->second.zoneId; @@ -79,43 +77,43 @@ bool AuthDomainCache::getEntry(const DNSName& domain, int& zoneId) return found; } -bool AuthDomainCache::isEnabled() const +bool AuthZoneCache::isEnabled() const { - return d_ttl > 0; + return d_refreshinterval > 0; } -void AuthDomainCache::clear() +void AuthZoneCache::clear() { purgeLockedCollectionsVector(d_maps); } -void AuthDomainCache::replace(const vector>& domain_indices) +void AuthZoneCache::replace(const vector>& zone_indices) { - if (!d_ttl) + if (!d_refreshinterval) return; - size_t count = domain_indices.size(); + size_t count = zone_indices.size(); vector newMaps(d_maps.size()); // build new maps - for (const tuple& tup : domain_indices) { - const DNSName& domain = tup.get<0>(); + for (const tuple& tup : zone_indices) { + const DNSName& zone = tup.get<0>(); CacheValue val; val.zoneId = tup.get<1>(); - auto& mc = newMaps[getMapIndex(domain)]; - mc.d_map.emplace(domain, val); + auto& mc = newMaps[getMapIndex(zone)]; + mc.d_map.emplace(zone, val); } { WriteLock globalLock(d_mut); if (d_replacePending) { - // add/replace all domains created while data collection for replace() was already in progress. + // add/replace all zones created while data collection for replace() was already in progress. for (const tuple& tup : d_pendingAdds) { - const DNSName& domain = tup.get<0>(); + const DNSName& zone = tup.get<0>(); CacheValue val; val.zoneId = tup.get<1>(); - auto& mc = newMaps[getMapIndex(domain)]; - mc.d_map[domain] = val; + auto& mc = newMaps[getMapIndex(zone)]; + mc.d_map[zone] = val; } } @@ -132,32 +130,32 @@ void AuthDomainCache::replace(const vector>& domain_indices) d_statnumentries->store(count); } -void AuthDomainCache::add(const DNSName& domain, const int zoneId) +void AuthZoneCache::add(const DNSName& zone, const int zoneId) { - if (!d_ttl) + if (!d_refreshinterval) return; { WriteLock globalLock(d_mut); if (d_replacePending) { - d_pendingAdds.push_back({domain, zoneId}); + d_pendingAdds.push_back({zone, zoneId}); } } CacheValue val; val.zoneId = zoneId; - int mapIndex = getMapIndex(domain); + int mapIndex = getMapIndex(zone); { auto& mc = d_maps[mapIndex]; WriteLock mcLock(mc.d_mut); - mc.d_map.emplace(domain, val); + mc.d_map.emplace(zone, val); } } -void AuthDomainCache::setReplacePending() +void AuthZoneCache::setReplacePending() { - if (!d_ttl) + if (!d_refreshinterval) return; { diff --git a/pdns/auth-domaincache.hh b/pdns/auth-zonecache.hh similarity index 78% rename from pdns/auth-domaincache.hh rename to pdns/auth-zonecache.hh index ba6432c15a..e5ace8b265 100644 --- a/pdns/auth-domaincache.hh +++ b/pdns/auth-zonecache.hh @@ -27,28 +27,28 @@ #include "lock.hh" #include "misc.hh" -class AuthDomainCache : public boost::noncopyable +class AuthZoneCache : public boost::noncopyable { public: - AuthDomainCache(size_t mapsCount = 1024); - ~AuthDomainCache(); + AuthZoneCache(size_t mapsCount = 1024); + ~AuthZoneCache(); - void replace(const vector>& domains); - void add(const DNSName& domain, const int zoneId); + void replace(const vector>& zone); + void add(const DNSName& zone, const int zoneId); void setReplacePending(); //!< call this when data collection for the subsequent replace() call starts. - bool getEntry(const DNSName& domain, int& zoneId); + bool getEntry(const DNSName& zone, int& zoneId); size_t size() { return *d_statnumentries; } //!< number of entries in the cache - uint32_t getTTL() const + uint32_t getRefreshInterval() const { - return d_ttl; + return d_refreshinterval; } - void setTTL(uint32_t ttl) + void setRefreshInterval(uint32_t interval) { - d_ttl = ttl; + d_refreshinterval = interval; } bool isEnabled() const; @@ -75,9 +75,9 @@ private: }; vector d_maps; - size_t getMapIndex(const DNSName& domain) + size_t getMapIndex(const DNSName& zone) { - return domain.hash() % d_maps.size(); + return zone.hash() % d_maps.size(); } MapCombo& getMap(const DNSName& qname) { @@ -88,11 +88,11 @@ private: AtomicCounter* d_statnummiss; AtomicCounter* d_statnumentries; - time_t d_ttl{0}; + time_t d_refreshinterval{0}; ReadWriteLock d_mut; std::vector> d_pendingAdds; bool d_replacePending{false}; }; -extern AuthDomainCache g_domainCache; +extern AuthZoneCache g_zoneCache; diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index dfbb2dd473..114a1b2e01 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -55,7 +55,7 @@ ArgvMap theArg; StatBag S; //!< Statistics are gathered across PDNS via the StatBag class S AuthPacketCache PC; //!< This is the main PacketCache, shared across all threads AuthQueryCache QC; -AuthDomainCache g_domainCache; +AuthZoneCache g_zoneCache; std::unique_ptr DP{nullptr}; std::unique_ptr dl{nullptr}; CommunicatorClass Communicator; @@ -181,7 +181,7 @@ void declareArguments() ::arg().set("cache-ttl","Seconds to store packets in the PacketCache")="20"; ::arg().set("negquery-cache-ttl","Seconds to store negative query results in the QueryCache")="60"; ::arg().set("query-cache-ttl","Seconds to store query results in the QueryCache")="20"; - ::arg().set("domain-cache-ttl", "Seconds to cache list of known domains") = "0"; + ::arg().set("zone-cache-refresh-interval", "Seconds to cache list of known zones") = "0"; ::arg().set("server-id", "Returned when queried for 'id.server' TXT or NSID, defaults to hostname - disabled or custom")=""; ::arg().set("default-soa-content","Default SOA content")="a.misconfigured.dns.server.invalid hostmaster.@ 0 10800 3600 604800 3600"; ::arg().set("default-soa-edit","Default SOA-EDIT value")=""; @@ -680,23 +680,23 @@ void mainthread() const uint32_t secpollInterval = 1800; uint32_t secpollSince = 0; - uint32_t domainCacheUpdateSince = 0; + uint32_t zoneCacheUpdateSince = 0; for(;;) { - const uint32_t sleeptime = g_domainCache.getTTL() == 0 ? secpollInterval : std::min(secpollInterval, g_domainCache.getTTL()); + const uint32_t sleeptime = g_zoneCache.getRefreshInterval() == 0 ? secpollInterval : std::min(secpollInterval, g_zoneCache.getRefreshInterval()); sleep(sleeptime); // if any signals arrive, we might run more often than expected. - domainCacheUpdateSince += sleeptime; - if (domainCacheUpdateSince >= g_domainCache.getTTL()) { + zoneCacheUpdateSince += sleeptime; + if (zoneCacheUpdateSince >= g_zoneCache.getRefreshInterval()) { try { UeberBackend B; - B.updateDomainCache(); - domainCacheUpdateSince = 0; + B.updateZoneCache(); + zoneCacheUpdateSince = 0; } catch(PDNSException &e) { - g_log< -#include "auth-domaincache.hh" +#include "auth-zonecache.hh" #include "misc.hh" -BOOST_AUTO_TEST_SUITE(test_auth_domaincache_cc) +BOOST_AUTO_TEST_SUITE(test_auth_zonecache_cc) BOOST_AUTO_TEST_CASE(test_replace) { - AuthDomainCache cache; - cache.setTTL(3600); + AuthZoneCache cache; + cache.setRefreshInterval(3600); - vector> domain_indices{ + vector> zone_indices{ {DNSName("example.org."), 1}, }; - cache.replace(domain_indices); + cache.replace(zone_indices); int zoneId = 0; bool found = cache.getEntry(DNSName("example.org."), zoneId); if (!found || zoneId != 1) { - BOOST_FAIL("domain added in replace() not found"); + BOOST_FAIL("zone added in replace() not found"); } } BOOST_AUTO_TEST_CASE(test_add_while_pending_replace) { - AuthDomainCache cache; - cache.setTTL(3600); + AuthZoneCache cache; + cache.setRefreshInterval(3600); - vector> domain_indices{ + vector> zone_indices{ {DNSName("powerdns.org."), 1}}; cache.setReplacePending(); cache.add(DNSName("example.org."), 2); - cache.replace(domain_indices); + cache.replace(zone_indices); int zoneId = 0; bool found = cache.getEntry(DNSName("example.org."), zoneId); if (!found || zoneId != 2) { - BOOST_FAIL("domain added while replace was pending not found"); + BOOST_FAIL("zone added while replace was pending not found"); } } -// Add domain using .add(), but also in the .replace() data +// Add zone using .add(), but also in the .replace() data BOOST_AUTO_TEST_CASE(test_add_while_pending_replace_duplicate) { - AuthDomainCache cache; - cache.setTTL(3600); + AuthZoneCache cache; + cache.setRefreshInterval(3600); - vector> domain_indices{ + vector> zone_indices{ {DNSName("powerdns.org."), 1}, {DNSName("example.org."), 2}, }; cache.setReplacePending(); cache.add(DNSName("example.org."), 3); - cache.replace(domain_indices); + cache.replace(zone_indices); int zoneId = 0; bool found = cache.getEntry(DNSName("example.org."), zoneId); if (!found || zoneId == 0) { - BOOST_FAIL("domain added while replace was pending not found"); + BOOST_FAIL("zone added while replace was pending not found"); } if (zoneId != 3) { BOOST_FAIL(string("zoneId got overwritten using replace() data (zoneId=") + std::to_string(zoneId) + ")"); diff --git a/pdns/test-ueberbackend_cc.cc b/pdns/test-ueberbackend_cc.cc index da63913da1..23e302bc8d 100644 --- a/pdns/test-ueberbackend_cc.cc +++ b/pdns/test-ueberbackend_cc.cc @@ -16,8 +16,8 @@ #include #include "arguments.hh" -#include "auth-domaincache.hh" #include "auth-querycache.hh" +#include "auth-zonecache.hh" #include "ueberbackend.hh" class SimpleBackend : public DNSBackend @@ -338,8 +338,8 @@ struct UeberBackendSetupArgFixture { ::arg().set("negquery-cache-ttl")="0"; ::arg().set("consistent-backends")="no"; QC.cleanup(); - ::arg().set("domain-cache-ttl")="0"; - g_domainCache.clear(); + ::arg().set("zone-cache-refresh-interval")="0"; + g_zoneCache.clear(); BackendMakers().clear(); SimpleBackend::s_zones.clear(); SimpleBackend::s_metadata.clear(); @@ -355,9 +355,9 @@ static void testWithoutThenWithAuthCache(std::function f ::arg().set("query-cache-ttl")="0"; ::arg().set("negquery-cache-ttl")="0"; QC.cleanup(); - /* keep domain cache disabled */ - ::arg().set("domain-cache-ttl")="0"; - g_domainCache.clear(); + /* keep zone cache disabled */ + ::arg().set("zone-cache-refresh-interval")="0"; + g_zoneCache.clear(); UeberBackend ub; func(ub); @@ -368,9 +368,9 @@ static void testWithoutThenWithAuthCache(std::function f ::arg().set("query-cache-ttl")="20"; ::arg().set("negquery-cache-ttl")="60"; QC.cleanup(); - /* keep domain cache disabled */ - ::arg().set("domain-cache-ttl")="0"; - g_domainCache.clear(); + /* keep zone cache disabled */ + ::arg().set("zone-cache-refresh-interval")="0"; + g_zoneCache.clear(); UeberBackend ub; /* a first time to fill the cache */ @@ -380,14 +380,14 @@ static void testWithoutThenWithAuthCache(std::function f } } -static void testWithoutThenWithDomainCache(std::function func) +static void testWithoutThenWithZoneCache(std::function func) { extern AuthQueryCache QC; { - /* disable domain cache */ - ::arg().set("domain-cache-ttl")="0"; - g_domainCache.clear(); + /* disable zone cache */ + ::arg().set("zone-cache-refresh-interval")="0"; + g_zoneCache.clear(); /* keep auth caches disabled */ ::arg().set("query-cache-ttl")="0"; ::arg().set("negquery-cache-ttl")="0"; @@ -398,16 +398,16 @@ static void testWithoutThenWithDomainCache(std::function } { - /* enable domain cache */ - ::arg().set("domain-cache-ttl")="0"; - g_domainCache.clear(); + /* enable zone cache */ + ::arg().set("zone-cache-refresh-interval")="0"; + g_zoneCache.clear(); /* keep auth caches disabled */ ::arg().set("query-cache-ttl")="0"; ::arg().set("negquery-cache-ttl")="0"; QC.cleanup(); UeberBackend ub; - ub.updateDomainCache(); + ub.updateZoneCache(); /* a first time to fill the cache */ func(ub); /* a second time to make sure every call has been tried with the cache filled */ @@ -535,7 +535,7 @@ BOOST_AUTO_TEST_CASE(test_simple) { }; testWithoutThenWithAuthCache(testFunction); - testWithoutThenWithDomainCache(testFunction); + testWithoutThenWithZoneCache(testFunction); } catch(const PDNSException& e) { cerr< #include "arguments.hh" -#include "auth-domaincache.hh" #include "auth-packetcache.hh" #include "auth-querycache.hh" +#include "auth-zonecache.hh" #include "statbag.hh" StatBag S; -AuthDomainCache g_domainCache; AuthPacketCache PC; AuthQueryCache QC; +AuthZoneCache g_zoneCache; ArgvMap &arg() { diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index fce557f5cf..e4c28d0446 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -26,7 +26,7 @@ #include #include "auth-querycache.hh" -#include "auth-domaincache.hh" +#include "auth-zonecache.hh" #include "utility.hh" @@ -130,7 +130,7 @@ bool UeberBackend::createDomain(const DNSName &domain, const DomainInfo::DomainK } } if (success) { - g_domainCache.add(domain, zoneId); // make new domain visible + g_zoneCache.add(domain, zoneId); // make new zone visible } return success; } @@ -280,23 +280,23 @@ void UeberBackend::reload() } } -void UeberBackend::updateDomainCache() { - if (!g_domainCache.isEnabled()) { +void UeberBackend::updateZoneCache() { + if (!g_zoneCache.isEnabled()) { return; } - vector> domain_indices; - g_domainCache.setReplacePending(); + vector> zone_indices; + g_zoneCache.setReplacePending(); for (vector::iterator i = backends.begin(); i != backends.end(); ++i ) { - vector domains; - (*i)->getAllDomains(&domains, true); - for(auto& di: domains) { - domain_indices.push_back({std::move(di.zone), (int)di.id}); // this cast should not be necessary + vector zones; + (*i)->getAllDomains(&zones, true); + for(auto& di: zones) { + zone_indices.push_back({std::move(di.zone), (int)di.id}); // this cast should not be necessary } } - g_domainCache.replace(domain_indices); + g_zoneCache.replace(zone_indices); } void UeberBackend::rediscover(string *status) @@ -309,7 +309,7 @@ void UeberBackend::rediscover(string *status) *status+=tmpstr + (i!=backends.begin() ? "\n" : ""); } - updateDomainCache(); + updateZoneCache(); } @@ -355,16 +355,16 @@ bool UeberBackend::getAuth(const DNSName &target, const QType& qtype, SOAData* s vector > bestmatch (backends.size(), make_pair(target.wirelength()+1, SOAData())); do { int zoneId{-1}; - if(cachedOk && g_domainCache.isEnabled()) { - if (g_domainCache.getEntry(shorter, zoneId)) { - // Zone exists in domain cache, directly look up SOA. + if(cachedOk && g_zoneCache.isEnabled()) { + if (g_zoneCache.getEntry(shorter, zoneId)) { + // Zone exists in zone cache, directly look up SOA. // XXX: this code path and the cache lookup below should be merged; but that needs the code path below to also use ANY. // Or it should just also use lookup(). DNSZoneRecord zr; lookup(QType(QType::SOA), shorter, zoneId, nullptr); if (!get(zr)) { - // domain has somehow vanished - DLOG(g_log << Logger::Info << "Backend returned no SOA for domain '" << shorter.toLogString() << "', which it reported as existing " << endl); + // zone has somehow vanished + DLOG(g_log << Logger::Info << "Backend returned no SOA for zone '" << shorter.toLogString() << "', which it reported as existing " << endl); continue; } if (zr.dr.d_name != shorter) { @@ -377,7 +377,7 @@ bool UeberBackend::getAuth(const DNSName &target, const QType& qtype, SOAData* s ; goto found; } - // domain does not exist, try again with shorter name + // zone does not exist, try again with shorter name continue; } diff --git a/pdns/ueberbackend.hh b/pdns/ueberbackend.hh index 92963176f1..b3b688aac6 100644 --- a/pdns/ueberbackend.hh +++ b/pdns/ueberbackend.hh @@ -132,7 +132,7 @@ public: bool searchRecords(const string &pattern, int maxResults, vector& result); bool searchComments(const string &pattern, int maxResults, vector& result); - void updateDomainCache(); + void updateZoneCache(); bool inTransaction(); private: diff --git a/regression-tests/backends/gsql-common b/regression-tests/backends/gsql-common index 63e1a23ce8..90d70ee9d1 100644 --- a/regression-tests/backends/gsql-common +++ b/regression-tests/backends/gsql-common @@ -50,7 +50,7 @@ gsql_master() --config-name=$backend --socket-dir=./ --no-shuffle \ --dnsupdate=yes --resolver=$RESOLVERIP --outgoing-axfr-expand-alias=yes \ --expand-alias=yes \ - --cache-ttl=$cachettl --domain-cache-ttl=$cachettl --dname-processing \ + --cache-ttl=$cachettl --zone-cache-refresh-interval=$cachettl --dname-processing \ --disable-axfr-rectify=yes $lua_prequery & if [ $context = ${backend}-nsec3 ] diff --git a/regression-tests/backends/gsqlite3-master b/regression-tests/backends/gsqlite3-master index c082126456..2a3a67b506 100644 --- a/regression-tests/backends/gsqlite3-master +++ b/regression-tests/backends/gsqlite3-master @@ -13,7 +13,7 @@ launch=gsqlite3 gsqlite3-database=pdns.sqlite3 consistent-backends cache-ttl=30 -domain-cache-ttl=30 +zone-cache-refresh-interval=30 direct-dnskey __EOF__ diff --git a/regression-tests/backends/ldap-master b/regression-tests/backends/ldap-master index c607fdf706..791e38a764 100644 --- a/regression-tests/backends/ldap-master +++ b/regression-tests/backends/ldap-master @@ -31,7 +31,7 @@ __EOF__ --query-logging --dnsupdate=yes \ --expand-alias=yes --outgoing-axfr-expand-alias=yes \ --resolver=$RESOLVERIP \ - --domain-cache-ttl=0 \ + --zone-cache-refresh-interval=0 \ --cache-ttl=$cachettl --dname-processing $lua_prequery & skipreasons="nodnssec noent nodyndns nometa noaxfr" diff --git a/regression-tests/tests/bind-add-zone/command b/regression-tests/tests/bind-add-zone/command index 1462e274de..2e28426c25 100755 --- a/regression-tests/tests/bind-add-zone/command +++ b/regression-tests/tests/bind-add-zone/command @@ -7,7 +7,7 @@ fi cleandig ns1.addzone.com A cleandig ns1.test.com A $PDNSCONTROL --config-name=bind --socket-dir=. --no-config bind-add-zone addzone.com ${PWD}/zones/addzone.com >/dev/null 2>&1 -# output of purge changes if domain-cache-ttl is set +# output of purge changes if zone-cache-refresh-interval is set $PDNSCONTROL --config-name=bind --socket-dir=. --no-config purge addzone.com >/dev/null sleep 1 $PDNSCONTROL --config-name=bind --socket-dir=. --no-config bind-add-zone addzone.com ${PWD}/zones/addzone.com -- 2.47.2