]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1761 in SNORT/snort3 from ~SBAIGAL/snort3:revert_map_change to...
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Tue, 24 Sep 2019 16:55:31 +0000 (12:55 -0400)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Tue, 24 Sep 2019 16:55:31 +0000 (12:55 -0400)
Squashed commit of the following:

commit 2bd74d091178b75253934e1f51a7bb5bfc9130bf
Author: Steven Baigal (sbaigal) <sbaigal@cisco.com>
Date:   Mon Sep 23 20:51:16 2019 -0400

    binder: remove global check for stream inspectors and revert module_map changes

src/managers/module_manager.cc
src/network_inspectors/binder/binder.cc

index ab718f9aabdb747e7a10a93154e7bd257a4c09ad..7e2b3a901726ec8e06265cc0934726d293e2a89c 100644 (file)
@@ -68,7 +68,6 @@ struct ModHook
 
 typedef std::list<ModHook*> ModuleList;
 static ModuleList s_modules;
-static std::unordered_map<std::string, Module*> s_module_map;
 static unsigned s_errors = 0;
 
 std::set<uint32_t> ModuleManager::gids;
@@ -872,7 +871,6 @@ void ModuleManager::add_module(Module* m, const BaseApi* b)
 {
     ModHook* mh = new ModHook(m, b);
     s_modules.emplace_back(mh);
-    s_module_map[std::string(m->get_name())] = m;
 
     Profiler::register_module(m);
 
@@ -882,7 +880,11 @@ void ModuleManager::add_module(Module* m, const BaseApi* b)
 
 Module* ModuleManager::get_module(const char* s)
 {
-    return s_module_map[std::string(s)];
+    for ( auto p : s_modules )
+        if ( !strcmp(p->mod->get_name(), s) )
+            return p->mod;
+
+    return nullptr;
 }
 
 Module* ModuleManager::get_default_module(const char* s, SnortConfig* sc)
index 5829b73a1d84026384b6e20005646610e104fc40..a5bbc198b96bc716ec2b18f17ecde70b7dad219a 100644 (file)
@@ -398,15 +398,10 @@ bool Binding::check_all(const Flow* flow, Packet* p) const
 //-------------------------------------------------------------------------
 // helpers
 //-------------------------------------------------------------------------
-static bool is_global(const char* key)
-{
-    Module* m = ModuleManager::get_module(key);
-    return m ? m->get_usage() == Module::GLOBAL : false;
-}
 
 static void set_session(Flow* flow, const char* key)
 {
-    Inspector* pin = InspectorManager::get_inspector(key, is_global(key));
+    Inspector* pin = InspectorManager::get_inspector(key);
 
     if ( pin )
     {
@@ -436,7 +431,7 @@ static Inspector* get_gadget(Flow* flow)
 
     const char* s = SnortConfig::get_conf()->proto_ref->get_name(flow->ssn_state.snort_protocol_id);
 
-    return InspectorManager::get_inspector(s, is_global(s));
+    return InspectorManager::get_inspector(s);
 }
 
 //-------------------------------------------------------------------------
@@ -475,6 +470,7 @@ bool Stuff::update(Binding* pb)
         action = pb->use.action;
         return true;
     }
+
     switch ( pb->use.what )
     {
     case BindUse::BW_NONE:
@@ -842,7 +838,9 @@ void Binder::set_binding(SnortConfig*, Binding* pb)
     else
         key = pb->use.svc.c_str();
 
-    if ( (pb->use.object = InspectorManager::get_inspector(key, is_global(key))) )
+    Module* m = ModuleManager::get_module(key);
+    bool is_global = m ? m->get_usage() == Module::GLOBAL : false;
+    if ( (pb->use.object = InspectorManager::get_inspector(key, is_global)) )
     {
         switch ( ((Inspector*)pb->use.object)->get_api()->type )
         {