]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
remove recursion in auth
authorKees Monshouwer <mind04@monshouwer.org>
Mon, 9 Jan 2017 12:26:30 +0000 (13:26 +0100)
committermind04 <mind04@monshouwer.org>
Mon, 9 Jan 2017 12:26:30 +0000 (13:26 +0100)
pdns/common_startup.cc
pdns/packethandler.cc
pdns/packethandler.hh
pdns/tcpreceiver.cc

index 4e4839e8aff337ac952cdb65506abb34c4ae2646..997fbec20bbb6b1e8b03efd38d36cc8aa78f7e65 100644 (file)
@@ -362,7 +362,6 @@ void *qthread(void *number)
 
   int diff;
   bool logDNSQueries = ::arg().mustDo("log-dns-queries");
-  bool doRecursion = ::arg().mustDo("recursor");
   UDPNameserver *NS = N;
 
   // If we have SO_REUSEPORT then create a new port for all receiver threads
@@ -408,9 +407,7 @@ void *qthread(void *number)
     }
 
     if((P->d.opcode != Opcode::Notify && P->d.opcode != Opcode::Update) && P->couldBeCached()) {
-      bool haveSomething = false;
-      if (!P->d.rd || !DP->recurseFor(P))
-        haveSomething=PC.get(P, &cached); // does the PacketCache recognize this question?
+      bool haveSomething=PC.get(P, &cached); // does the PacketCache recognize this question?
       if (haveSomething) {
         if(logDNSQueries)
           L<<"packetcache HIT"<<endl;
index 254a564a5e8d91c17892d9736dacc62b4a277db4..3a40fbc0cc54a1eba1d31dd00fdd0f9bff88f744 100644 (file)
@@ -59,7 +59,6 @@ PacketHandler::PacketHandler():B(s_programname), d_dk(&B)
 {
   ++s_count;
   d_doDNAME=::arg().mustDo("dname-processing");
-  d_doRecursion= ::arg().mustDo("recursor");
   d_logDNSDetails= ::arg().mustDo("log-dns-details");
   d_doIPv6AdditionalProcessing = ::arg().mustDo("do-ipv6-additional-processing");
   string fname= ::arg()["lua-prequery-script"];
@@ -942,11 +941,8 @@ DNSPacket *PacketHandler::question(DNSPacket *p)
     return ret;
   }
 
-  bool shouldRecurse=false;
-  ret=questionOrRecurse(p, &shouldRecurse);
-  if(shouldRecurse) {
-    DP->sendPacket(p);
-  }
+  ret=doQuestion(p);
+
   if(LPE) {
     policyres = LPE->police(p, ret);
     if(policyres == PolicyDecision::DROP) {
@@ -1106,9 +1102,8 @@ bool PacketHandler::tryWildcard(DNSPacket *p, DNSPacket*r, SOAData& sd, DNSName
 }
 
 //! Called by the Distributor to ask a question. Returns 0 in case of an error
-DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
+DNSPacket *PacketHandler::doQuestion(DNSPacket *p)
 {
-  *shouldRecurse=false;
   DNSZoneRecord rr;
   SOAData sd;
 
@@ -1226,8 +1221,6 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
 
     // L<<Logger::Warning<<"Query for '"<<p->qdomain<<"' "<<p->qtype.getName()<<" from "<<p->getRemote()<< " (tcp="<<p->d_tcp<<")"<<endl;
     
-    r->d.ra = (p->d.rd && d_doRecursion && DP->recurseFor(p));  // make sure we set ra if rd was set, and we'll do it
-
     if(p->qtype.getCode()==QType::IXFR) {
       r->setRcode(RCode::NotImp);
       return r;
@@ -1272,13 +1265,6 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
     
     if(!B.getAuth(p, &sd, target)) {
       DLOG(L<<Logger::Error<<"We have no authority over zone '"<<target<<"'"<<endl);
-      if(r->d.ra) {
-        DLOG(L<<Logger::Error<<"Recursion is available for this remote, doing that"<<endl);
-        *shouldRecurse=true;
-        delete r;
-        return 0;
-      }
-      
       if(!retargetcount) {
         r->setA(false); // drop AA if we never had a SOA in the first place
         r->setRcode(RCode::Refused); // send REFUSED - but only on empty 'no idea'
index e422e413494c7636fb8d2f9f110bc456f90ec1ed..357c909b8d918e64d92a99249439847742b78fce 100644 (file)
@@ -56,7 +56,7 @@ class NSEC3PARAMRecordContent;
 class PacketHandler
 {
 public:
-  DNSPacket *questionOrRecurse(DNSPacket *, bool* shouldRecurse); //!< hand us a DNS packet with a question, we'll tell you answer, or that you should recurse
+  DNSPacket *doQuestion(DNSPacket *); //!< hand us a DNS packet with a question, we give you an answer
   DNSPacket *question(DNSPacket *); //!< hand us a DNS packet with a question, we give you an answer
   PacketHandler(); 
   ~PacketHandler(); // defined in packethandler.cc, and does --count
index 7eb16f433600157df6856ea639123da70ce21b0c..3273b22869c957ad1713c74acc0d74100053451e 100644 (file)
@@ -217,49 +217,6 @@ catch(NetworkError& ae) {
   throw NetworkError("Error reading DNS data from TCP client "+remote.toString()+": "+ae.what());
 }
 
-static void proxyQuestion(shared_ptr<DNSPacket> packet, unsigned int idleTimeout)
-{
-  int sock=socket(AF_INET, SOCK_STREAM, 0);
-  
-  setCloseOnExec(sock);
-  if(sock < 0)
-    throw NetworkError("Error making TCP connection socket to recursor: "+stringerror());
-
-  setNonBlocking(sock);
-  ServiceTuple st;
-  st.port=53;
-  parseService(::arg()["recursor"],st);
-
-  try {
-    ComboAddress recursor(st.host, st.port);
-    connectWithTimeout(sock, (struct sockaddr*)&recursor, recursor.getSocklen());
-    const string &buffer=packet->getString();
-    
-    uint16_t len=htons(buffer.length()), slen;
-    
-    writenWithTimeout(sock, &len, 2, idleTimeout);
-    writenWithTimeout(sock, buffer.c_str(), buffer.length(), idleTimeout);
-    
-    readnWithTimeout(sock, &len, 2, idleTimeout);
-    len=ntohs(len);
-
-    char answer[len];
-    readnWithTimeout(sock, answer, len, idleTimeout);
-
-    slen=htons(len);
-    writenWithTimeout(packet->getSocket(), &slen, 2, idleTimeout);
-    
-    writenWithTimeout(packet->getSocket(), answer, len, idleTimeout);
-  }
-  catch(NetworkError& ae) {
-    close(sock);
-    throw NetworkError("While proxying a question to recursor "+st.host+": " +ae.what());
-  }
-  close(sock);
-  return;
-}
-
-
 static void incTCPAnswerCount(const ComboAddress& remote)
 {
   S.inc("tcp-answers");
@@ -399,7 +356,7 @@ void *TCPNameserver::doConnection(void *data)
       }
 
 
-      if(!packet->d.rd && packet->couldBeCached() && PC.get(packet.get(), cached.get())) { // short circuit - does the PacketCache recognize this question?
+      if(packet->couldBeCached() && PC.get(packet.get(), cached.get())) { // short circuit - does the PacketCache recognize this question?
         if(logDNSQueries)
           L<<"packetcache HIT"<<endl;
         cached->setRemote(&packet->d_remote);
@@ -420,16 +377,10 @@ void *TCPNameserver::doConnection(void *data)
           L<<Logger::Error<<"TCP server is without backend connections, launching"<<endl;
           s_P=new PacketHandler;
         }
-        bool shouldRecurse;
 
-        reply=shared_ptr<DNSPacket>(s_P->questionOrRecurse(packet.get(), &shouldRecurse)); // we really need to ask the backend :-)
+        reply=shared_ptr<DNSPacket>(s_P->doQuestion(packet.get())); // we really need to ask the backend :-)
 
         if(LPE) LPE->police(&(*packet), &(*reply), true);
-
-        if(shouldRecurse) {
-          proxyQuestion(packet, d_idleTimeout);
-          continue;
-        }
       }
 
       if(!reply)  // unable to write an answer?