]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Get rid of `SyncRes::d_nocache`, prevent root refresh loop
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 11 Apr 2017 09:18:59 +0000 (11:18 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Sun, 14 May 2017 12:30:55 +0000 (14:30 +0200)
`SyncRes::d_nocache` did not really prevent looking at the cache
or the local zones, and was only used when we refresh the root NS.

pdns/syncres.cc
pdns/syncres.hh

index 9aa7cb60e3e0062c766e3b44a539d2843b3081b6..e43c91525bd99f8247fc8f57bbd69c781c3a61ca 100644 (file)
@@ -103,7 +103,7 @@ static void accountAuthLatency(int usec, int family)
 
 SyncRes::SyncRes(const struct timeval& now) :  d_outqueries(0), d_tcpoutqueries(0), d_throttledqueries(0), d_timeouts(0), d_unreachables(0),
                                               d_totUsec(0), d_now(now),
-                                              d_cacheonly(false), d_nocache(false), d_doDNSSEC(false), d_doEDNS0(false), d_lm(s_lm)
+                                              d_cacheonly(false), d_doDNSSEC(false), d_doEDNS0(false), d_lm(s_lm)
                                                  
 { 
 }
@@ -479,7 +479,7 @@ int SyncRes::doResolve(const DNSName &qname, const QType &qtype, vector<DNSRecor
   int res=0;
 
   // This is a difficult way of expressing "this is a normal query", i.e. not getRootNS.
-  if(!(d_nocache && qtype.getCode()==QType::NS && qname.isRoot())) {
+  if(!(d_updatingRootNS && qtype.getCode()==QType::NS && qname.isRoot())) {
     if(d_cacheonly) { // very limited OOB support
       LWResult lwr;
       LOG(prefix<<qname<<": Recursion not requested for '"<<qname<<"|"<<qtype.getName()<<"', peeking at auth/forward zones"<<endl);
@@ -705,7 +705,10 @@ void SyncRes::getBestNSFromCache(const DNSName &qname, const QType& qtype, vecto
       // We lost the root NS records
       primeHints();
       LOG(prefix<<qname<<": reprimed the root"<<endl);
-      getRootNS(d_now, d_asyncResolve);
+      /* let's prevent an infinite loop */
+      if (!d_updatingRootNS) {
+        getRootNS(d_now, d_asyncResolve);
+      }
     }
   }while(subdomain.chopOff());
 }
@@ -1761,7 +1764,7 @@ int directResolve(const DNSName& qname, const QType& qtype, int qclass, vector<D
 int SyncRes::getRootNS(struct timeval now, asyncresolve_t asyncCallback) {
   SyncRes sr(now);
   sr.setDoEDNS0(true);
-  sr.setNoCache();
+  sr.setUpdatingRootNS();
   sr.setDoDNSSEC(g_dnssecmode != DNSSECMode::Off);
   sr.setAsyncCallback(asyncCallback);
 
index 8f15c028404032ce38396c0b24ad097e06a959f6..c8a3a9b3c4af629f5b17f21e45bf6d1a1695b2f1 100644 (file)
@@ -535,10 +535,6 @@ public:
   {
     d_cacheonly=state;
   }
-  void setNoCache(bool state=true)
-  {
-    d_nocache=state;
-  }
 
   void setDoEDNS0(bool state=true)
   {
@@ -705,6 +701,12 @@ private:
 
   boost::optional<Netmask> getEDNSSubnetMask(const ComboAddress& local, const DNSName&dn, const ComboAddress& rem);
 
+  void setUpdatingRootNS()
+  {
+    d_updatingRootNS = true;
+  }
+
+
   ostringstream d_trace;
   shared_ptr<RecursorLua4> d_pdl;
   boost::optional<const EDNSSubnetOpts&> d_incomingECS;
@@ -719,14 +721,11 @@ private:
    * This is set when the RD bit is unset in the incoming query
    */
   bool d_cacheonly;
-  /* d_nocache is *only* set in getRootNS() (in pdns_recursor.cc).
-   * It forces us to not look in the cache or local auth.
-   */
-  bool d_nocache;
   bool d_doDNSSEC;
   bool d_doEDNS0{true};
   bool d_incomingECSFound{false};
   bool d_skipCNAMECheck{false};
+  bool d_updatingRootNS{false};
   bool d_wantsRPZ{true};
   bool d_wasOutOfBand{false};
   bool d_wasVariable{false};