]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pfring pkt acq: capture loop optimisation 1712/head
authorcardigliano <cardigliano@ntop.org>
Wed, 21 Oct 2015 23:43:41 +0000 (01:43 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 22 Oct 2015 08:16:54 +0000 (10:16 +0200)
For each packet the capture module checks whether it is time to dump stats calling
TimeGet(). TimeGet() is an expensive function using gettimeofday() or SCSpinLock()
which affect performance. Since gettimeofday() is already called for setting packet
timestamp, it is more efficient to use the packet timestamp directly.

src/source-pfring.c

index 3e9db24b1104ca7e3404bf8b0a7479c1123fac66..3e2ba6a8563c9dcd5106c38bdfcb7e3c6ec4832e 100644 (file)
@@ -301,7 +301,6 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot)
     struct pfring_pkthdr hdr;
     TmSlot *s = (TmSlot *)slot;
     time_t last_dump = 0;
-    struct timeval current_time;
     u_int buffer_size;
     u_char *pkt_buffer;
 
@@ -365,10 +364,9 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot)
             }
 
             /* Trigger one dump of stats every second */
-            TimeGet(&current_time);
-            if (current_time.tv_sec != last_dump) {
+            if (p->ts.tv_sec != last_dump) {
                 PfringDumpCounters(ptv);
-                last_dump = current_time.tv_sec;
+                last_dump = p->ts.tv_sec;
             }
         } else {
             SCLogError(SC_ERR_PF_RING_RECV,"pfring_recv error  %" PRId32 "", r);