]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4735: appid: fix AppIdInspector hanging during tinit on startup and...
authorAndres Avila Segura (aavilase) <aavilase@cisco.com>
Tue, 3 Jun 2025 20:32:21 +0000 (20:32 +0000)
committerChris Sherwin (chsherwi) <chsherwi@cisco.com>
Tue, 3 Jun 2025 20:32:21 +0000 (20:32 +0000)
Merge in SNORT/snort3 from ~AAVILASE/snort3:tp_tinit_hanging_fix to master

Squashed commit of the following:

commit 383d11a617737c3d1a9c29d9811cd530a393fb44
Author: Andres Avila <aavilase@cisco.com>
Date:   Thu May 8 18:42:23 2025 -0400

    appid: queue analyzer command for third party setup during appid id tinit and stagger packet threads during third party tinit

src/network_inspectors/appid/appid_inspector.cc
src/network_inspectors/appid/appid_inspector.h
src/network_inspectors/appid/appid_module.cc

index 59f76f8f89cddb3bd291f3643da121ff0ae06aa1..9af66f07552a4e1ea2e86d4912658cdb6e241067 100644 (file)
@@ -177,6 +177,12 @@ void AppIdInspector::show(const SnortConfig*) const
     config->show();
 }
 
+void AppIdInspector::third_party_tinit()
+{
+    while (pkt_thread_tp_appid_ctxt->tinit())
+        ;
+}
+
 void AppIdInspector::tinit()
 {
     appid_pub_id = cached_global_pub_id;
@@ -196,7 +202,7 @@ void AppIdInspector::tinit()
     assert(!pkt_thread_tp_appid_ctxt);
     pkt_thread_tp_appid_ctxt = ctxt.get_tp_appid_ctxt();
     if (pkt_thread_tp_appid_ctxt)
-        pkt_thread_tp_appid_ctxt->tinit();
+        third_party_tinit();
     if (config->log_all_sessions)
         appidDebug->set_enabled(true);
      if ( snort::HighAvailabilityManager::active() )
index b94a6bd90c420869cbeeb1b5926255c3d93a2654..7b8b1b6596c6fe5df7996608ca41500232b5e03b 100644 (file)
@@ -58,6 +58,7 @@ private:
     AppIdConfig* config = nullptr;
     AppIdContext ctxt;
     static unsigned cached_global_pub_id;
+    void third_party_tinit();
 };
 
 extern const snort::InspectApi appid_inspector_api;
index 4c0acda50539d73643a1ef55964bbac59c603d98..23179288d4be6eddbe82516a05638fe1ec21cdb0 100644 (file)
@@ -177,9 +177,13 @@ private:
 
 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();
+    if (!pkt_thread_tp_appid_ctxt) 
+        pkt_thread_tp_appid_ctxt = inspector.get_ctxt().get_tp_appid_ctxt();
+    int reload_in_progress = pkt_thread_tp_appid_ctxt->tinit();
+    if (reload_in_progress) {
+        APPID_LOG(nullptr, TRACE_INFO_LEVEL, "== rescheduling third-party context swap\n");
+        return false;
+    }
     ThirdPartyAppIdContext::set_tp_reload_in_progress(false);
     APPID_LOG(nullptr, TRACE_INFO_LEVEL, "== third-party context swap in progress\n");
     return true;