From: Kees Monshouwer Date: Mon, 1 Jul 2013 22:58:19 +0000 (+0200) Subject: keep statistics for tcp queries and queries with do bit X-Git-Tag: rec-3.6.0-rc1~580^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9951e2d02a8d3c60543b0f1c2cfffdcd4e0202dc;p=thirdparty%2Fpdns.git keep statistics for tcp queries and queries with do bit --- diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 32d766d235..ca3087eb8a 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -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; diff --git a/pdns/dnspacket.cc b/pdns/dnspacket.cc index 327ff15ddf..e75bdaedea 100644 --- a/pdns/dnspacket.cc +++ b/pdns/dnspacket.cc @@ -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. */ diff --git a/pdns/dnspacket.hh b/pdns/dnspacket.hh index 91c44bddec..04609fd2dc 100644 --- a/pdns/dnspacket.hh +++ b/pdns/dnspacket.hh @@ -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 getAPRecords(); //!< get a vector with DNSResourceRecords that need additional processing vector getAnswerRecords(); //!< get a vector with DNSResourceRecords that are answers diff --git a/pdns/nameserver.cc b/pdns/nameserver.cc index 5cf7573c56..013ed2f9ad 100644 --- a/pdns/nameserver.cc +++ b/pdns/nameserver.cc @@ -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()); } diff --git a/pdns/packetcache.cc b/pdns/packetcache.cc index 0acbf725dd..da94aae516 100644 --- a/pdns/packetcache.cc +++ b/pdns/packetcache.cc @@ -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; } diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 1f89e31718..80f9088cae 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -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()); } diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index 2df867ff8b..cf5d98e482 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -175,6 +175,18 @@ void connectWithTimeout(int fd, struct sockaddr* remote, size_t socklen) void TCPNameserver::sendPacket(shared_ptr 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());