]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1932 in SNORT/snort3 from ~SHRARANG/snort3:appid_tp_reload_config...
authorShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Wed, 15 Jan 2020 19:14:05 +0000 (19:14 +0000)
committerShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Wed, 15 Jan 2020 19:14:05 +0000 (19:14 +0000)
Squashed commit of the following:

commit ce792e96a5d6abf2d1804c90e738487061616700
Author: Shravan Rangaraju <shrarang@cisco.com>
Date:   Fri Jan 10 11:26:32 2020 -0500

    appid: do not reload third party on reload_config

src/network_inspectors/appid/appid_config.cc
src/network_inspectors/appid/appid_config.h
src/network_inspectors/appid/appid_module.cc
src/network_inspectors/appid/test/tp_lib_handler_test.cc
src/network_inspectors/appid/tp_lib_handler.cc

index bcb30d193a4cd2d82c38f9d2ef85b5099c4d77af..83a15e6809d96580a71868665201043ffdef1126 100644 (file)
@@ -66,6 +66,10 @@ SnortProtocolId snortId_for_unsynchronized;
 SnortProtocolId snortId_for_ftp_data;
 SnortProtocolId snortId_for_http2;
 
+#ifdef ENABLE_APPID_THIRD_PARTY
+ThirdPartyAppIdContext* AppIdContext::tp_appid_ctxt = nullptr;
+#endif
+
 static void map_app_names_to_snort_ids(SnortConfig* sc)
 {
     /* init globals for snortId compares */
index 56b2aa233057303238940b95449fc7bff81ac439..0e19f651eb5cbbf3407284744849ae155ba7e286 100644 (file)
@@ -101,17 +101,15 @@ public:
     AppIdContext(AppIdConfig* config) : config(config)
     { }
 
-    ~AppIdContext()
-    {
-#ifdef ENABLE_APPID_THIRD_PARTY
-        delete tp_appid_ctxt;
-#endif
-    }
+    ~AppIdContext() { }
 
 #ifdef ENABLE_APPID_THIRD_PARTY
     ThirdPartyAppIdContext* get_tp_appid_ctxt() const
     { return tp_appid_ctxt; }
 
+    static void delete_tp_appid_ctxt()
+    { delete tp_appid_ctxt; }
+
     void create_tp_appid_ctxt();
 #endif
 
@@ -137,7 +135,7 @@ private:
     // removed from AppIdContext::pterm
     static AppInfoManager& app_info_mgr;
 #ifdef ENABLE_APPID_THIRD_PARTY
-    ThirdPartyAppIdContext* tp_appid_ctxt = nullptr;
+    static ThirdPartyAppIdContext* tp_appid_ctxt;
 #endif
 };
 
index 35fa39faed3c1566ad979f798f2de589f8753f0c..b554aa801dee0ab838de247bf0a5344565d6bf72 100644 (file)
@@ -184,11 +184,12 @@ static int reload_third_party(lua_State*)
     else
     {
         Swapper::set_reload_in_progress(true);
-        LogMessage(".. reloading third-party");
+        LogMessage(".. reloading third-party\n");
         AppIdInspector* inspector = (AppIdInspector*) InspectorManager::get_inspector(MOD_NAME, true);
         AppIdContext* ctxt = inspector->get_ctxt();
         ctxt->create_tp_appid_ctxt();
         Swapper::set_reload_in_progress(false);
+        LogMessage("== reload third-party complete\n");
     }
 #else
     LogMessage("== third party is not enabled\n");
index c484c2464ef53698fb7fdaa32673e94aaa0c9065..2a64ce7246db41a4aa9992b97425474107f3c7ab 100644 (file)
@@ -39,6 +39,10 @@ using namespace std;
 
 TPLibHandler* tph = nullptr;
 
+#ifdef ENABLE_APPID_THIRD_PARTY
+ThirdPartyAppIdContext* AppIdContext::tp_appid_ctxt = nullptr;
+#endif
+
 AppIdConfig::~AppIdConfig() { }
 
 TEST_GROUP(tp_lib_handler)
index 490cb797ef5e2906005faaf9a0faa218afd68a4f..2bc8e6856b9a916945c46964b2b15211d882a38d 100644 (file)
@@ -157,6 +157,8 @@ void TPLibHandler::pfini()
     if (ret != 0)
         ErrorMessage("Could not terminate 3rd party AppID module (%d)!\n", ret);
 
+    AppIdContext::delete_tp_appid_ctxt();
+
     // FIXIT-L: Find the right place to dlclose self->tp_so_handle. dlclose here was causing
     // segfault