]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4254: appid: separate main thread and packet thread appid_pub_id
authorLukasz Czarnik -X (lczarnik - SOFTSERVE INC at Cisco) <lczarnik@cisco.com>
Tue, 26 Mar 2024 18:54:26 +0000 (18:54 +0000)
committerChris Sherwin (chsherwi) <chsherwi@cisco.com>
Tue, 26 Mar 2024 18:54:26 +0000 (18:54 +0000)
Merge in SNORT/snort3 from ~LCZARNIK/snort3:appid_pub_id to master

Squashed commit of the following:

commit c7e9539db79ad120fdd1c50dd2b1d213378e6aa9
Author: Lukasz Czarnik <lczarnik@cisco.com>
Date:   Fri Mar 22 07:53:34 2024 -0400

    appid: separate main thread and packet thread appid_pub_id

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

index c98004d5a07eb55b42332ec15fb4b8a2c94a62a7..ea17d1562569b35f5bffcc2089cb8b8ec21b382e 100644 (file)
@@ -66,7 +66,8 @@ THREAD_LOCAL ThirdPartyAppIdContext* pkt_thread_tp_appid_ctxt = nullptr;
 THREAD_LOCAL OdpThreadContext* odp_thread_local_ctxt = nullptr;
 THREAD_LOCAL OdpContext* pkt_thread_odp_ctxt = nullptr;
 
-unsigned AppIdInspector::pub_id = 0;
+unsigned AppIdInspector::cached_global_pub_id = 0;
+static THREAD_LOCAL unsigned appid_pub_id = 0;
 
 static THREAD_LOCAL PacketTracer::TracerMute appid_mute;
 
@@ -111,6 +112,10 @@ AppIdContext& AppIdInspector::get_ctxt() const
     assert(ctxt);
     return *ctxt;
 }
+unsigned AppIdInspector::get_pub_id() 
+{
+    return appid_pub_id;
+}
 
 bool AppIdInspector::configure(SnortConfig* sc)
 {
@@ -167,7 +172,8 @@ bool AppIdInspector::configure(SnortConfig* sc)
     DataBus::subscribe_global(intrinsic_pub_key, IntrinsicEventIds::FLOW_NO_SERVICE,
          new AppIdServiceEventHandler(*this), *sc);
 
-    pub_id = DataBus::get_id(appid_pub_key);
+    cached_global_pub_id = DataBus::get_id(appid_pub_key);
+    appid_pub_id = cached_global_pub_id;
     return true;
 }
 
@@ -178,6 +184,7 @@ void AppIdInspector::show(const SnortConfig*) const
 
 void AppIdInspector::tinit()
 {
+    appid_pub_id = cached_global_pub_id;
     appid_mute = PacketTracer::get_mute();
 
     AppIdStatistics::initialize_manager(*config);
index 9a19c735eddd5df3721423d7c3449e870654e5f6..d2928b392bc989d57993a9abb82ab9662972d870 100644 (file)
@@ -49,12 +49,12 @@ public:
     AppIdContext& get_ctxt() const;
     const AppIdConfig& get_config() const { return *config; }
 
-    static unsigned get_pub_id() { return pub_id; }
+    static unsigned get_pub_id();
 
 private:
     const AppIdConfig* config = nullptr;
     AppIdContext* ctxt = nullptr;
-    static unsigned pub_id;
+    static unsigned cached_global_pub_id;
 };
 
 extern const snort::InspectApi appid_inspector_api;