From: Eric Leblond Date: Fri, 22 Apr 2016 22:30:39 +0000 (+0200) Subject: af-packet: ask for hardware timestamp X-Git-Tag: suricata-3.1RC1~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a40f08a21335e25d8b7aa1fe5182ec2687954b7d;p=thirdparty%2Fsuricata.git af-packet: ask for hardware timestamp --- diff --git a/configure.ac b/configure.ac index e7237651a2..fc936abaec 100644 --- a/configure.ac +++ b/configure.ac @@ -1197,6 +1197,10 @@ [], [[#include #include ]]) + AC_CHECK_DECL([SOF_TIMESTAMPING_RAW_HARDWARE], + AC_DEFINE([HAVE_HW_TIMESTAMPING],[1],[Hardware timestamping support is available]), + [], + [[#include ]]) ]) # Netmap support diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 7e1aa5444a..f6b6237f68 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -94,6 +94,10 @@ #include #endif +#ifdef HAVE_HW_TIMESTAMPING +#include +#endif + #endif /* HAVE_AF_PACKET */ extern int max_pending_packets; @@ -1669,6 +1673,16 @@ static int AFPSetupRing(AFPThreadVars *ptv, char *devname) return AFP_FATAL_ERROR; } +#ifdef HAVE_HW_TIMESTAMPING + int req = SOF_TIMESTAMPING_RAW_HARDWARE; + if (setsockopt(ptv->socket, SOL_PACKET, PACKET_TIMESTAMP, (void *) &req, + sizeof(req)) < 0) { + SCLogWarning(SC_ERR_AFP_CREATE, + "Can't activate hardware timestamping on packet socket: %s", + strerror(errno)); + } +#endif + /* Allocate RX ring */ #ifdef HAVE_TPACKET_V3 if (ptv->flags & AFP_TPACKET_V3) {