From: bert hubert Date: Fri, 26 Sep 2014 12:38:03 +0000 (+0200) Subject: use kernel recorded arrival time for question/answer latency measurements, so we... X-Git-Tag: rec-3.7.0-rc1~238^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ae194e2456ed2d415c70430dfab72637f91f284;p=thirdparty%2Fpdns.git use kernel recorded arrival time for question/answer latency measurements, so we include the queue of packets waiting for userland attention in our stats. could be bad. --- diff --git a/pdns/misc.cc b/pdns/misc.cc index a43030ba6f..41fb452586 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -907,3 +907,10 @@ uint32_t burtle(const unsigned char* k, uint32_t length, uint32_t initval) /*-------------------------------------------- report the result */ return c; } + +void setSocketTimestamps(int fd) +{ + int on=1; + if (setsockopt(fd, SOL_SOCKET, SO_TIMESTAMP, (char*)&on, sizeof(on)) < 0 ) + L<cmsg_level == SOL_SOCKET) && (cmsg->cmsg_type == SO_TIMESTAMP) && + CMSG_LEN(sizeof(*tv)) == cmsg->cmsg_len) { + memcpy(tv, CMSG_DATA(cmsg), sizeof(*tv)); + return true; + } + } + return false; +} + static bool HarvestDestinationAddress(struct msghdr* msgh, ComboAddress* destination) { memset(destination, 0, sizeof(*destination)); @@ -431,7 +448,7 @@ DNSPacket *UDPNameserver::receive(DNSPacket *prefilled) packet=prefilled; else packet=new DNSPacket; // don't forget to free it! - packet->d_dt.set(); // timing + packet->setSocket(sock); packet->setRemote(&remote); @@ -441,6 +458,13 @@ DNSPacket *UDPNameserver::receive(DNSPacket *prefilled) packet->d_anyLocal = dest; } + struct timeval recvtv; + if(HarvestTimestamp(&msgh, &recvtv)) { + packet->d_dt.setTimeval(recvtv); + } + else + packet->d_dt.set(); // timing + if(packet->parse(mesg, len)<0) { S.inc("corrupt-packets"); S.ringAccount("remotes-corrupt", packet->getRemote());