else
appid_stats.tp_reload_ignored_pkts++;
}
- else if (!tp_appid_ctxt->get_tp_reload_in_progress())
+ else if (!ThirdPartyAppIdContext::get_tp_reload_in_progress())
is_discovery_done = do_tp_discovery(*tp_appid_ctxt, asd, protocol, p,
direction, change_bits);
}
HttpEvent* http_event = (HttpEvent*)&event;
AppidChangeBits change_bits;
- if (asd->get_tp_appid_ctxt() && !http_event->get_is_http2())
+ if ((asd->get_tp_appid_ctxt() or ThirdPartyAppIdContext::get_tp_reload_in_progress()) and
+ !http_event->get_is_http2())
return;
if (appidDebug->is_active())
{
public:
bool execute(Analyzer&, void**) override;
- ACThirdPartyAppIdContextSwap(const AppIdInspector& inspector,
- Request& current_request, bool from_shell): inspector(inspector),
- request(current_request), from_shell(from_shell)
+ ACThirdPartyAppIdContextSwap(const AppIdInspector& inspector): inspector(inspector)
{
LogMessage("== swapping third-party configuration\n");
- request.respond("== swapping third-party configuration\n", from_shell, true);
}
~ACThirdPartyAppIdContextSwap() override;
const char* stringify() override { return "THIRD-PARTY_CONTEXT_SWAP"; }
private:
const AppIdInspector& inspector;
- Request& request;
- bool from_shell;
};
bool ACThirdPartyAppIdContextSwap::execute(Analyzer&, void**)
assert(!pkt_thread_tp_appid_ctxt);
pkt_thread_tp_appid_ctxt = inspector.get_ctxt().get_tp_appid_ctxt();
pkt_thread_tp_appid_ctxt->tinit();
- pkt_thread_tp_appid_ctxt->set_tp_reload_in_progress(false);
+ ThirdPartyAppIdContext::set_tp_reload_in_progress(false);
return true;
}
ACThirdPartyAppIdContextSwap::~ACThirdPartyAppIdContextSwap()
{
- Swapper::set_reload_in_progress(false);
- LogMessage("== reload third-party complete\n");
- request.respond("== reload third-party complete\n", from_shell, true);
+ LogMessage("== third-party configuration swap complete\n");
}
class ACThirdPartyAppIdContextUnload : public AnalyzerCommand
bool ACThirdPartyAppIdContextUnload::execute(Analyzer& ac, void**)
{
assert(pkt_thread_tp_appid_ctxt);
- pkt_thread_tp_appid_ctxt->set_tp_reload_in_progress(true);
+ 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);
delete tp_ctxt;
AppIdContext& ctxt = inspector.get_ctxt();
ctxt.create_tp_appid_ctxt();
- main_broadcast_command(new ACThirdPartyAppIdContextSwap(inspector,
- request, from_shell), from_shell);
+ main_broadcast_command(new ACThirdPartyAppIdContextSwap(inspector));
+ LogMessage("== reload third-party complete\n");
+ request.respond("== reload third-party complete\n", from_shell, true);
+ Swapper::set_reload_in_progress(false);
}
class ACOdpContextSwap : public AnalyzerCommand
initiator_port(port), asid(asid), protocol(proto),
api(*(new AppIdSessionApi(this, *ip))), odp_ctxt(odp_ctxt),
odp_ctxt_version(odp_ctxt.get_version()),
- tp_appid_ctxt(inspector.get_ctxt().get_tp_appid_ctxt())
+ tp_appid_ctxt(pkt_thread_tp_appid_ctxt)
{
service_ip.clear();
}
void AppIdSession::reinit_session_data(AppidChangeBits& change_bits,
- ThirdPartyAppIdContext* tp_appid_ctxt)
+ ThirdPartyAppIdContext* curr_tp_appid_ctxt)
{
misc_app_id = APP_ID_NONE;
free_flow_data_by_mask(APPID_SESSION_DATA_CLIENT_MODSTATE_BIT);
//3rd party cleaning
- if (tpsession and tp_appid_ctxt and
- (tpsession->get_ctxt_version() == tp_appid_ctxt->get_version()))
+ if (tpsession and curr_tp_appid_ctxt and
+ (tpsession->get_ctxt_version() == curr_tp_appid_ctxt->get_version()))
tpsession->reset();
else if (tpsession)
tpsession->set_state(TP_STATE_TERMINATED);
}
void AppIdSession::check_ssl_detection_restart(AppidChangeBits& change_bits,
- ThirdPartyAppIdContext* tp_appid_ctxt)
+ ThirdPartyAppIdContext* curr_tp_appid_ctxt)
{
if (get_session_flags(APPID_SESSION_DECRYPTED) or !flow->is_proxied())
return;
if (encrypted.payload_id > APP_ID_NONE)
api.payload.set_overwritten_id(encrypted.payload_id);
- reinit_session_data(change_bits, tp_appid_ctxt);
+ reinit_session_data(change_bits, curr_tp_appid_ctxt);
if (appidDebug->is_active())
LogMessage("AppIdDbg %s SSL decryption is available, restarting app detection\n",
appidDebug->get_debug_session());
}
void AppIdSession::check_app_detection_restart(AppidChangeBits& change_bits,
- ThirdPartyAppIdContext* tp_appid_ctxt)
+ ThirdPartyAppIdContext* curr_tp_appid_ctxt)
{
- check_ssl_detection_restart(change_bits, tp_appid_ctxt);
+ check_ssl_detection_restart(change_bits, curr_tp_appid_ctxt);
check_tunnel_detection_restart();
}
bool AppIdSession::is_tp_appid_done() const
{
- if (tp_appid_ctxt)
- {
- if (get_session_flags(APPID_SESSION_FUTURE_FLOW))
- return true;
-
- if (!tpsession)
- return false;
+ if (get_session_flags(APPID_SESSION_FUTURE_FLOW) or !tp_appid_ctxt)
+ return true;
- unsigned state = tpsession->get_state();
- return (state == TP_STATE_CLASSIFIED || state == TP_STATE_TERMINATED ||
- state == TP_STATE_HA);
- }
+ if (!tpsession)
+ return false;
- return true;
+ unsigned state = tpsession->get_state();
+ return (state == TP_STATE_CLASSIFIED || state == TP_STATE_TERMINATED ||
+ state == TP_STATE_HA);
}
bool AppIdSession::is_tp_processing_done() const
THREAD_LOCAL AppIdDebug* appidDebug = nullptr;
ThirdPartyAppIdContext* AppIdContext::tp_appid_ctxt = nullptr;
+THREAD_LOCAL bool ThirdPartyAppIdContext::tp_reload_in_progress = false;
void AppIdDebug::activate(const Flow*, const AppIdSession*, bool) { active = true; }
void ApplicationDescriptor::set_id(const Packet&, AppIdSession&, AppidSessionDirection, AppId, AppidChangeBits&) { }
virtual const ThirdPartyConfig& get_config() const { return cfg; }
- void set_tp_reload_in_progress(bool value) { tp_reload_in_progress = value; }
- bool get_tp_reload_in_progress() { return tp_reload_in_progress; }
+ static void set_tp_reload_in_progress(bool value) { tp_reload_in_progress = value; }
+ static bool get_tp_reload_in_progress() { return tp_reload_in_progress; }
protected:
const uint32_t api_version;