]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1858 in SNORT/snort3 from ~DAVMCPHE/snort3:reload_idle_tuning...
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Mon, 9 Dec 2019 13:22:29 +0000 (13:22 +0000)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Mon, 9 Dec 2019 13:22:29 +0000 (13:22 +0000)
Squashed commit of the following:

commit bac1de7f1bdc9aa14db71457e39932c27768c43e
Author: davis mcpherson <davmcphe@cisco.com>
Date:   Fri Nov 22 09:07:13 2019 -0500

    reload: fix issue where resource tuning was not being called when in idle context

src/flow/prune_stats.h
src/main/analyzer.cc
src/main/analyzer.h
src/main/analyzer_command.cc
src/stream/base/stream_base.cc
src/stream/base/stream_module.cc
src/stream/base/stream_module.h

index 1015f4695d1850f58d1fd1f73dd46b8bae14b45a..ab4cacd2fcad8836666b00ba7c63f5951bb51852 100644 (file)
@@ -82,7 +82,7 @@ struct FlowDeleteStats
     PegCount get_total() const
     {
         PegCount total = 0;
-        for ( state_t i = 0; i < static_cast<state_t>(PruneReason::MAX); ++i )
+        for ( state_t i = 0; i < static_cast<state_t>(FlowDeleteState::MAX); ++i )
             total += deletes[i];
 
         return total;
index 5d5eb2be44137dd9f9ae96c772d46841ceca6399..c06d2714eb916f199354ac54a7039f33ac87ec89 100644 (file)
@@ -535,6 +535,8 @@ const char* Analyzer::get_state_string()
 
 void Analyzer::idle()
 {
+    idling = true;
+
     // FIXIT-L this whole thing could be pub-sub
     daq_stats.idle++;
 
@@ -555,6 +557,10 @@ void Analyzer::idle()
     Stream::timeout_flows(packet_time());
 
     HighAvailabilityManager::process_receive();
+
+    handle_uncompleted_commands();
+
+    idling = false;
 }
 
 /*
index b15f4ade77090e2edb64ba28afd50aaeb3c079a3..77c1fad88abac1104f65864a7079746f49b2e27d 100644 (file)
@@ -108,6 +108,9 @@ public:
     void rotate();
     snort::SFDAQInstance* get_daq_instance() { return daq_instance; }
 
+    bool is_idling() const
+    { return idling; }
+
 private:
     void analyze();
     bool handle_command();
@@ -136,6 +139,7 @@ private:
     std::atomic<State> state;
     unsigned id;
     bool exit_requested = false;
+    bool idling = false;
     uint64_t exit_after_cnt;
     uint64_t pause_after_cnt = 0;
     uint64_t skip_cnt = 0;
index ee9170afd498606fe6b343b398f2b87eff7d0a1d..8bad70d9b5803f21267c8292f30ff80de500cbf3 100644 (file)
@@ -129,8 +129,16 @@ bool ACSwap::execute(Analyzer& analyzer, void** ac_state)
             if ( !reload_tuners->empty() )
             {
                 auto rrt = reload_tuners->front();
-                if ( rrt->tune_packet_context() )
-                    reload_tuners->pop_front();
+                if ( analyzer.is_idling() )
+                {
+                    if ( rrt->tune_idle_context() )
+                        reload_tuners->pop_front();
+                }
+                else
+                {
+                    if ( rrt->tune_packet_context() )
+                        reload_tuners->pop_front();
+                }
             }
 
             // check for empty again and free list instance if we are done
index 2b1c08f50d81c4e16ec6f325b7e4b98e6c63c293..7bc89e1931ff1c810e64a6c7782d1e106935fb79 100644 (file)
@@ -65,6 +65,8 @@ const PegInfo base_pegs[] =
     { CountType::SUM, "expected_realized", "number of expected flows realized" },
     { CountType::SUM, "expected_pruned", "number of expected flows pruned" },
     { CountType::SUM, "expected_overflows", "number of expected cache overflows" },
+    { CountType::SUM, "reload_tuning_idle", "number of times stream resource tuner called while idle" },
+    { CountType::SUM, "reload_tuning_packets", "number of times stream resource tuner called while processing packets" },
     { CountType::SUM, "reload_total_adds", "number of flows added by config reloads" },
     { CountType::SUM, "reload_total_deletes", "number of flows deleted by config reloads" },
     { CountType::SUM, "reload_freelist_deletes", "number of flows deleted from the free list by config reloads" },
@@ -103,13 +105,13 @@ void base_sum()
     }
 
     sum_stats((PegCount*)&g_stats, (PegCount*)&stream_base_stats,
-        array_size(base_pegs)-1);
+        array_size(base_pegs) - 1);
     base_reset();
 }
 
 void base_stats()
 {
-    show_stats((PegCount*)&g_stats, base_pegs, array_size(base_pegs)-1, MOD_NAME);
+    show_stats((PegCount*)&g_stats, base_pegs, array_size(base_pegs) - 1, MOD_NAME);
 }
 
 void base_reset()
index 4eb969c7a7201bc21a74968b8eeb8617f3c29449..09e3ae375fdbd11ca58cdd0e8b318b577c03c897 100644 (file)
@@ -238,11 +238,13 @@ bool StreamReloadResourceManager::tinit()
 
 bool StreamReloadResourceManager::tune_packet_context()
 {
+    ++stream_base_stats.reload_tuning_packets;
     return tune_resources(max_work);
 }
 
 bool StreamReloadResourceManager::tune_idle_context()
 {
+    ++stream_base_stats.reload_tuning_idle;
     return tune_resources(max_work_idle);
 }
 
index c6d3e1128a6f9d0c2f6fd2583d86f1b61700d880..dd212b228bcff6c4c6cbf798c853a6a257867ea2 100644 (file)
@@ -57,6 +57,8 @@ struct BaseStats
      PegCount expected_realized;
      PegCount expected_pruned;
      PegCount expected_overflows;
+     PegCount reload_tuning_idle;
+     PegCount reload_tuning_packets;
      PegCount reload_total_adds;
      PegCount reload_total_deletes;
      PegCount reload_freelist_flow_deletes;