From 6865d5c0f89878840a174bec27e4e95cb93ce45e Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Mon, 1 Jul 2013 19:30:50 +0200 Subject: [PATCH] improve udp query statistics --- pdns/nameserver.cc | 13 ++++++++++++- pdns/packethandler.cc | 9 +++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pdns/nameserver.cc b/pdns/nameserver.cc index 95dbd3f7dd..5cf7573c56 100644 --- a/pdns/nameserver.cc +++ b/pdns/nameserver.cc @@ -243,7 +243,18 @@ void UDPNameserver::send(DNSPacket *p) struct cmsghdr *cmsg; struct iovec iov; char cbuf[256]; - + + /* 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) + S.ringAccount("nxdomain-queries",p->qdomain+"/"+p->qtype.getName()); + } else { + S.ringAccount("unauth-queries",p->qdomain); + S.ringAccount("remotes-unauth",p->getRemote()); + } + /* Set up iov and msgh structures. */ memset(&msgh, 0, sizeof(struct msghdr)); iov.iov_base = (void*)buffer.c_str(); diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index ad2a54f8dc..1f89e31718 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -977,12 +977,11 @@ void PacketHandler::makeNXDomain(DNSPacket* p, DNSPacket* r, const std::string& rr.auth = 1; rr.scopeMask = sd.scopeMask; r->addRecord(rr); - + if(p->d_dnssecOk && d_dk.isSecuredZone(sd.qname)) addNSECX(p, r, target, wildcard, sd.qname, 4); - - r->setRcode(RCode::NXDomain); - S.ringAccount("nxdomain-queries",p->qdomain+"/"+p->qtype.getName()); + + r->setRcode(RCode::NXDomain); } void PacketHandler::makeNOError(DNSPacket* p, DNSPacket* r, const std::string& target, const std::string& wildcard, SOAData& sd, int mode) @@ -1001,8 +1000,6 @@ 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()); } -- 2.47.3