]> granicus.if.org Git - pdns/commitdiff
on Linux, SO_TIMESTAMP == SCM_TIMESTAMP, on at least FreeBSD, it is not, causing...
authorbert hubert <bert.hubert@netherlabs.nl>
Wed, 11 Feb 2015 16:00:21 +0000 (17:00 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Wed, 11 Feb 2015 16:00:21 +0000 (17:00 +0100)
pdns/iputils.cc
pdns/misc.cc
pdns/pdns_recursor.cc

index 2f09d51924c71600655b80846a2762b8c09f7729..83c48d9ca33f9701044fb3344a4bb3a1b8f51579 100644 (file)
@@ -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;
index 6e0fa7ecf48d946b2aadfe75564225ce8978a28e..01529cf054a9dc9a2da70e2162ae42e44ad03bea 100644 (file)
@@ -21,6 +21,7 @@
 */
 
 #include <sys/param.h>
+#include <sys/socket.h>
 #include <netdb.h>
 #include <sys/time.h>
 #include <time.h>
index e07e9afd0c0386e555a185a8942d9550d6c52076..fdee0f115e54a3e28954b6c42d7b83f35d978d20 100644 (file)
@@ -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;
   }