]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
We only want to do QName Minimization for the names in a forwarded
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 7 Sep 2020 10:17:30 +0000 (12:17 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 7 Sep 2020 10:17:30 +0000 (12:17 +0200)
domain.

E.g. if foo.bar.com is forwarded and the qname is x.foo.bar.com,
start the QM process with ancestor foo.bar.com, so the query is
directed to the forwarder.  But if the qname is baz.bar.com, we do
regular QM, starting with the regular ancestor.

Should fix #9438 without breaking having forward for .

pdns/syncres.cc

index df689a6f69ba7a7774ad8cd1b1766ad9064655a6..6638b0336d13699f55ff9b0dedc2eae5db78555c 100644 (file)
@@ -714,22 +714,30 @@ int SyncRes::doResolve(const DNSName &qname, const QType &qtype, vector<DNSRecor
     if (qtype == QType::DS) {
       nsdomain.chopOff();
     }
-    // the two retries allow getBestNSFromCache&co to reprime the root
-    // hints, in case they ever go missing
-    for (int tries = 0; tries < 2 && bestns.empty(); ++tries) {
-      bool flawedNSSet = false;
-      set<GetBestNSAnswer> beenthereIgnored;
-      getBestNSFromCache(nsdomain, qtype, bestns, &flawedNSSet, depth, beenthereIgnored);
-    }
 
-    if (bestns.size() == 0) {
-      // Something terrible is wrong
-      QLOG("Step1 No ancestor found return ServFail");
-      return RCode::ServFail;
+    DNSName fwdomain(qname);
+    bool forwarded = getBestAuthZone(&fwdomain) != t_sstorage.domainmap->end();
+    if (forwarded) {
+      QLOG("Step1 qname is in a forwarded domain");
+    } else {
+      // the two retries allow getBestNSFromCache&co to reprime the root
+      // hints, in case they ever go missing
+      for (int tries = 0; tries < 2 && bestns.empty(); ++tries) {
+        bool flawedNSSet = false;
+        set<GetBestNSAnswer> beenthereIgnored;
+        getBestNSFromCache(nsdomain, qtype, bestns, &flawedNSSet, depth, beenthereIgnored);
+      }
+
+      if (bestns.size() == 0) {
+        // Something terrible is wrong
+        QLOG("Step1 No ancestor found return ServFail");
+        return RCode::ServFail;
+      }
+      QLOG("Step1 Ancestor from cache is " << bestns[0].d_name);
     }
 
-    const DNSName& ancestor(bestns[0].d_name);
-    QLOG("Step1 Ancestor from cache is " << ancestor.toString());
+    const DNSName& ancestor(forwarded ? fwdomain : bestns[0].d_name);
+
     child = ancestor;
 
     unsigned int targetlen = std::min(child.countLabels() + (i > 3 ? 3 : 1), qnamelen);