From: Remi Gacogne Date: Tue, 7 Jul 2020 15:01:27 +0000 (+0200) Subject: auth: Add an 'any-lookups-only' setting X-Git-Tag: auth-4.4.0-alpha2~8^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd8df5bccb21db89b09d3457a114ff2fecd9a709;p=thirdparty%2Fpdns.git auth: Add an 'any-lookups-only' setting It controls whether we only send 'ANY' lookups to our backend, instead of a mix of 'ANY' and exact types. This behaviour is enabled by default since it should save a lot of round-trips for most setups, but can be disabled for multi-backends setups that require it. --- diff --git a/docs/settings.rst b/docs/settings.rst index 9ea5be481d..fdbe04ffd9 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -116,6 +116,22 @@ When notifying a domain, also notify these nameservers. Example: ``also-notify`` always receive a notification. Even if they do not match the list in :ref:`setting-only-notify`. +.. _setting-any-lookups-only: + +``any-lookups-only`` +-------------------- + +- Boolean +- Default: yes + +.. versionadded:: 4.4.0 + +Whether PowerDNS will only send ANY lookups to its backends, instead of sometimes requesting the exact needed type. +This reduces the load on backends by retrieving all the types for a given name at once, adding all of them to the cache. +It improves performance significantly for latency-sensitive backends, like SQL ones, where a round-trip takes serious time. +This behaviour is enabled by default but can be disabled by setting this option to "no" for the few multi-backends setups +that do not support it. + .. _setting-any-to-tcp: ``any-to-tcp`` diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index ab5f3e23e7..5e9f6188d8 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -240,6 +240,8 @@ void declareArguments() ::arg().set("max-generate-steps", "Maximum number of $GENERATE steps when loading a zone from a file")="0"; ::arg().setSwitch("upgrade-unknown-types","Transparently upgrade known TYPExxx records. Recommended to keep off, except for PowerDNS upgrades until data sources are cleaned up")="no"; + ::arg().set("any-lookups-only", "Send only ANY lookup operations to the backend to reduce the number of lookups.")="yes"; + ::arg().set("rng", "Specify the random number generator to use. Valid values are auto,sodium,openssl,getrandom,arc4random,urandom.")="auto"; ::arg().setDefaults(); } diff --git a/pdns/ueberbackend.cc b/pdns/ueberbackend.cc index bba5deeb6f..fa55f3e467 100644 --- a/pdns/ueberbackend.cc +++ b/pdns/ueberbackend.cc @@ -54,6 +54,7 @@ std::mutex UeberBackend::instances_lock; // initially we are blocked bool UeberBackend::d_go=false; +bool UeberBackend::s_doANYLookupsOnly=false; std::mutex UeberBackend::d_mut; std::condition_variable UeberBackend::d_cond; @@ -94,6 +95,10 @@ bool UeberBackend::loadModules(const vector& modules, const string& path void UeberBackend::go(void) { + if (::arg().mustDo("any-lookups-only")) { + s_doANYLookupsOnly = true; + } + { std::unique_lock l(d_mut); d_go = true; @@ -585,9 +590,9 @@ void UeberBackend::lookup(const QType &qtype,const DNSName &qname, int zoneId, D d_domain_id=zoneId; d_handle.i=0; - d_handle.qtype=false ? QType::ANY : qtype; + d_handle.qtype=s_doANYLookupsOnly ? QType::ANY : qtype; d_handle.qname=qname; - d_handle.zoneId=false ? -1 : zoneId; + d_handle.zoneId=s_doANYLookupsOnly? -1 : zoneId; d_handle.pkt_p=pkt_p; if(!backends.size()) { diff --git a/pdns/ueberbackend.hh b/pdns/ueberbackend.hh index 6b013f76eb..d708569add 100644 --- a/pdns/ueberbackend.hh +++ b/pdns/ueberbackend.hh @@ -155,6 +155,7 @@ private: bool d_cached; static bool d_go; bool d_stale; + static bool s_doANYLookupsOnly; int cacheHas(const Question &q, vector &rrs); void addNegCache(const Question &q);