]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3285: sfdaq: fix for underflow of outstanding counter
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Tue, 22 Feb 2022 17:36:52 +0000 (17:36 +0000)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Tue, 22 Feb 2022 17:36:52 +0000 (17:36 +0000)
Merge in SNORT/snort3 from ~OSERHIIE/snort3:daq_outstanding_fix to master

Squashed commit of the following:

commit d97c12297e4c794b5d61753760c63dd2102aff28
Author: Oleksandr Serhiienko <oserhiie@cisco.com>
Date:   Tue Feb 22 15:02:05 2022 +0200

    packet_io: truncate negative values to zero in DAQ stats

src/packet_io/sfdaq_module.cc

index e863d2685bec4f96d3815be376308f29d1856fcc..910270ae7ea0875e64bc60b4319a04d7511314cb 100644 (file)
@@ -253,13 +253,22 @@ void SFDAQModule::prep_counts()
     daq_stats.analyzed = daq_stats_delta.packets_received;
     daq_stats.dropped = daq_stats_delta.hw_packets_dropped;
     daq_stats.filtered = daq_stats_delta.packets_filtered;
-    daq_stats.outstanding = daq_stats_delta.hw_packets_received -
-        daq_stats_delta.packets_filtered - daq_stats_delta.packets_received;
     daq_stats.injected =  daq_stats_delta.packets_injected;
 
     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;
+
     prev_daq_stats = new_daq_stats;
 }