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
#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"
AppIdHAManager::tterm();
}
+void AppIdInspector::tear_down(SnortConfig*)
+{
+ main_broadcast_command(new ACThirdPartyAppIdCleanup(), true);
+}
+
void AppIdInspector::eval(Packet* p)
{
Profile profile(appid_perf_stats);
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;
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:
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;
#include <vector>
#include "framework/module.h"
+#include "main/analyzer.h"
+#include "main/analyzer_command.h"
#include "main/snort_config.h"
#include "appid_config.h"
AppIdConfig* config;
};
+class ACThirdPartyAppIdCleanup : public snort::AnalyzerCommand
+{
+public:
+ bool execute(Analyzer&, void**) override;
+ const char* stringify() override { return "THIRD_PARTY_APPID_CLEANUP"; }
+};
+
#endif
void AppIdInspector::show(const SnortConfig*) const { }
void AppIdInspector::tinit() { }
void AppIdInspector::tterm() { }
+void AppIdInspector::tear_down(SnortConfig*) { }
AppIdContext& AppIdInspector::get_ctxt() const
{
assert(ctxt);
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;
}
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:
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; }