]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2878 in SNORT/snort3 from ~DIPANDIT/snort3:thread_wise_resume...
authorBhargava Jandhyala (bjandhya) <bjandhya@cisco.com>
Wed, 26 May 2021 20:41:01 +0000 (20:41 +0000)
committerBhargava Jandhyala (bjandhya) <bjandhya@cisco.com>
Wed, 26 May 2021 20:41:01 +0000 (20:41 +0000)
Squashed commit of the following:

commit 30f9f9897dd34aba4a6743c499cbf0dea39dda5f
Author: Dipto Pandit (dipandit) <dipandit@cisco.com>
Date:   Fri May 7 06:39:14 2021 -0400

    main: added support for resuming particular thread

src/main.cc
src/main/analyzer_command.h

index 3c26a0a1df01a1bb3a60387250551b4f45b3931b..cc9a9c43e16deabbf2d731a6c4e6457e9eb5bf40 100644 (file)
@@ -312,6 +312,16 @@ void snort::main_broadcast_command(AnalyzerCommand* ac, bool from_shell)
         orphan_commands.push(ac);
 }
 
+#ifdef REG_TEST
+void snort::main_unicast_command(AnalyzerCommand* ac, unsigned target, bool from_shell)
+{
+    assert(target < max_pigs);
+    ac = get_command(ac, from_shell);
+    if (!pigs[target].queue_command(ac))
+        orphan_commands.push(ac);
+}
+#endif
+
 int main_dump_stats(lua_State* L)
 {
     bool from_shell = ( L != nullptr );
@@ -618,6 +628,11 @@ int main_resume(lua_State* L)
 {
     bool from_shell = ( L != nullptr );
     uint64_t pkt_num = 0;
+
+    #ifdef REG_TEST
+    int target = -1;
+    #endif
+
     if (from_shell)
     {
         const int num_of_args = lua_gettop(L);
@@ -629,10 +644,30 @@ int main_resume(lua_State* L)
                 current_request->respond("Invalid usage of resume(n), n should be a number > 0\n");
                 return 0;
             }
+            #ifdef REG_TEST
+            if (num_of_args > 1)
+            {
+                target = lua_tointeger(L, 2);
+                if (target < 0 or unsigned(target) >= max_pigs)
+                {
+                    current_request->respond(
+                        "Invalid usage of resume(n,m), m should be a number >= 0 and less than number of threads\n");
+                    return 0;
+                }
+            }
+            #endif
         }
     }
     current_request->respond("== resuming\n", from_shell);
+
+    #ifdef REG_TEST
+    if (target >= 0)
+        main_unicast_command(new ACResume(pkt_num), target, from_shell);
+    else
+        main_broadcast_command(new ACResume(pkt_num), from_shell);
+    #else
     main_broadcast_command(new ACResume(pkt_num), from_shell);
+    #endif
     paused = false;
     return 0;
 }
index 0a326d890638d309b2d249a248fa4803201dab01..4b2c5a5764bc6462b2b08717db063c491455e7b0 100644 (file)
@@ -175,6 +175,9 @@ namespace snort
 {
 // from main.cc
 SO_PUBLIC void main_broadcast_command(snort::AnalyzerCommand* ac, bool from_shell = false);
+#ifdef REG_TEST
+void main_unicast_command(AnalyzerCommand* ac, unsigned target, bool from_shell = false);
+#endif
 }
 
 #endif