]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Add an 'any-lookups-only' setting
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 7 Jul 2020 15:01:27 +0000 (17:01 +0200)
committermind04 <mind04@monshouwer.org>
Tue, 27 Oct 2020 08:04:18 +0000 (09:04 +0100)
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.

docs/settings.rst
pdns/common_startup.cc
pdns/ueberbackend.cc
pdns/ueberbackend.hh

index 9ea5be481d5580bda25c06557fcb9bd890bf296d..fdbe04ffd96529b46042288e0dd124d01357552f 100644 (file)
@@ -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``
index ab5f3e23e78303361db146c8f556199bf35bd99e..5e9f6188d8ac31f1cd7c4d476f1ab2193f98fe15 100644 (file)
@@ -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();
 }
index bba5deeb6f2152a9f9a952be80afc57c70c40033..fa55f3e4678a47914621efc61636af9b9d65ba24 100644 (file)
@@ -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<string>& modules, const string& path
 
 void UeberBackend::go(void)
 {
+  if (::arg().mustDo("any-lookups-only")) {
+    s_doANYLookupsOnly = true;
+  }
+
   {
     std::unique_lock<std::mutex> 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()) {
index 6b013f76ebc79f9559273f8146d9c13888a575e9..d708569adda9b5412c73d07e0e6c3fc0190ec8e9 100644 (file)
@@ -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<DNSZoneRecord> &rrs);
   void addNegCache(const Question &q);