]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
capture: use 64 bits counters 858/head
authorEric Leblond <eric@regit.org>
Thu, 27 Feb 2014 10:47:38 +0000 (11:47 +0100)
committerEric Leblond <eric@regit.org>
Thu, 27 Feb 2014 10:47:38 +0000 (11:47 +0100)
Some of the packets counters were using a 32bit integer. Given the
bandwidth that is often seen, this is not a good idea. This patch
switches to 64bit counter.

src/source-af-packet.c
src/source-pfring.c
src/util-device.c
src/util-device.h

index 3604d4c0e3ac1b9df5f1860d7013c386c3f1fc4e..51ed693e41f474ab2ebdfbd26d2e7ea4b5c2cd91 100644 (file)
@@ -191,9 +191,9 @@ typedef struct AFPThreadVars_
     int cooked;
 
     /* counters */
-    uint32_t pkts;
+    uint64_t pkts;
     uint64_t bytes;
-    uint32_t errs;
+    uint64_t errs;
 
     ThreadVars *tv;
     TmSlot *slot;
@@ -499,8 +499,8 @@ static inline void AFPDumpCounters(AFPThreadVars *ptv)
                 kstats.tp_packets, kstats.tp_drops);
         SCPerfCounterAddUI64(ptv->capture_kernel_packets, ptv->tv->sc_perf_pca, kstats.tp_packets);
         SCPerfCounterAddUI64(ptv->capture_kernel_drops, ptv->tv->sc_perf_pca, kstats.tp_drops);
-        (void) SC_ATOMIC_ADD(ptv->livedev->drop, kstats.tp_drops);
-        (void) SC_ATOMIC_ADD(ptv->livedev->pkts, kstats.tp_packets);
+        (void) SC_ATOMIC_ADD(ptv->livedev->drop, (uint64_t) kstats.tp_drops);
+        (void) SC_ATOMIC_ADD(ptv->livedev->pkts, (uint64_t) kstats.tp_packets);
     }
 #endif
 }
@@ -1648,7 +1648,7 @@ void ReceiveAFPThreadExitStats(ThreadVars *tv, void *data) {
             (uint64_t) SCPerfGetLocalCounterValue(ptv->capture_kernel_drops, tv->sc_perf_pca));
 #endif
 
-    SCLogInfo("(%s) Packets %" PRIu32 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes);
+    SCLogInfo("(%s) Packets %" PRIu64 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes);
 }
 
 /**
index 96f1fc72458e40cac6089628403e276d582fb4b8..6c966083febc4b9de9849559d7ee3903b12f9690 100644 (file)
@@ -132,7 +132,7 @@ typedef struct PfringThreadVars_
 
     /* counters */
     uint64_t bytes;
-    uint32_t pkts;
+    uint64_t pkts;
 
     uint16_t capture_kernel_packets;
     uint16_t capture_kernel_drops;
@@ -525,7 +525,7 @@ void ReceivePfringThreadExitStats(ThreadVars *tv, void *data) {
             tv->name,
             (uint64_t) SCPerfGetLocalCounterValue(ptv->capture_kernel_packets, tv->sc_perf_pca),
             (uint64_t) SCPerfGetLocalCounterValue(ptv->capture_kernel_drops, tv->sc_perf_pca));
-    SCLogInfo("(%s) Packets %" PRIu32 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes);
+    SCLogInfo("(%s) Packets %" PRIu64 ", bytes %" PRIu64 "", tv->name, ptv->pkts, ptv->bytes);
 }
 
 /**
index 19db88cbcd4f0cb4b4eb4ae341aee25b4c79d9ba..f048cd7919d3456eb13c8e6828487d663d90b668 100644 (file)
@@ -165,7 +165,7 @@ int LiveDeviceListClean()
     LiveDevice *pd, *tpd;
 
     TAILQ_FOREACH_SAFE(pd, &live_devices, next, tpd) {
-        SCLogNotice("Stats for '%s':  pkts: %u, drop: %u (%.2f%%), invalid chksum: %u",
+        SCLogNotice("Stats for '%s':  pkts: %" PRIu64", drop: %" PRIu64 " (%.2f%%), invalid chksum: %" PRIu64,
                     pd->dev,
                     SC_ATOMIC_GET(pd->pkts),
                     SC_ATOMIC_GET(pd->drop),
index cfd85b64fb70c4f93746e798c91d056ecb8b08ff..455c2d2e26743c85e19f90747f44da5c0bb0f1c8 100644 (file)
@@ -25,9 +25,9 @@
 typedef struct LiveDevice_ {
     char *dev;  /**< the device (e.g. "eth0") */
     int ignore_checksum;
-    SC_ATOMIC_DECLARE(unsigned int, pkts);
-    SC_ATOMIC_DECLARE(unsigned int, drop);
-    SC_ATOMIC_DECLARE(unsigned int, invalid_checksums);
+    SC_ATOMIC_DECLARE(uint64_t, pkts);
+    SC_ATOMIC_DECLARE(uint64_t, drop);
+    SC_ATOMIC_DECLARE(uint64_t, invalid_checksums);
     TAILQ_ENTRY(LiveDevice_) next;
 } LiveDevice;