From: Mike Stepanek (mstepane) Date: Tue, 22 Feb 2022 17:36:52 +0000 (+0000) Subject: Pull request #3285: sfdaq: fix for underflow of outstanding counter X-Git-Tag: 3.1.24.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c321a23c91e4e720bc3473dd9642685e78751423;p=thirdparty%2Fsnort3.git Pull request #3285: sfdaq: fix for underflow of outstanding counter Merge in SNORT/snort3 from ~OSERHIIE/snort3:daq_outstanding_fix to master Squashed commit of the following: commit d97c12297e4c794b5d61753760c63dd2102aff28 Author: Oleksandr Serhiienko Date: Tue Feb 22 15:02:05 2022 +0200 packet_io: truncate negative values to zero in DAQ stats --- diff --git a/src/packet_io/sfdaq_module.cc b/src/packet_io/sfdaq_module.cc index e863d2685..910270ae7 100644 --- a/src/packet_io/sfdaq_module.cc +++ b/src/packet_io/sfdaq_module.cc @@ -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; }