From: Bhargava Jandhyala (bjandhya) Date: Wed, 26 May 2021 20:41:01 +0000 (+0000) Subject: Merge pull request #2878 in SNORT/snort3 from ~DIPANDIT/snort3:thread_wise_resume... X-Git-Tag: 3.1.6.0~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a10fa47e902ab8431a37216e09a65958012b660;p=thirdparty%2Fsnort3.git Merge pull request #2878 in SNORT/snort3 from ~DIPANDIT/snort3:thread_wise_resume to master Squashed commit of the following: commit 30f9f9897dd34aba4a6743c499cbf0dea39dda5f Author: Dipto Pandit (dipandit) Date: Fri May 7 06:39:14 2021 -0400 main: added support for resuming particular thread --- diff --git a/src/main.cc b/src/main.cc index 3c26a0a1d..cc9a9c43e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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; } diff --git a/src/main/analyzer_command.h b/src/main/analyzer_command.h index 0a326d890..4b2c5a576 100644 --- a/src/main/analyzer_command.h +++ b/src/main/analyzer_command.h @@ -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