]> granicus.if.org Git - pdns/commitdiff
quiet query logging with log-dns-details, move query logging to place where cache...
authorBert Hubert <bert.hubert@netherlabs.nl>
Tue, 11 Jan 2011 19:52:55 +0000 (19:52 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Tue, 11 Jan 2011 19:52:55 +0000 (19:52 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1868 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/common_startup.cc
pdns/packethandler.cc
pdns/tcpreceiver.cc

index 1913edc394cb36ad6f26139984efc18b827d6272..74431b14d79d5863a51a04d1b13679c4b4804d65 100644 (file)
@@ -228,7 +228,8 @@ void *qthread(void *number)
   unsigned int &numanswered6=*S.getPointer("udp6-answers");
   numreceived=-1;
   int diff;
-
+  bool logDNSDetails= ::arg().mustDo("log-dns-details");
+  
   for(;;) {
     if(number==0) { // only run on main thread
       if(!((numreceived++)%250)) { // maintenance tasks
@@ -250,8 +251,13 @@ void *qthread(void *number)
 
     S.ringAccount("queries", P->qdomain+"/"+P->qtype.getName());
     S.ringAccount("remotes",P->getRemote());
+    if(logDNSDetails) 
+      L << Logger::Notice<<"Remote "<< P->remote.toString() <<" wants '" << P->qdomain<<"|"<<P->qtype.getName() << 
+        "', do = " <<P->d_dnssecOk <<", bufsize = "<< P->getMaxReplyLen()<<": ";
 
-    if((P->d.opcode != Opcode::Notify) && !P->d_dnssecOk && P->couldBeCached() && PC.get(P, &cached)) { // short circuit - does the PacketCache recognize this question?
+    if((P->d.opcode != Opcode::Notify) && P->couldBeCached() && PC.get(P, &cached)) { // short circuit - does the PacketCache recognize this question?
+      if(logDNSDetails)
+        L<<"packetcache HIT"<<endl;
       cached.setRemote(&P->remote);  // inlined
       cached.setSocket(P->getSocket());                               // inlined
       cached.setMaxReplyLen(P->getMaxReplyLen());
@@ -271,6 +277,8 @@ void *qthread(void *number)
 
       continue;
     }
+    if(logDNSDetails)
+        L<<"packetcache MISS"<<endl;
     if(g_mustlockdistributor) {
       Lock l(&d_distributorlock);
       g_distributor->question(P, &sendout); // otherwise, give to the distributor
index 1ad758a0753a28eafc0e908036edb133faed5ad6..fca25b11544831b2e71ffa25a4d1113c777eebfd 100644 (file)
@@ -1139,8 +1139,6 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
 
   DNSPacket *r=0;
   try {    
-    L << Logger::Notice<<"Remote "<< p->remote.toString() <<" wants " << p->qtype.getName() << " for '"<<p->qdomain << 
-      "', do = " <<p->d_dnssecOk <<", bufsize = "<< p->getMaxReplyLen()<< endl;
 
     if(p->d.qr) { // QR bit from dns packet (thanks RA from N)
       L<<Logger::Error<<"Received an answer (non-query) packet from "<<p->getRemote()<<", dropping"<<endl;
@@ -1151,7 +1149,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
     // XXX FIXME do this in DNSPacket::parse ?
 
     if(!validDNSName(p->qdomain)) {
-      if(::arg().mustDo("log-dns-details"))
+      if(d_logDNSDetails)
         L<<Logger::Error<<"Received a malformed qdomain from "<<p->getRemote()<<", '"<<p->qdomain<<"': sending servfail"<<endl;
       S.inc("corrupt-packets");
       r=p->replyPacket(); 
index 950041cbfb183e7720ebfccebab5b14deacd49d3..0d2f92f015d70e45eae0aa263b2dfb0069354e82 100644 (file)
@@ -244,7 +244,7 @@ void *TCPNameserver::doConnection(void *data)
     char mesg[512];
     
     DLOG(L<<"TCP Connection accepted on fd "<<fd<<endl);
-    
+    bool logDNSDetails= ::arg().mustDo("log-dns-details");
     for(;;) {
       ComboAddress remote;
       socklen_t remotelen=sizeof(remote);
@@ -282,8 +282,14 @@ void *TCPNameserver::doConnection(void *data)
 
       shared_ptr<DNSPacket> reply; 
       shared_ptr<DNSPacket> cached= shared_ptr<DNSPacket>(new DNSPacket);
+      if(logDNSDetails) 
+        L << Logger::Notice<<"Remote "<< packet->remote.toString() <<" wants '" << packet->qdomain<<"|"<<packet->qtype.getName() << 
+        "', do = " <<packet->d_dnssecOk <<", bufsize = "<< packet->getMaxReplyLen()<<": ";
+
 
-      if(!packet->d.rd && !packet->d_dnssecOk && packet->couldBeCached() && PC.get(packet.get(), cached.get())) { // short circuit - does the PacketCache recognize this question?
+      if(!packet->d.rd && packet->couldBeCached() && PC.get(packet.get(), cached.get())) { // short circuit - does the PacketCache recognize this question?
+        if(logDNSDetails)
+          L<<"packetcache HIT"<<endl;
         cached->setRemote(&packet->remote);
         cached->d.id=packet->d.id;
         cached->d.rd=packet->d.rd; // copy in recursion desired bit 
@@ -293,7 +299,8 @@ void *TCPNameserver::doConnection(void *data)
         S.inc("tcp-answers");
         continue;
       }
-        
+      if(logDNSDetails)
+          L<<"packetcache MISS"<<endl;  
       {
         Lock l(&s_plock);
         if(!s_P) {