]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
DNAME: find CNAME first
authorPieter Lexis <pieter.lexis@powerdns.com>
Wed, 13 Mar 2019 09:43:23 +0000 (10:43 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Wed, 13 Mar 2019 09:43:23 +0000 (10:43 +0100)
pdns/syncres.cc

index e7002c20f7a0476681a78b76694e831b2a8999dc..fc8dc8d9fe5bef3b3a1b7902b9660a7aa2308ba7 100644 (file)
@@ -944,7 +944,14 @@ bool SyncRes::doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector
   DNSName foundName;
   QType foundQT = QType(0); // 0 == QTYPE::ENT
 
-  if (qname != g_rootdnsname) {
+  LOG(prefix<<qname<<": Looking for CNAME cache hit of '"<<qname<<"|CNAME"<<"'"<<endl);
+  /* we don't require auth data for forward-recurse lookups */
+  if (t_RC->get(d_now.tv_sec, qname, QType(QType::CNAME), !wasForwardRecurse && d_requireAuthData, &cset, d_cacheRemote, d_doDNSSEC ? &signatures : nullptr, d_doDNSSEC ? &authorityRecs : nullptr, &d_wasVariable, &state, &wasAuth) > 0) {
+    foundName = qname;
+    foundQT = QType(QType::CNAME);
+  }
+
+  if (foundName.empty() && qname != g_rootdnsname) {
     // look for a DNAME cache hit
     auto labels = qname.getRawLabels();
     DNSName dnameName(g_rootdnsname);
@@ -964,15 +971,6 @@ bool SyncRes::doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector
     } while(!labels.empty());
   }
 
-  if (foundName.empty()) {
-    LOG(prefix<<qname<<": Looking for CNAME cache hit of '"<<qname<<"|CNAME"<<"'"<<endl);
-    /* we don't require auth data for forward-recurse lookups */
-    if (t_RC->get(d_now.tv_sec, qname, QType(QType::CNAME), !wasForwardRecurse && d_requireAuthData, &cset, d_cacheRemote, d_doDNSSEC ? &signatures : nullptr, d_doDNSSEC ? &authorityRecs : nullptr, &d_wasVariable, &state, &wasAuth) > 0) {
-      foundName = qname;
-      foundQT = QType(QType::CNAME);
-    }
-  }
-
   if(!foundName.empty()) {
     for(auto j=cset.cbegin() ; j != cset.cend() ; ++j) {
       if (j->d_class != QClass::IN) {