]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2668 in SNORT/snort3 from ~SUNIMUKH/snort3:clear_counter to master
authorNaveen Gujje (ngujje) <ngujje@cisco.com>
Tue, 9 Feb 2021 08:02:35 +0000 (08:02 +0000)
committerNaveen Gujje (ngujje) <ngujje@cisco.com>
Tue, 9 Feb 2021 08:02:35 +0000 (08:02 +0000)
Squashed commit of the following:

commit edc690f9464477764c96dbc175411d6e2b0e543f
Author: Sunirmal Mukherjee <sunimukh@cisco.com>
Date:   Tue Dec 8 03:14:39 2020 -0500

    snort: clear snort counter for modules, daq, file_id, appid

36 files changed:
src/file_api/file_module.cc
src/file_api/file_module.h
src/file_api/file_stats.cc
src/file_api/file_stats.h
src/flow/expect_cache.h
src/framework/module.cc
src/main.cc
src/main.h
src/main/analyzer_command.cc
src/main/analyzer_command.h
src/main/snort.cc
src/main/snort_module.cc
src/managers/module_manager.cc
src/managers/module_manager.h
src/network_inspectors/appid/appid_module.cc
src/network_inspectors/appid/appid_module.h
src/network_inspectors/appid/appid_peg_counts.cc
src/network_inspectors/appid/appid_peg_counts.h
src/network_inspectors/appid/detector_plugins/test/http_url_patterns_test.cc
src/network_inspectors/appid/test/appid_api_test.cc
src/network_inspectors/appid/test/appid_detector_test.cc
src/network_inspectors/appid/test/appid_discovery_test.cc
src/network_inspectors/appid/test/appid_http_event_test.cc
src/network_inspectors/appid/test/appid_http_session_test.cc
src/network_inspectors/appid/test/appid_session_api_test.cc
src/packet_io/sfdaq_module.cc
src/packet_io/sfdaq_module.h
src/packet_io/trough.h
src/protocols/packet_manager.cc
src/protocols/packet_manager.h
src/stream/base/stream_base.cc
src/stream/base/stream_module.h
src/stream/tcp/tcp_module.cc
src/stream/tcp/tcp_module.h
src/stream/tcp/tcp_normalizer.cc
src/stream/tcp/tcp_normalizer.h

index 7f42b87d6488435aa94e2f14b78610b629df75ac..fa5e1606bd4acc725de0e64015363d1a1272af7e 100644 (file)
@@ -506,3 +506,8 @@ void FileIdModule::show_dynamic_stats()
     file_stats_print();
 }
 
+void FileIdModule::reset_stats()
+{
+    file_stats_clear();
+    Module::reset_stats();
+}
index 7f7bc48d94465be1550912602493ee6988376c1b..bec62194db0b2ebc702d371c2e56bcf51f04968e 100644 (file)
@@ -51,6 +51,8 @@ public:
 
     void load_config(FileConfig*& dst);
 
+    void reset_stats() override;
+
     Usage get_usage() const override
     { return GLOBAL; }
 
index 237f93d7e8da1a5b3dcd851e3bb4bc68e19513a6..8b8958f9e7e7690fa6470988b2c0f26510909f9a 100644 (file)
@@ -68,6 +68,14 @@ void file_stats_sum()
     }
 }
 
+void file_stats_clear()
+{
+    memset(&file_counts, 0, sizeof(file_counts));
+    memset(&file_totals, 0, sizeof(file_totals));
+    if (file_stats)
+        memset(file_stats, 0, sizeof(*file_stats));
+}
+
 void file_stats_print()
 {
     uint64_t processed_total[2];
index 64de22ef8347b3eb3b3c55ffd6435ab0da55af36..b4eb524d2b1969a6a271d43c453f5d882d29474d 100644 (file)
@@ -74,6 +74,7 @@ void file_stats_term();
 
 void file_stats_sum();
 void file_stats_print();
+void file_stats_clear();
 
 #endif
 
index 44b62babf162f8d27441f44ae8a4345ec5f9dad5..2aa434edaa4e74da9728baa5f785befbca89d80c 100644 (file)
@@ -107,6 +107,13 @@ public:
     unsigned long get_realized() { return realized; }
     unsigned long get_prunes() { return prunes; }
     unsigned long get_overflows() { return overflows; }
+    void reset_stats() 
+    {
+        expects = 0;
+        realized = 0;
+        prunes = 0;
+        overflows = 0;
+    }
 
 private:
     void prune_lru();
index 582abfcad561ae3e92d405d4b75fd2bd171940b2..2b3daced4e2045971648f315f45e3ff7483e5639 100644 (file)
@@ -126,13 +126,19 @@ void Module::show_stats()
 
 void Module::reset_stats()
 {
+    PegCount* p = get_counts();
+    
+    if ( !p )
+        return;
+
+    const PegInfo* pegs = get_pegs();
+
+    if ( !pegs )
+        return;
+
     if ( num_counts <= 0 )
     {
         num_counts = 0;
-        const PegInfo* pegs = get_pegs();
-
-        if ( !pegs )
-            return;
 
         while ( pegs[num_counts].name )
             ++num_counts;
@@ -141,7 +147,12 @@ void Module::reset_stats()
     }
 
     for ( int i = 0; i < num_counts; i++ )
+    {
         counts[i] = 0;
+
+        if ( pegs[i].type != CountType::NOW )
+            p[i] = 0;
+    }
 }
 
 PegCount Module::get_global_count(const char* name) const
index 8282d9ed44083837d4419b28ff311b03b8b777e4..89f3401612013d2a1ec39e4ad93aa027242fb0f3 100644 (file)
@@ -320,6 +320,15 @@ int main_dump_stats(lua_State* L)
     return 0;
 }
 
+int main_reset_stats(lua_State* L)
+{
+    int type = luaL_optint(L, 1, 0);
+    bool from_shell = ( L != nullptr );
+    current_request->respond("== clearing stats\n", from_shell);
+    main_broadcast_command(new ACResetStats(static_cast<clear_counter_type_t>(type)), true);
+    return 0;
+}
+
 int main_rotate_stats(lua_State* L)
 {
     bool from_shell = ( L != nullptr );
index 22d2710d12fc9266348b5b76a6195dbe902ff7cd..479b533af767955fc0d3195c65d57f6c06a0fb1c 100644 (file)
@@ -31,6 +31,7 @@ SharedRequest get_current_request();
 // commands provided by the snort module
 int main_delete_inspector(lua_State* = nullptr);
 int main_dump_stats(lua_State* = nullptr);
+int main_reset_stats(lua_State* = nullptr);
 int main_rotate_stats(lua_State* = nullptr);
 int main_reload_config(lua_State* = nullptr);
 int main_reload_policy(lua_State* = nullptr);
index 64cfe2438d98d7dea0a312acb8f557f0ba92c022..1afa76eb8a5880d856fab2a6fd5378fd3aff7103 100644 (file)
@@ -94,6 +94,15 @@ ACGetStats::~ACGetStats()
     LogMessage("==================================================\n"); // Marking End of stats
 }
 
+bool ACResetStats::execute(Analyzer&, void**)
+{
+    ModuleManager::reset_stats(requested_type);
+    return true;
+}
+
+ACResetStats::ACResetStats(clear_counter_type_t requested_type_l) : requested_type(
+        requested_type_l) { }
+
 ACSwap::ACSwap(Swapper* ps, SharedRequest req, bool from_shell) : ps(ps), request(req), from_shell(from_shell)
 {
     assert(Swapper::get_reload_in_progress() == false);
index 1c9d904ec80c94cd255e87aa40464010345ac22d..e16f6bda586ca0f66e6d90d5fd24cfd9204bb629 100644 (file)
@@ -53,6 +53,40 @@ public:
     ~ACGetStats() override;
 };
 
+typedef enum clear_counter_type
+{
+    TYPE_UNKNOWN=-1,
+    TYPE_DAQ=0,
+    TYPE_MODULE,
+    TYPE_APPID,
+    TYPE_FILE_ID,
+    TYPE_SNORT,
+    TYPE_HA
+} clear_counter_type_t;
+
+// FIXIT-M Will replace this vector with an unordered map of 
+// <clear_counter_type, clear_counter_type_string_map> when
+// will come up with more granular form of clearing module stats.
+static std::vector<const char*> clear_counter_type_string_map
+{
+    "daq",
+    "module",
+    "appid",
+    "file_id",
+    "snort",
+    "high_availability"
+};
+
+class ACResetStats : public snort::AnalyzerCommand
+{
+public:
+    explicit ACResetStats(clear_counter_type_t requested_type);
+    bool execute(Analyzer&, void**) override;
+    const char* stringify() override { return "RESET_STATS"; }
+private:
+    clear_counter_type_t requested_type;
+};
+
 class ACPause : public snort::AnalyzerCommand
 {
 public:
index 4680e30fb5cc4c0f881ed0061827aa314b5badd0..bd3b901e9c55a4cdaa404b7dcb69e918c16c8d14 100644 (file)
@@ -182,6 +182,8 @@ void Snort::init(int argc, char** argv)
 
     HighAvailabilityManager::configure(sc->ha_config);
 
+    ModuleManager::reset_stats(sc);
+
     if (sc->alert_before_pass())
         sc->rule_order = "reset block drop alert pass log";
 
@@ -205,8 +207,6 @@ void Snort::init(int argc, char** argv)
     // Must be after InspectorManager::configure()
     FileService::post_init(sc);
 
-    ModuleManager::reset_stats(sc);
-
     if (sc->file_mask != 0)
         umask(sc->file_mask);
     else
index 5f83814ccde5d840b291a407bfc0f31d1cba884e..a48bfd473ea3c433eed3b92e2bfa295489aceb51 100644 (file)
@@ -106,6 +106,7 @@ static const Command snort_cmds[] =
       "delete an inspector from the default policy" },
 
     { "dump_stats", main_dump_stats, nullptr, "show summary statistics" },
+    { "reset_stats", main_reset_stats, nullptr, "clear summary statistics" },
     { "rotate_stats", main_rotate_stats, nullptr, "roll perfmonitor log files" },
     { "reload_config", main_reload_config, s_reload_w_path, "load new configuration" },
     { "reload_policy", main_reload_policy, s_reload, "reload part or all of the default policy" },
index 2cab9293dbee42035b2b8a99ce41c98f4782e986..9694d79518d3396c7c49c4b0e6f8af985fd4d516 100644 (file)
@@ -46,6 +46,7 @@
 #include "parser/parse_conf.h"
 #include "parser/parser.h"
 #include "profiler/profiler.h"
+#include "protocols/packet_manager.h"
 #include "utils/util.h"
 
 #include "plugin_manager.h"
@@ -1387,6 +1388,52 @@ void ModuleManager::reset_stats(SnortConfig*)
     }
 }
 
+void ModuleManager::reset_stats(clear_counter_type_t type)
+{
+    if ( type != TYPE_MODULE and type != TYPE_UNKNOWN )
+    {
+        ModHook* mh = get_hook(clear_counter_type_string_map[type]);
+        if ( mh and mh->mod )
+        {
+            lock_guard<mutex> lock(stats_mutex);
+            mh->mod->reset_stats();
+        }
+    
+    }
+    else
+    { 
+        auto mod_hooks = get_all_modhooks();
+        for ( auto* mh : mod_hooks )
+        {
+            bool ignore = false;
+
+            // FIXIT-M Will remove this for loop when will come up with more
+            //  granular form of clearing module stats.
+            for ( int i = 0; i < static_cast<int>(clear_counter_type_string_map.size()); i++ )
+            {
+                if ( !strcmp(mh->mod->get_name(), clear_counter_type_string_map[i]) )
+                {
+                    ignore = true;
+                    break;
+                }
+            }
+
+            if ( type == TYPE_UNKNOWN or !ignore )
+            {
+                lock_guard<mutex> lock(stats_mutex);
+                mh->mod->reset_stats();
+            }
+        }
+    }
+    if ( type == TYPE_DAQ or type == TYPE_UNKNOWN )
+    {
+        lock_guard<mutex> lock(stats_mutex);
+        PacketManager::reset_stats();
+    }
+}
+
+
+
 //-------------------------------------------------------------------------
 // parameter loading
 //-------------------------------------------------------------------------
index fc0d53b8d1d0496e129846c56a341df513305429..0a33a0fcb2daf7acc4215f67cf6212522ff5e116 100644 (file)
@@ -28,6 +28,7 @@
 #include <mutex>
 #include <set>
 
+#include "main/analyzer_command.h"
 #include "main/snort_types.h"
 
 //-------------------------------------------------------------------------
@@ -87,6 +88,7 @@ public:
     static void accumulate();
     static void accumulate_offload(const char* name);
     static void reset_stats(SnortConfig*);
+    static void reset_stats(clear_counter_type_t);
 
     static std::set<uint32_t> gids;
     SO_PUBLIC static std::mutex stats_mutex;
index 91809baaf75df49374fd63f94815bbf8c5b00a30..788875ec86657bc54a0e6a512d80f38d5c4ca20a 100644 (file)
@@ -540,6 +540,12 @@ void AppIdModule::show_dynamic_stats()
     AppIdPegCounts::print();
 }
 
+void AppIdModule::reset_stats()
+{
+    AppIdPegCounts::cleanup_dynamic_sum();
+    Module::reset_stats();
+}
+
 bool AppIdReloadTuner::tinit()
 {
     return AppIdServiceState::initialize(memcap);
index 68a6c363ac29a0bb3f3654382ca9b66852f3f574..4084444397f9c0b6061b63ebba4fa938a7d89a97 100644 (file)
@@ -88,6 +88,8 @@ public:
 
     const AppIdConfig* get_data();
 
+    void reset_stats() override;
+
     Usage get_usage() const override
     { return CONTEXT; }
     void sum_stats(bool) override;
index ec28957d8f03f34726f28fd637172a07529f66aa..1abfbfacdef0b3a6a0f6014c6c343f33d6a8ad01 100644 (file)
@@ -55,6 +55,20 @@ void AppIdPegCounts::cleanup_peg_info()
     appid_detector_pegs_idx.clear();
 }
 
+void AppIdPegCounts::cleanup_dynamic_sum()
+{
+    if ( !appid_peg_counts )
+        return;
+
+    for ( unsigned app_num = 0; app_num < AppIdPegCounts::appid_detectors_info.size(); app_num++ )
+    {
+        memset(appid_dynamic_sum[app_num].stats, 0, sizeof(PegCount) *
+            DetectorPegs::NUM_APPID_DETECTOR_PEGS);
+        memset((*appid_peg_counts)[app_num].stats, 0, sizeof(PegCount) *
+            DetectorPegs::NUM_APPID_DETECTOR_PEGS);
+    }
+}
+
 void AppIdPegCounts::add_app_peg_info(std::string app_name, AppId app_id)
 {
     std::replace(app_name.begin(), app_name.end(), ' ', '_');
@@ -68,7 +82,7 @@ void AppIdPegCounts::sum_stats()
     if (!appid_peg_counts)
         return;
 
-    const unsigned peg_num = appid_peg_counts->size() - 1;
+    const unsigned peg_num = appid_peg_counts->size() ? (appid_peg_counts->size() - 1) : 0;
     const AppIdDynamicPeg* ptr = (AppIdDynamicPeg*)appid_peg_counts->data();
 
     for ( unsigned i = 0; i < peg_num; ++i )
@@ -86,7 +100,7 @@ void AppIdPegCounts::update_service_count(AppId id, bool increment)
 {
     if (increment)
         (*appid_peg_counts)[get_stats_index(id)].stats[DetectorPegs::SERVICE_DETECTS]++;
-    else
+    else if ((*appid_peg_counts)[get_stats_index(id)].stats[DetectorPegs::SERVICE_DETECTS])
         (*appid_peg_counts)[get_stats_index(id)].stats[DetectorPegs::SERVICE_DETECTS]--;
 }
 
@@ -94,7 +108,7 @@ void AppIdPegCounts::update_client_count(AppId id, bool increment)
 {
     if (increment)
         (*appid_peg_counts)[get_stats_index(id)].stats[DetectorPegs::CLIENT_DETECTS]++;
-    else
+    else if ((*appid_peg_counts)[get_stats_index(id)].stats[DetectorPegs::CLIENT_DETECTS])
         (*appid_peg_counts)[get_stats_index(id)].stats[DetectorPegs::CLIENT_DETECTS]--;
 }
 
@@ -102,7 +116,7 @@ void AppIdPegCounts::update_payload_count(AppId id, bool increment)
 {
     if (increment)
         (*appid_peg_counts)[get_stats_index(id)].stats[DetectorPegs::PAYLOAD_DETECTS]++;
-    else
+    else if ((*appid_peg_counts)[get_stats_index(id)].stats[DetectorPegs::PAYLOAD_DETECTS])
         (*appid_peg_counts)[get_stats_index(id)].stats[DetectorPegs::PAYLOAD_DETECTS]--;
 }
 
index 2c0219abe5d1763c727f6d4b2485b0a96d781a2b..b77ae553b023672bbffb0e70be7cdf6ea984532a 100644 (file)
@@ -80,6 +80,7 @@ public:
     static void init_pegs();
     static void cleanup_pegs();
     static void cleanup_peg_info();
+    static void cleanup_dynamic_sum();
 
     static void update_service_count(AppId id, bool increment);
     static void update_client_count(AppId id, bool increment);
index 3d94c40f48ddd5947836d256208118c5d70c91ba..631d4af8d4e5bacf8eef981b39ca200cbae156a1 100644 (file)
@@ -75,6 +75,7 @@ int AppIdDiscovery::add_service_port(AppIdDetector*, ServiceDetectorPort const&)
 DnsPatternMatchers::~DnsPatternMatchers() { }
 SipPatternMatchers::~SipPatternMatchers() { }
 SslPatternMatchers::~SslPatternMatchers() { }
+void AppIdModule::reset_stats() {}
 
 TEST_GROUP(http_url_patterns_tests)
 {
index d581d8d9d27d594a5fa93d2b97d872eec502be71..465a768c97ba2329bc9a194c139d73675f25d392 100644 (file)
@@ -67,6 +67,8 @@ AppIdSessionApi::AppIdSessionApi(const AppIdSession*, const SfIp&) :
     StashGenericObject(STASH_GENERIC_OBJECT_APPID) {}
 }
 
+void AppIdModule::reset_stats() {}
+
 class DummyInspector : public snort::Inspector
 {
 public:
index 2f7491dd3ce4301789fe36943acb25400fc68389..f4e46aa2d27746e9674da80b73185c45938fe1a5 100644 (file)
@@ -49,6 +49,8 @@ void ApplicationDescriptor::set_id(
 
 void AppIdHttpSession::set_http_change_bits(AppidChangeBits&, HttpFieldIds) {}
 
+void AppIdModule::reset_stats() {}
+
 class TestDetector : public AppIdDetector
 {
 public:
index fd2d4ca33619f90123e41bd0f7ab8cef49f2c47b..d23faa2d69204a50d4dd007bd09375537f66b6fd 100644 (file)
@@ -108,6 +108,7 @@ void IpApi::set(const SfIp& sip, const SfIp& dip)
 AppIdSessionApi::AppIdSessionApi(const AppIdSession*, const SfIp&) :
     StashGenericObject(STASH_GENERIC_OBJECT_APPID) {}
 } // namespace snort
+void AppIdModule::reset_stats() {}
 
 // Stubs for publish
 void DataBus::publish(const char*, DataEvent& event, Flow*)
index 1ef7d05f5625045ca6bdffa5e07a07f61a6ca473..02809c2e15231b419c6d2c72bad2c21e382d75a3 100644 (file)
@@ -89,6 +89,7 @@ AppIdSession* AppIdSession::allocate_session(const Packet*, IpProtocol, AppidSes
 {
     return nullptr;
 }
+void AppIdModule::reset_stats() {}
 void AppIdSession::set_application_ids_service(AppId, AppidChangeBits&) {}
 void AppIdSession::set_ss_application_ids(AppId, AppId, AppId, AppId, AppId, AppidChangeBits&) {}
 AppIdHttpSession* AppIdSession::get_http_session(uint32_t stream_index) const
index c046bd0a0949c15e7801ad54946fb6ffe4df9bf3..b23f4e528d36abdcd168f74a825b1ce41a479d92 100644 (file)
@@ -145,6 +145,8 @@ bool AppIdSession::is_tp_appid_available() const
     return true;
 }
 
+void AppIdModule::reset_stats() {}
+
 // AppIdDebug mock functions
 void AppIdDebug::activate(const uint32_t*, const uint32_t*, uint16_t,
     uint16_t, IpProtocol, const int, uint16_t, const AppIdSession*, bool,
index 9c86bae12d020db5de4b400b4fa8c685f1f31556..9e7e0ad821955b8f364af14cf37d307c00a2363f 100644 (file)
@@ -37,6 +37,7 @@ static OdpContext odpctxt(config, nullptr);
 static Flow flow;
 
 void ApplicationDescriptor::set_id(const Packet&, AppIdSession&, AppidSessionDirection, AppId, AppidChangeBits&) { }
+void AppIdModule::reset_stats() {}
 
 Inspector* InspectorManager::get_inspector(char const*, bool, const snort::SnortConfig*)
 {
index 119640ac8a26e0d9f6788cbe07a5ee038d887e13..db27ba1d129f65641e20a9b9d8333febb49caed2 100644 (file)
@@ -258,3 +258,8 @@ void SFDAQModule::prep_counts()
     prev_daq_stats = new_daq_stats;
 }
 
+void SFDAQModule::reset_stats()
+{
+    Trough::clear_file_count();
+    Module::reset_stats();
+}
index 736947bb07a27a434e4cf14550c72df8e2859a63..4c236eb626c35770ff59c89bf109341d06a51811 100644 (file)
@@ -42,6 +42,7 @@ public:
     const PegInfo* get_pegs() const override;
     PegCount* get_counts() const override;
     void prep_counts() override;
+    void reset_stats() override;
 
     bool counts_need_prep() const override
     { return true; }
index e5f5c255942fcb73213a85f267354f013415fd9e..60f674b7956c8ec8afb97fa2bc118213f96e6e12 100644 (file)
@@ -48,6 +48,10 @@ public:
     {
         return file_count;
     }
+    static void clear_file_count()
+    {
+        file_count = 0;
+    }
     static unsigned get_queue_size()
     {
         return pcap_queue.size();
index f5450bfb1463cc356f6447b7275d9eb2be81e19a..843260338e52c75e044f281c3ae70862bba01979 100644 (file)
@@ -882,6 +882,12 @@ void PacketManager::dump_stats()
         (unsigned int)pkt_names.size(), "codec");
 }
 
+void PacketManager::reset_stats()
+{
+    std::fill(std::begin(g_stats), std::end(g_stats), 0);
+    std::fill(std::begin(s_stats), std::end(s_stats), 0);
+}
+
 void PacketManager::accumulate()
 {
     static std::mutex stats_mutex;
index fd9806e41e5b91981c40f6ee92d90f1d23610f70..c9b395ddcb5ef205cc2f4f9f9254f59190772bd0 100644 (file)
@@ -109,6 +109,8 @@ public:
     // print codec information.  MUST be called after thread_term.
     static void dump_stats();
 
+    static void reset_stats();
+
     // Get the name of the given protocol ID
     static const char* get_proto_name(ProtocolId);
 
index 2de2a211bf1acf97f990ede99f989e5bca60fa07..df1e7dbae81bdeb4941e74feea53bb6306d13507 100644 (file)
@@ -113,7 +113,7 @@ void base_sum()
 {
     sum_stats((PegCount*)&g_stats, (PegCount*)&stream_base_stats,
         array_size(base_pegs) - 1);
-    base_reset();
+    base_reset(false);
 }
 
 void base_stats()
@@ -121,12 +121,23 @@ void base_stats()
     show_stats((PegCount*)&g_stats, base_pegs, array_size(base_pegs) - 1, MOD_NAME);
 }
 
-void base_reset()
+void base_reset(bool reset_all)
 {
     if ( flow_con )
         flow_con->clear_counts();
 
     memset(&stream_base_stats, 0, sizeof(stream_base_stats));
+
+    if ( reset_all )
+    {
+        if ( flow_con )
+        {
+            ExpectCache* exp_cache = flow_con->get_exp_cache();
+            if ( exp_cache )
+                exp_cache->reset_stats();
+        }
+        memset(&g_stats, 0, sizeof(g_stats));
+    }
 }
 
 //-------------------------------------------------------------------------
index a789bc5a0279c295ac0ecbfc2fade9a8444bbfda..5979f73f48bc8a359d64366adcceec2201b65de2 100644 (file)
@@ -168,6 +168,6 @@ private:
 extern void base_prep();
 extern void base_sum();
 extern void base_stats();
-extern void base_reset();
+extern void base_reset(bool reset_all=true);
 
 #endif
index d1642490cc76546592697f7fba4524ab118e293b..18b9dad8d61e26f1e868e0ea87295b09c7426999 100644 (file)
@@ -23,6 +23,7 @@
 #endif
 
 #include "tcp_module.h"
+#include "tcp_normalizer.h"
 
 #include "main/snort_config.h"
 #include "profiler/profiler_defs.h"
@@ -380,3 +381,8 @@ const PegInfo* StreamTcpModule::get_pegs() const
 PegCount* StreamTcpModule::get_counts() const
 { return (PegCount*)&tcpStats; }
 
+void StreamTcpModule::reset_stats()
+{
+    TcpNormalizer::reset_stats();
+    Module::reset_stats();
+}
index 9fd3d7a7d53bd8c9f6a9ed4767ae0c21d8f9d281..39693dd6d5c2d5ccfb357cc0276ffee60922e70d 100644 (file)
@@ -131,6 +131,8 @@ public:
 
     const snort::RuleMap* get_rules() const override;
 
+    void reset_stats() override;
+
     unsigned get_gid() const override
     { return GID_STREAM_TCP; }
 
index cb6d0278ac3f2018474290bfc63f906664b0bcf0..fe7f33e30fe2c7a553806bb1442c840dfafca22f 100644 (file)
@@ -422,3 +422,9 @@ uint16_t TcpNormalizer::set_urg_offset(
     return urg_offset;
 }
 
+void TcpNormalizer::reset_stats()
+{
+    for (int i = 0; i < PC_TCP_MAX; i++)
+        for (int j = 0; j < NORM_MODE_MAX; j++)
+            tcp_norm_stats[i][j] = 0;
+}
index 0ad6b8d6b5a02aa774ae6d0a00e68e6380626507..b5caa335e091a7a085fb8f9c703497c4dad02dce 100644 (file)
@@ -94,6 +94,7 @@ public:
 
     static const PegInfo* get_normalization_pegs();
     static NormPegs get_normalization_counts(unsigned&);
+    static void reset_stats();
 
 protected:
     TcpNormalizer() = default;