From: Victor Julien Date: Mon, 29 Oct 2018 08:29:58 +0000 (+0100) Subject: pfring: fix bypass counter print uninitialized values X-Git-Tag: suricata-4.1.0~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c02b40be6c3db83d5669cbc3c04c3ea9fa495f3;p=thirdparty%2Fsuricata.git pfring: fix bypass counter print uninitialized values If the option was disabled in the config the value would be uninitialized. --- diff --git a/src/source-pfring.c b/src/source-pfring.c index e38546b1bb..8063290977 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -198,18 +198,17 @@ static inline void PfringDumpCounters(PfringThreadVars *ptv) * to the interface counter */ uint64_t th_pkts = StatsGetLocalCounterValue(ptv->tv, ptv->capture_kernel_packets); uint64_t th_drops = StatsGetLocalCounterValue(ptv->tv, ptv->capture_kernel_drops); -#ifdef HAVE_PF_RING_FLOW_OFFLOAD - uint64_t th_bypassed = StatsGetLocalCounterValue(ptv->tv, ptv->capture_bypassed); -#endif SC_ATOMIC_ADD(ptv->livedev->pkts, pfring_s.recv - th_pkts); SC_ATOMIC_ADD(ptv->livedev->drop, pfring_s.drop - th_drops); -#ifdef HAVE_PF_RING_FLOW_OFFLOAD - SC_ATOMIC_ADD(ptv->livedev->bypassed, pfring_s.shunt - th_bypassed); -#endif StatsSetUI64(ptv->tv, ptv->capture_kernel_packets, pfring_s.recv); StatsSetUI64(ptv->tv, ptv->capture_kernel_drops, pfring_s.drop); + #ifdef HAVE_PF_RING_FLOW_OFFLOAD - StatsSetUI64(ptv->tv, ptv->capture_bypassed, pfring_s.shunt); + if (ptv->flags & PFRING_FLAGS_BYPASS) { + uint64_t th_bypassed = StatsGetLocalCounterValue(ptv->tv, ptv->capture_bypassed); + SC_ATOMIC_ADD(ptv->livedev->bypassed, pfring_s.shunt - th_bypassed); + StatsSetUI64(ptv->tv, ptv->capture_bypassed, pfring_s.shunt); + } #endif } }