]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2688 in SNORT/snort3 from ~SATHIRKA/snort3:navl_conn_destroy_core...
authorShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Mon, 11 Jan 2021 21:19:32 +0000 (21:19 +0000)
committerShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Mon, 11 Jan 2021 21:19:32 +0000 (21:19 +0000)
Squashed commit of the following:

commit 8f96caf9be67da55952502cee1e0822a72ec64c9
Author: Sreeja Athirkandathil Narayanan <sathirka@cisco.com>
Date:   Wed Jan 6 10:40:59 2021 -0500

    appid: tear down third-party when appid gets disabled

src/network_inspectors/appid/appid_inspector.cc
src/network_inspectors/appid/appid_inspector.h
src/network_inspectors/appid/appid_module.cc
src/network_inspectors/appid/appid_module.h
src/network_inspectors/appid/test/appid_discovery_test.cc
src/network_inspectors/appid/test/appid_mock_inspector.h
src/network_inspectors/appid/test/tp_mock.cc
src/network_inspectors/appid/tp_appid_module_api.h

index 238a45bb0cc4bab3f592e2c4a3f869a7aaed84e6..5727db7bc698a58a1ffda54d590a01436c70bd7f 100644 (file)
@@ -28,6 +28,7 @@
 #include <openssl/crypto.h>
 
 #include "flow/flow.h"
+#include "main/analyzer_command.h"
 #include "managers/inspector_manager.h"
 #include "managers/module_manager.h"
 #include "packet_tracer/packet_tracer.h"
@@ -178,6 +179,11 @@ void AppIdInspector::tterm()
         AppIdHAManager::tterm();
 }
 
+void AppIdInspector::tear_down(SnortConfig*)
+{
+    main_broadcast_command(new ACThirdPartyAppIdCleanup(), true);
+}
+
 void AppIdInspector::eval(Packet* p)
 {
     Profile profile(appid_perf_stats);
index 0f9d327b6f7e4422bd30bcc401f910f7a935c260..dc0e373baa91e8f051e5b0cd267fa464767759e1 100644 (file)
@@ -45,6 +45,7 @@ public:
     void show(const snort::SnortConfig*) const override;
     void tinit() override;
     void tterm() override;
+    void tear_down(snort::SnortConfig*) override;
     void eval(snort::Packet*) override;
     AppIdContext& get_ctxt() const;
 
index ee7cd5062701663e5f28dfa7024479ebb1657372..4ce78cd0e1f21b80b850c7aec0b0f62310bee565 100644 (file)
@@ -127,6 +127,18 @@ bool AcAppIdDebug::execute(Analyzer&, void**)
     return true;
 }
 
+bool ACThirdPartyAppIdCleanup::execute(Analyzer& a, void**)
+{
+    if (!pkt_thread_tp_appid_ctxt)
+        return true;
+    bool tear_down_in_progress;
+    if (a.is_idling())
+        tear_down_in_progress = pkt_thread_tp_appid_ctxt->tfini(true);
+    else
+        tear_down_in_progress = pkt_thread_tp_appid_ctxt->tfini();
+    return !tear_down_in_progress;
+}
+
 class ACThirdPartyAppIdContextSwap : public AnalyzerCommand
 {
 public:
@@ -182,9 +194,9 @@ bool ACThirdPartyAppIdContextUnload::execute(Analyzer& ac, void**)
     ThirdPartyAppIdContext::set_tp_reload_in_progress(true);
     bool reload_in_progress;
     if (ac.is_idling())
-        reload_in_progress = pkt_thread_tp_appid_ctxt->tfini(true, true);
-    else
         reload_in_progress = pkt_thread_tp_appid_ctxt->tfini(true);
+    else
+        reload_in_progress = pkt_thread_tp_appid_ctxt->tfini();
     if (reload_in_progress)
         return false;
     pkt_thread_tp_appid_ctxt = nullptr;
index df3afa24b3d0b467e95c24101f8a384c422ad2cf..68a6c363ac29a0bb3f3654382ca9b66852f3f574 100644 (file)
@@ -26,6 +26,8 @@
 #include <vector>
 
 #include "framework/module.h"
+#include "main/analyzer.h"
+#include "main/analyzer_command.h"
 #include "main/snort_config.h"
 
 #include "appid_config.h"
@@ -98,4 +100,11 @@ private:
     AppIdConfig* config;
 };
 
+class ACThirdPartyAppIdCleanup : public snort::AnalyzerCommand
+{
+public:
+    bool execute(Analyzer&, void**) override;
+    const char* stringify() override { return "THIRD_PARTY_APPID_CLEANUP"; }
+};
+
 #endif
index 919cbff5b6fca521303dcc2c47d892d9546326ac..eff65cbf241a291948e3b48d51ff0f2de67142c6 100644 (file)
@@ -177,6 +177,7 @@ bool AppIdInspector::configure(SnortConfig*) { return true; }
 void AppIdInspector::show(const SnortConfig*) const { }
 void AppIdInspector::tinit() { }
 void AppIdInspector::tterm() { }
+void AppIdInspector::tear_down(SnortConfig*) { }
 AppIdContext& AppIdInspector::get_ctxt() const
 {
     assert(ctxt);
index e3213948bce108e667bb5176cd567a0d66e5b07b..328ccb598d17e2da5fb6272625021b8d252aa166 100644 (file)
@@ -66,6 +66,7 @@ bool AppIdInspector::configure(snort::SnortConfig*) { return true; }
 void AppIdInspector::show(const SnortConfig*) const { }
 void AppIdInspector::tinit() { }
 void AppIdInspector::tterm() { }
+void AppIdInspector::tear_down(snort::SnortConfig*) { }
 AppIdContext& AppIdInspector::get_ctxt() const { return *ctxt; }
 
 AppIdModule appid_mod;
index d3c7830177d5dd404bda4c7708d44528b7b4a408..2519b111a9dee84a4f759a99ac2552623b88d88a 100644 (file)
@@ -56,7 +56,7 @@ public:
     }
 
     int tinit() override { return 0; }
-    bool tfini(bool, bool) override { return false; }
+    bool tfini(bool) override { return false; }
     const string& get_user_config() const override { return user_config; }
 
 private:
index 4cab3143af227759f55afd85a5f06eee7696d30f..af7cbe85fc58f34d386cbadbc35975291b679186 100644 (file)
@@ -60,7 +60,7 @@ public:
     const std::string& module_name() const { return name; }
 
     virtual int tinit() = 0;
-    virtual bool tfini(bool reload = false, bool is_idling = false) = 0;
+    virtual bool tfini(bool is_idling = false) = 0;
 
     virtual const ThirdPartyConfig& get_config() const { return cfg; }