]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Make QName Minimization parameters from RFC 9156 settable
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 25 Sep 2023 11:59:44 +0000 (13:59 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 11 Oct 2023 13:41:49 +0000 (15:41 +0200)
Also fix a counting ommission

pdns/recursordist/rec-main.cc
pdns/recursordist/settings/table.py
pdns/recursordist/syncres.cc
pdns/recursordist/syncres.hh

index 25e6d7d74c7c7ebeae5610fa8ef02553d1fb3d23..fd713a11fd1e16a3ee3f1661dcc0ffcb8025a3f8 100644 (file)
@@ -1687,6 +1687,8 @@ static int initSyncRes(Logr::log_t log)
   SyncRes::s_ecscachelimitttl = ::arg().asNum("ecs-cache-limit-ttl");
 
   SyncRes::s_qnameminimization = ::arg().mustDo("qname-minimization");
+  SyncRes::s_minimize_one_lab = ::arg().asNum("qname-minimize-one-label");
+  SyncRes::s_max_minimize_count = ::arg().asNum("qname-max-minimize-count");
 
   SyncRes::s_hardenNXD = SyncRes::HardenNXD::DNSSEC;
   string value = ::arg()["nothing-below-nxdomain"];
index e833fb6564065d3b3ea2472b20f5e98d9fd78e01..2a54dc1478369c1cab2f4a64cc1ad6f4beb982c6 100644 (file)
@@ -1955,10 +1955,34 @@ Path to the Public Suffix List file, if any. If set, PowerDNS will try to load t
         'help' : 'Use Query Name Minimization',
         'doc' : '''
 Enable Query Name Minimization. This implements a relaxed form of Query Name Mimimization as
-described in :rfc:`7816`.
+described in :rfc:`9156`.
  ''',
     'versionadded': '4.3.0'
     },
+    {
+        'name' : 'qname_max_minimize_count',
+        'section' : 'recursor',
+        'type' : LType.Uint64,
+        'default' : '10',
+        'help' : 'RFC9156 max minimize count',
+        'doc' : '''
+``Max minimize count`` parameter, described in :rfc:`9156`. This is the maximum number of iterations
+of the Quqey Name Minimization Algorithm.
+ ''',
+    'versionadded': '5.0.0'
+    },
+    {
+        'name' : 'qname_minimize_one_label',
+        'section' : 'recursor',
+        'type' : LType.Uint64,
+        'default' : '4',
+        'help' : 'RFC9156 minimize one label parameter',
+        'doc' : '''
+``Minimize one label`` parameter, described in :rfc:`9156`.
+The value for the number of iterations of the Query Name Minimization Algorithm that should only have one label appended.
+ ''',
+    'versionadded': '5.0.0'
+    },
     {
         'name' : 'source_address',
         'section' : 'outgoing',
index 129091b5db3aba4ddeb18307f9ad970f61c05b1c..2c779dddcffec34aab20bea1ec1c734dab2a6b58 100644 (file)
@@ -1596,20 +1596,20 @@ LWResult::Result SyncRes::asyncresolveWrapper(const ComboAddress& address, bool
 }
 
 /* The parameters from rfc9156. */
-/* maximum number of QNAME minimisation iterations */
-static const unsigned int s_max_minimise_count = 10;
-/* number of queries that should only have one label appended */
-static const unsigned int s_minimise_one_lab = 4;
+/* maximum number of QNAME minimization iterations */
+unsigned int SyncRes::s_max_minimize_count; // default is 10
+/* number of iterations that should only have one label appended */
+unsigned int SyncRes::s_minimize_one_lab; // default is 4
 
 static unsigned int qmStepLen(unsigned int labels, unsigned int qnamelen, unsigned int i)
 {
   unsigned int step;
 
-  if (i < s_minimise_one_lab) {
+  if (i < SyncRes::s_minimize_one_lab) {
     step = 1;
   }
-  else if (i < s_max_minimise_count) {
-    step = std::max(1U, (qnamelen - labels) / (10 - i));
+  else if (i < SyncRes::s_max_minimize_count) {
+    step = std::max(1U, (qnamelen - labels) / (SyncRes::s_max_minimize_count - i));
   }
   else {
     step = qnamelen - labels;
@@ -1788,6 +1788,7 @@ int SyncRes::doResolve(const DNSName& qname, const QType qtype, vector<DNSRecord
       LOG(prefix << qname << ": Step4 Resolve " << child << "|A result is " << RCode::to_s(res) << "/" << retq.size() << "/" << stopAtDelegation << endl);
       if (stopAtDelegation == Stopped) {
         LOG(prefix << qname << ": Delegation seen, continue at step 1" << endl);
+        i++;
         break;
       }
 
index 9ae9297b873fc5bc2a726644521cc240183ad836..44f41c5f3a5dc4a203e7147fe3015eea95b917d8 100644 (file)
@@ -550,6 +550,8 @@ public:
   static bool s_dot_to_port_853;
   static unsigned int s_max_busy_dot_probes;
   static unsigned int s_max_CNAMES_followed;
+  static unsigned int s_max_minimize_count;
+  static unsigned int s_minimize_one_lab;
 
   static const int event_trace_to_pb = 1;
   static const int event_trace_to_log = 2;