]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1628 in SNORT/snort3 from ~BBANTWAL/snort3:pegcounts to master
authorRuss Combs (rucombs) <rucombs@cisco.com>
Sun, 16 Jun 2019 14:59:35 +0000 (10:59 -0400)
committerRuss Combs (rucombs) <rucombs@cisco.com>
Sun, 16 Jun 2019 14:59:35 +0000 (10:59 -0400)
Squashed commit of the following:

commit 46120f09f1374a79a945dcf8c14bcdaf70a16c8c
Author: Bhagya Tholpady <bbantwal@cisco.com>
Date:   Tue Jun 11 10:15:18 2019 -0400

    adding stats for offloader busy

commit 98821ce7200c8f1fd72476e264bc4f782a74dfd6
Author: Bhagya Tholpady <bbantwal@cisco.com>
Date:   Tue Jun 4 12:41:48 2019 -0400

    adding pegcounts for context chain suspends

commit b71215b8870e26706d2a93336dcb2be03f4012a7
Author: Bhagya Tholpady <bbantwal@cisco.com>
Date:   Tue Jun 4 09:53:47 2019 -0400

    detection: adding pegcounts for fallback, offload failures

commit 1ad6aa682e0d3f6faf9fb91256f322c089f754d9
Author: russ <rucombs@cisco.com>
Date:   Sat Jun 1 15:54:10 2019 -0400

    detection: add peg for onload wait conditions

src/detection/detection_engine.cc
src/detection/regex_offload.cc
src/utils/stats.cc
src/utils/stats.h

index 3c3bf1436c6e1566dce53d9e864dc0f4a690d9bb..5fa4dcf7f88bd67e4b9b06ed5ce3ede0d2f3e6f7 100644 (file)
@@ -399,6 +399,7 @@ bool DetectionEngine::do_offload(Packet* p)
         else
         {
             sw->suspend();
+            pc.offload_suspends++;
             return true;
         }
     }
@@ -408,13 +409,17 @@ bool DetectionEngine::offload(Packet* p)
 {
     ContextSwitcher* sw = Analyzer::get_switcher();
 
-    bool depends_on_suspended = p->flow ? p->flow->context_chain.front() : sw->non_flow_chain.front();
-    bool can_offload = offloader->available();
+    bool depends_on_suspended = 
+        p->flow ? p->flow->context_chain.front() : sw->non_flow_chain.front();
+
     bool should_offload = p->dsize >= SnortConfig::get_conf()->offload_limit;
 
-    if ( can_offload and should_offload )
+    if ( should_offload )
     {
-        return do_offload(p);
+        if ( offloader->available() )
+            return do_offload(p);
+
+        pc.offload_busy++;
     }
 
     if ( depends_on_suspended )
@@ -422,6 +427,7 @@ bool DetectionEngine::offload(Packet* p)
         fp_partial(p);
         p->context->searches.search_sync();
         sw->suspend();
+        pc.offload_suspends++;
         return true;
     }
 
@@ -450,6 +456,9 @@ void DetectionEngine::idle()
 
 void DetectionEngine::onload(Flow* flow)
 {
+    if ( flow->is_suspended() )
+        pc.onload_waits++;
+
     while ( flow->is_suspended() )
     {
         trace_logf(detection,
index 9a426453db7c46ad62b5a6137577c1a423c371a0..8bea6ca57764650aba25066a57dd8e3f70063738 100644 (file)
@@ -39,6 +39,9 @@
 #include "latency/rule_latency.h"
 #include "main/snort_config.h"
 #include "managers/module_manager.h"
+#include "utils/stats.h"
+
+using namespace snort;
 
 // FIXIT-L this could be offloader specific
 struct RegexRequest
@@ -137,10 +140,10 @@ bool MpseRegexOffload::get(snort::Packet*& p)
         {
             if (batch->can_fallback())
             {
-                // FIXIT-M Add peg counts to record offload search fallback attempts
                 batch->search_sync();
+                pc.offload_fallback++;
             }
-            // FIXIT-M else Add peg counts to record offload search failures
+            pc.offload_failures++;
         }
 
         snort::IpsContext* c = (snort::IpsContext*)(batch->context);
@@ -276,16 +279,17 @@ void ThreadRegexOffload::worker(RegexRequest* req, snort::SnortConfig* initial_c
         {
             if (c->searches.can_fallback())
             {
-                // FIXIT-M Add peg counts to record offload search fallback attempts
                 c->searches.search_sync();
+                pc.offload_fallback++;
             }
-            // FIXIT-M else Add peg counts to record offload search failures
+            pc.offload_failures++;
         }
 
         c->searches.items.clear();
         req->offload = false;
     }
     snort::ModuleManager::accumulate_offload("search_engine");
+    snort::ModuleManager::accumulate_offload("detection");
 
     // FIXIT-M break this over-coupling. In reality we shouldn't be evaluating latency in offload.
     PacketLatency::tterm();
index ca6a22ac14ced9d9f497e7c740b037464d9f6f0a..0bd4f972ba427e2ec45155015c31c79170e42150 100644 (file)
@@ -190,6 +190,11 @@ const PegInfo pc_names[] =
     { CountType::SUM, "event_limit", "events filtered" },
     { CountType::SUM, "alert_limit", "events previously triggered on same PDU" },
     { CountType::SUM, "context_stalls", "times processing stalled to wait for an available context" },
+    { CountType::SUM, "offload_busy", "times offload was not available" },
+    { CountType::SUM, "onload_waits", "times processing waited for onload to complete" },
+    { CountType::SUM, "offload_fallback", "fast pattern offload search fallback attempts" },
+    { CountType::SUM, "offload_failures", "fast pattern offload search failures" },
+    { CountType::SUM, "offload_suspends", "fast pattern search suspends due to offload context chains" },
     { CountType::END, nullptr, nullptr }
 };
 
index 24a66f5402d240cbeb64399b1b4d0f21e817ed5d..6e24ccaeeb26241b290e785f7f7b23be03ecfe64 100644 (file)
@@ -55,6 +55,11 @@ struct PacketCount
     PegCount event_limit;
     PegCount alert_limit;
     PegCount context_stalls;
+    PegCount offload_busy;
+    PegCount onload_waits;
+    PegCount offload_fallback;
+    PegCount offload_failures;
+    PegCount offload_suspends;
 };
 
 struct ProcessCount