]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dpdk: query device stats only with one worker
authorLukas Sismis <lsismis@oisf.net>
Tue, 18 Apr 2023 11:50:28 +0000 (13:50 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 10 May 2023 13:59:01 +0000 (15:59 +0200)
Function rte_eth_stats_get is not thread-safe and
the result is only used by one thread.
Running with multiple workers led to very high values in rx_missed
counters (buffer-overflow-like behavior).

Ticket: #6006

src/source-dpdk.c

index 2c22cc31a811a7fee1643283e0887ecbd7a57b1b..cf59ad9bba063a2b1b0f60041be9682dc375f7c0 100644 (file)
@@ -268,17 +268,17 @@ void TmModuleDecodeDPDKRegister(void)
 
 static inline void DPDKDumpCounters(DPDKThreadVars *ptv)
 {
-    struct rte_eth_stats eth_stats;
-    int retval = rte_eth_stats_get(ptv->port_id, &eth_stats);
-    if (unlikely(retval != 0)) {
-        SCLogError("Failed to get stats for port id %d: %s", ptv->port_id, rte_strerror(-retval));
-        return;
-    }
-
     /* Some NICs (e.g. Intel) do not support queue statistics and the drops can be fetched only on
      * the port level. Therefore setting it to the first worker to have at least continuous update
      * on the dropped packets. */
     if (ptv->queue_id == 0) {
+        struct rte_eth_stats eth_stats;
+        int retval = rte_eth_stats_get(ptv->port_id, &eth_stats);
+        if (unlikely(retval != 0)) {
+            SCLogError("%s: failed to get stats: %s", ptv->livedev->dev, rte_strerror(-retval));
+            return;
+        }
+
         StatsSetUI64(ptv->tv, ptv->capture_dpdk_packets,
                 ptv->pkts + eth_stats.imissed + eth_stats.ierrors + eth_stats.rx_nombuf);
         SC_ATOMIC_SET(ptv->livedev->pkts,