Permalink
Browse files

on Linux, SO_TIMESTAMP == SCM_TIMESTAMP, on at least FreeBSD, it is n…

…ot, causing us to miss harvesting the timestamp, and dropping all packets as too old. With this change, we don't drop if we can't find the timestamp, plus harvest it properly
  • Loading branch information...
1 parent 60ba1e6 commit d63f0d83631c41eff203d30b0b7c475a88f1db59 @ahupowerdns ahupowerdns committed Feb 11, 2015
Showing with 5 additions and 2 deletions.
  1. +3 −1 pdns/iputils.cc
  2. +1 −0 pdns/misc.cc
  3. +1 −1 pdns/pdns_recursor.cc
View
@@ -1,4 +1,6 @@
#include "iputils.hh"
+#include <sys/socket.h>
+
/** these functions provide a very lightweight wrapper to the Berkeley sockets API. Errors -> exceptions! */
static void RuntimeError(const boost::format& fmt)
@@ -63,7 +65,7 @@ bool HarvestTimestamp(struct msghdr* msgh, struct timeval* tv)
#ifdef SO_TIMESTAMP
struct cmsghdr *cmsg;
for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(msgh,cmsg)) {
- if ((cmsg->cmsg_level == SOL_SOCKET) && (cmsg->cmsg_type == SO_TIMESTAMP) &&
+ if ((cmsg->cmsg_level == SOL_SOCKET) && (cmsg->cmsg_type == SO_TIMESTAMP || cmsg->cmsg_type == SCM_TIMESTAMP) &&
CMSG_LEN(sizeof(*tv)) == cmsg->cmsg_len) {
memcpy(tv, CMSG_DATA(cmsg), sizeof(*tv));
return true;
View
@@ -21,6 +21,7 @@
*/
#include <sys/param.h>
+#include <sys/socket.h>
#include <netdb.h>
#include <sys/time.h>
#include <time.h>
@@ -934,7 +934,7 @@ string* doProcessUDPQuestion(const std::string& question, const ComboAddress& fr
struct timeval diff = g_now - tv;
double delta=(diff.tv_sec*1000 + diff.tv_usec/1000.0);
- if(delta > 1000.0) {
+ if(tv.tv_sec && delta > 1000.0) {
g_stats.tooOldDrops++;
return 0;
}

0 comments on commit d63f0d8

Please sign in to comment.