From: ARUNKUMAR KAYAMBU -X (akayambu - XORIANT CORPORATION at Cisco) Date: Tue, 24 Oct 2023 14:46:30 +0000 (+0000) Subject: Pull request #4041: packet_io: fix incorrect counters caused by data plane counters... X-Git-Tag: 3.1.74.0~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef7df0eed5460822105e9cb2de51740c684373a3;p=thirdparty%2Fsnort3.git Pull request #4041: packet_io: fix incorrect counters caused by data plane counters reset Merge in SNORT/snort3 from ~AKAYAMBU/snort3:daq_counter_fix to master Squashed commit of the following: commit 4ed5cf5bc6c597417789b18c15b03efa2843db69 Author: Arunkumar Kayambu Date: Fri Oct 6 08:21:47 2023 -0400 packet_io: fix incorrect counters caused by data plane counters reset --- diff --git a/src/packet_io/sfdaq_instance.cc b/src/packet_io/sfdaq_instance.cc index 2cea141c6..df424f5f4 100644 --- a/src/packet_io/sfdaq_instance.cc +++ b/src/packet_io/sfdaq_instance.cc @@ -292,14 +292,6 @@ const DAQ_Stats_t* SFDAQInstance::get_stats() int rval = daq_instance_get_stats(instance, &daq_instance_stats); if (rval != DAQ_SUCCESS) LogMessage("Couldn't query DAQ stats: %s (%d)\n", daq_instance_get_error(instance), rval); - - // Some DAQ modules don't provide hardware numbers, so we default HW RX to the SW equivalent - // (this means outstanding packets = 0) - if (daq_instance_stats.hw_packets_received == 0) - { - daq_instance_stats.hw_packets_received = daq_instance_stats.packets_received + - daq_instance_stats.packets_filtered; - } } return &daq_instance_stats; diff --git a/src/packet_io/sfdaq_module.cc b/src/packet_io/sfdaq_module.cc index 39fb65939..33f127232 100644 --- a/src/packet_io/sfdaq_module.cc +++ b/src/packet_io/sfdaq_module.cc @@ -250,22 +250,32 @@ void SFDAQModule::prep_counts(bool dump_stats) DAQ_Stats_t daq_stats_delta = new_daq_stats - prev_daq_stats; daq_stats.pcaps = Trough::get_file_count(); - daq_stats.received = daq_stats_delta.hw_packets_received; 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.injected = daq_stats_delta.packets_injected; + daq_stats.injected = daq_stats_delta.packets_injected; + + // Data plane stats is reset + if ( new_daq_stats.hw_packets_dropped < prev_daq_stats.hw_packets_dropped || + new_daq_stats.hw_packets_received < prev_daq_stats.hw_packets_received ) + { + daq_stats.dropped = new_daq_stats.hw_packets_dropped; + daq_stats.received = new_daq_stats.hw_packets_received; + } + else + { + daq_stats.dropped = daq_stats_delta.hw_packets_dropped; + daq_stats.received = daq_stats_delta.hw_packets_received; + } for ( unsigned i = 0; i < MAX_DAQ_VERDICT; i++ ) daq_stats.verdicts[i] = daq_stats_delta.verdicts[i]; 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) + if ( !dump_stats ) prev_daq_stats = new_daq_stats; }