]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1553 in SNORT/snort3 from ~BBANTWAL/snort3:offload_stats to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 21 Mar 2019 23:33:46 +0000 (19:33 -0400)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Thu, 21 Mar 2019 23:33:46 +0000 (19:33 -0400)
Squashed commit of the following:

commit a94be253698a7f9a43a4f59f51c21e030254e68c
Author: Bhagya Tholpady <bbantwal@cisco.com>
Date:   Mon Mar 18 21:02:50 2019 -0400

    fix stats for thread

src/detection/regex_offload.cc
src/managers/module_manager.cc
src/managers/module_manager.h

index 71ad8c1864e8c8ff32b964f69edf9a306d30e052..52def1566fc7866af06e4a86f904e4c11dcb7eb5 100644 (file)
@@ -38,6 +38,7 @@
 #include "latency/packet_latency.h"
 #include "latency/rule_latency.h"
 #include "main/snort_config.h"
+#include "managers/module_manager.h"
 
 // FIXIT-L this could be offloader specific
 struct RegexRequest
@@ -136,7 +137,7 @@ bool MpseRegexOffload::get(snort::Packet*& p)
 
             else if (resp_ret == snort::Mpse::MPSE_RESP_COMPLETE_FAIL)
             {
-                if (!c->searches.can_fallback())
+                if (c->searches.can_fallback())
                 {
                     // FIXIT-M Add peg counts to record offload search fallback attempts
                     c->searches.search_sync();
@@ -271,7 +272,7 @@ void ThreadRegexOffload::worker(RegexRequest* req, snort::SnortConfig* initial_c
 
         if (resp_ret == snort::Mpse::MPSE_RESP_COMPLETE_FAIL)
         {
-            if (!batch.can_fallback())
+            if (batch.can_fallback())
             {
                 // FIXIT-M Add peg counts to record offload search fallback attempts
                 batch.search_sync();
@@ -282,6 +283,7 @@ void ThreadRegexOffload::worker(RegexRequest* req, snort::SnortConfig* initial_c
         batch.items.clear();
         req->offload = false;
     }
+    snort::ModuleManager::accumulate_offload("search_engine");
 
     // FIXIT-M break this over-coupling. In reality we shouldn't be evaluating latency in offload.
     PacketLatency::tterm();
index 24734724ee3a8fb968b816298532dbdcad01f154..166d316971c8ccabd2a36d3a87abe381b9aa5f2b 100644 (file)
@@ -1449,6 +1449,18 @@ void ModuleManager::accumulate(SnortConfig*)
     std::lock_guard<std::mutex> lock(stats_mutex);
 }
 
+void ModuleManager::accumulate_offload(const char* name)
+{
+    ModHook* p = get_hook(name);
+    if ( p )
+    {
+        std::lock_guard<std::mutex> lock(stats_mutex);
+        p->mod->prep_counts();
+        p->mod->sum_stats(true);
+    }
+    std::lock_guard<std::mutex> lock(stats_mutex);
+}
+
 void ModuleManager::reset_stats(SnortConfig*)
 {
     for ( auto p : s_modules )
index 6fd633541fde3c4ea677a12383144a67a4fd0225..345736e7797cc06cd317a04e7373d04ec90ec347 100644 (file)
@@ -80,6 +80,7 @@ public:
     static void dump_stats(SnortConfig*, const char* skip = nullptr, bool dynamic = false);
  
     static void accumulate(SnortConfig*);
+    static void accumulate_offload(const char* name);
     static void reset_stats(SnortConfig*);
 
     static std::set<uint32_t> gids;