]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Fix missing timestamps in some flavours of PF_RING
authorChris Wakelin <c.d.wakelin@reading.ac.uk>
Wed, 30 May 2012 20:53:21 +0000 (21:53 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 31 May 2012 09:27:38 +0000 (11:27 +0200)
src/source-pfring.c

index 4079ce258b22b6b1fef3494e3559fe1c090786ed..56210bef19c0ef375e329cecf97f8450cb74d19d 100644 (file)
@@ -260,6 +260,9 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot)
             SCReturnInt(TM_ECODE_FAILED);
         }
 
+        /* Some flavours of PF_RING may fail to set timestamp - see PF-RING-enabled libpcap code*/
+        hdr.ts.tv_sec = 0;
+
         /* Depending on what compile time options are used for pfring we either return 0 or -1 on error and always 1 for success */
 #ifdef HAVE_PFRING_RECV_UCHAR
         int r = pfring_recv(ptv->pd, (u_char**)&GET_PKT_DIRECT_DATA(p),
@@ -276,6 +279,10 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot)
         if (r == 1) {
             //printf("RecievePfring src %" PRIu32 " sport %" PRIu32 " dst %" PRIu32 " dstport %" PRIu32 "\n",
             //        hdr.parsed_pkt.ipv4_src,hdr.parsed_pkt.l4_src_port, hdr.parsed_pkt.ipv4_dst,hdr.parsed_pkt.l4_dst_port);
+
+            /* PF_RING may fail to set timestamp */
+            if (hdr.ts.tv_sec == 0) gettimeofday((struct timeval*)&hdr.ts, NULL);
+
             PfringProcessPacket(ptv, &hdr, p);
             if (TmThreadsSlotProcessPkt(ptv->tv, ptv->slot, p) != TM_ECODE_OK) {
                 TmqhOutputPacketpool(ptv->tv, p);