]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
keep statistics for tcp queries and queries with do bit
authorKees Monshouwer <mind04@monshouwer.org>
Mon, 1 Jul 2013 22:58:19 +0000 (00:58 +0200)
committermind04 <mind04@monshouwer.org>
Wed, 3 Jul 2013 07:22:29 +0000 (09:22 +0200)
pdns/common_startup.cc
pdns/dnspacket.cc
pdns/dnspacket.hh
pdns/nameserver.cc
pdns/packetcache.cc
pdns/packethandler.cc
pdns/tcpreceiver.cc

index 32d766d235bb5452813ed2b35747a3b43fc66324..ca3087eb8a3ef286d51f93b21ef15a820dc033be 100644 (file)
@@ -151,10 +151,11 @@ void declareArguments()
 void declareStats(void)
 {
   S.declare("udp-queries","Number of UDP queries received");
+  S.declare("udp-do-queries","Number of UDP queries received with DO bit");
   S.declare("udp-answers","Number of answers sent out over UDP");
 
   S.declare("udp4-answers","Number of IPv4 answers sent out over UDP");
-  S.declare("udp4-queries","Number of IPv4UDP queries received");
+  S.declare("udp4-queries","Number of IPv4 UDP queries received");
   S.declare("udp6-answers","Number of IPv6 answers sent out over UDP");
   S.declare("udp6-queries","Number of IPv6 UDP queries received");
 
@@ -231,6 +232,7 @@ void *qthread(void *number)
   DNSPacket cached;
 
   unsigned int &numreceived=*S.getPointer("udp-queries");
+  unsigned int &numreceiveddo=*S.getPointer("udp-do-queries");
   unsigned int &numanswered=*S.getPointer("udp-answers");
 
   unsigned int &numreceived4=*S.getPointer("udp4-queries");
@@ -267,6 +269,9 @@ void *qthread(void *number)
     else
       numreceived6++;
 
+    if(P->d_dnssecOk)
+      numreceiveddo++;
+
      if(P->d.qr)
        continue;
 
index 327ff15ddf71e5b59e883975c018115127196e91..e75bdaedea5fc2e2fbe210bb5952f416b19b436e 100644 (file)
@@ -241,6 +241,11 @@ unsigned int DNSPacket::getMinTTL()
   return minttl;
 }
 
+bool DNSPacket::isEmpty()
+{
+  return (d_rrs.empty());
+}
+
 /** Must be called before attempting to access getData(). This function stuffs all resource
  *  records found in rrs into the data buffer. It also frees resource records queued for us.
  */
index 91c44bddec2258f3735d259321fc17d3098bbbd2..04609fd2dcaed016eaa8f5b8db4716f216e6f199 100644 (file)
@@ -125,6 +125,7 @@ public:
   void wrapup();  // writes out queued rrs, and generates the binary packet. also shuffles. also rectifies dnsheader 'd', and copies it to the stringbuffer
   void spoofQuestion(const DNSPacket *qd); //!< paste in the exact right case of the question. Useful for PacketCache
   unsigned int getMinTTL(); //!< returns lowest TTL of any record in the packet
+  bool isEmpty(); //!< returns true if there are no rrs in the packet
 
   vector<DNSResourceRecord*> getAPRecords(); //!< get a vector with DNSResourceRecords that need additional processing
   vector<DNSResourceRecord*> getAnswerRecords(); //!< get a vector with DNSResourceRecords that are answers
index 5cf7573c5607721d7aba79e676b52761bcd03503..013ed2f9ad339a244713890bb7951f6126433e7f 100644 (file)
@@ -246,11 +246,9 @@ void UDPNameserver::send(DNSPacket *p)
 
   /* Query statistics */
   if(p->d.aa) {
-    if (p->d.rcode == RCode::NoError)
-      S.ringAccount("noerror-queries",p->qdomain+"/"+p->qtype.getName());
-    else if (p->d.rcode == RCode::NXDomain)
+    if (p->d.rcode==RCode::NXDomain)
       S.ringAccount("nxdomain-queries",p->qdomain+"/"+p->qtype.getName());
-  } else {
+  } else if (p->isEmpty()) {
     S.ringAccount("unauth-queries",p->qdomain);
     S.ringAccount("remotes-unauth",p->getRemote());
   }
index 0acbf725dd60066ed16c5bdc106ba422da611cc9..da94aae5164f9c64faeaef63116c09a6d8622a7a 100644 (file)
@@ -93,6 +93,8 @@ int PacketCache::get(DNSPacket *p, DNSPacket *cached)
       return 0;
     }
     cached->spoofQuestion(p); // for correct case
+    cached->qdomain=p->qdomain;
+    cached->qtype=p->qtype;
     return 1;
   }
 
index 1f89e3171899bed2b83d6f12c5fcc9771f5beda7..80f9088cae61385a4af4cf97a921762e82f2b53d 100644 (file)
@@ -1000,6 +1000,8 @@ void PacketHandler::makeNOError(DNSPacket* p, DNSPacket* r, const std::string& t
 
   if(p->d_dnssecOk && d_dk.isSecuredZone(sd.qname))
     addNSECX(p, r, target, wildcard, sd.qname, mode);
+
+  S.ringAccount("noerror-queries",p->qdomain+"/"+p->qtype.getName());
 }
 
 
index 2df867ff8bdab6ac21266fd297826774fed1f220..cf5d98e482a826d7ec0da833be6b118bbd24f668 100644 (file)
@@ -175,6 +175,18 @@ void connectWithTimeout(int fd, struct sockaddr* remote, size_t socklen)
 
 void TCPNameserver::sendPacket(shared_ptr<DNSPacket> p, int outsock)
 {
+
+  /* Query statistics */
+  if(p->qtype.getCode()!=QType::AXFR && p->qtype.getCode()!=QType::IXFR) {
+    if(p->d.aa) {
+      if(p->d.rcode==RCode::NXDomain)
+        S.ringAccount("nxdomain-queries",p->qdomain+"/"+p->qtype.getName());
+    } else if(p->isEmpty()) {
+      S.ringAccount("unauth-queries",p->qdomain);
+      S.ringAccount("remotes-unauth",p->getRemote());
+    }
+  }
+
   uint16_t len=htons(p->getString().length());
   string buffer((const char*)&len, 2);
   buffer.append(p->getString());