]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4011: packet_io: fix daq stats
authorAdrian Mamolea (admamole) <admamole@cisco.com>
Thu, 28 Sep 2023 08:58:28 +0000 (08:58 +0000)
committerOleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) <oshumeik@cisco.com>
Thu, 28 Sep 2023 08:58:28 +0000 (08:58 +0000)
Merge in SNORT/snort3 from ~ADMAMOLE/snort3:kern to master

Squashed commit of the following:

commit 0ef7d59ebe19f9c93e39296bcf6dd7d540596971
Author: Adrian Mamolea <admamole@cisco.com>
Date:   Tue Sep 19 17:52:12 2023 -0400

    packet_io: fix daq stats

src/packet_io/sfdaq_module.cc
src/packet_io/sfdaq_module.h

index c0399e1fa81833e5fad9d9dfae0d94462d400403..39fb65939f534224e2ec74e5d350232b378793c6 100644 (file)
@@ -178,7 +178,8 @@ const PegInfo daq_names[] =
     { CountType::SUM, "analyzed", "total packets analyzed from DAQ" },
     { CountType::SUM, "dropped", "packets dropped" },
     { CountType::SUM, "filtered", "packets filtered out" },
-    { CountType::SUM, "outstanding", "packets unprocessed" },
+    { CountType::NOW, "outstanding", "packets unprocessed" },
+    { CountType::MAX, "outstanding_max", "maximum of packets unprocessed" },
     { CountType::SUM, "injected", "active responses or replacements" },
 
     // Must align with MAX_DAQ_VERDICT (one for each, in order)
@@ -258,16 +259,11 @@ void SFDAQModule::prep_counts(bool dump_stats)
     for ( unsigned i = 0; i < MAX_DAQ_VERDICT; i++ )
         daq_stats.verdicts[i] = daq_stats_delta.verdicts[i];
 
-    // If DAQ returns HW packets counter less than SW packets counter,
-    // Snort treats that as no outstanding packets left.
-    if (daq_stats_delta.hw_packets_received >
-        (daq_stats_delta.packets_filtered + daq_stats_delta.packets_received))
-    {
-        daq_stats.outstanding = daq_stats_delta.hw_packets_received -
-            daq_stats_delta.packets_filtered - daq_stats_delta.packets_received;
-    }
-    else
-        daq_stats.outstanding = 0;
+    daq_stats.outstanding = new_daq_stats.hw_packets_received -
+        new_daq_stats.packets_filtered - new_daq_stats.packets_received;
+
+    if ( daq_stats.outstanding > daq_stats.outstanding_max )
+        daq_stats.outstanding_max = daq_stats.outstanding;
 
     if(!dump_stats)
         prev_daq_stats = new_daq_stats;
index 770d546964ec19dec6d53fc3413201f40c137cab..678080aed704c635eacd51c703b6c525cbd752c0 100644 (file)
@@ -63,6 +63,7 @@ struct DAQStats
     PegCount dropped;
     PegCount filtered;
     PegCount outstanding;
+    PegCount outstanding_max;
     PegCount injected;
     PegCount verdicts[MAX_DAQ_VERDICT];
     PegCount internal_blacklist;