]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
fully abort query resolving if we hit more than 50 outqueries
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Thu, 30 Oct 2014 11:02:40 +0000 (12:02 +0100)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Thu, 30 Oct 2014 11:02:40 +0000 (12:02 +0100)
pdns/pdns_recursor.cc
pdns/syncres.cc
pdns/syncres.hh

index a6e71a007f0db785d937bb880bf78e875b90dad2..7cc7462fd5d2b572c155f51cbdd57a28d8b0b317 100644 (file)
@@ -563,7 +563,14 @@ void startDoResolve(void *p)
 
     // if there is a RecursorLua active, and it 'took' the query in preResolve, we don't launch beginResolve      
     if(!t_pdl->get() || !(*t_pdl)->preresolve(dc->d_remote, local, dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), ret, res, &variableAnswer)) {
-      res = sr.beginResolve(dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), dc->d_mdp.d_qclass, ret);
+      try {
+        res = sr.beginResolve(dc->d_mdp.d_qname, QType(dc->d_mdp.d_qtype), dc->d_mdp.d_qclass, ret);
+      }
+      catch(ImmediateServFailException &e) {
+        L<<Logger::Error<<"Sending SERVFAIL during resolve of '"<<dc->d_mdp.d_qname<<"' because: "<<e.reason<<endl;
+
+        res = RCode::ServFail;
+      }
 
       if(t_pdl->get()) {
         if(res == RCode::NoError) {
index 533adb87f60a1d0b62c8062aca1e9063382159a4..d605573731594bf10bd354a4f6e282ae87ff5f2a 100644 (file)
@@ -923,6 +923,7 @@ int SyncRes::doResolveAt(set<string, CIStringCompare> nameservers, string auth,
           }
           else {
             s_outqueries++; d_outqueries++;
+            if(d_outqueries > 50) throw ImmediateServFailException("more than 50 queries sent while resolving "+qname);
           TryTCP:
             if(doTCP) {
               LOG(prefix<<qname<<": using TCP with "<< remoteIP->toStringWithPort() <<endl);
index c68aca49b0689de220d93b5c1e75ee16d2e9a38a..74a26cf120a1c6b996a9ff869bc8f445f57a366e 100644 (file)
@@ -593,6 +593,13 @@ private:
   static AtomicCounter s_currentConnections; //!< total number of current TCP connections
 };
 
+class ImmediateServFailException
+{
+public:
+  ImmediateServFailException(string r){reason=r;};
+
+  string reason; //! Print this to tell the user what went wrong
+};
 
 struct RemoteKeeper
 {