]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4892: file_api: file cache sharing to use ref count for file inspector
authorShilpa Nagpal (shinagpa) <shinagpa@cisco.com>
Tue, 9 Sep 2025 04:47:40 +0000 (04:47 +0000)
committerLokesh Bevinamarad (lbevinam) <lbevinam@cisco.com>
Tue, 9 Sep 2025 04:47:40 +0000 (04:47 +0000)
Merge in SNORT/snort3 from ~SHINAGPA/snort3:mp_file_fix to master

Squashed commit of the following:

commit 0b966c02fef4f384c8fb5537cb81a15ea12f969e
Author: Shilpa Nagpal <shinagpa@cisco.com>
Date:   Wed Sep 3 18:48:32 2025 +0530

    file_api: file cache sharing to use ref count for file inspector

src/file_api/file_cache.cc
src/file_api/file_lib.h

index 0ba4e7b497a9d3a17aeaba0ee623583aa106c421..b39b80c8ade4ed7ac578203148115e45cf499c32 100644 (file)
@@ -27,6 +27,7 @@
 #include "hash/hash_defs.h"
 #include "hash/xhash.h"
 #include "log/messages.h"
+#include "managers/inspector_manager.h"
 #include "main/snort_config.h"
 #include "main/thread_config.h"
 #include "packet_io/active.h"
@@ -35,6 +36,7 @@
 #include "time/packet_time.h"
 
 #include "file_flows.h"
+#include "file_inspect.h"
 #include "file_module.h"
 #include "file_service.h"
 #include "file_stats.h"
@@ -276,10 +278,15 @@ FileContext* FileCache::get_file(Flow* flow, uint64_t file_id, bool to_create,
     if (to_create and !file)
         file = add(hashKey, timeout, cache_full, cache_expire);
 
-    if (file and !file->get_config())
+    if (file and !file->get_config() and !file->get_inspector())
     {
-        FileConfig *fc = get_file_config(SnortConfig::get_conf());  
-        file->set_config(fc);
+        FileInspect *inspector = (FileInspect*)InspectorManager::acquire_file_inspector();
+        if (inspector)
+        {
+            FileConfig *fc = inspector->config;
+            file->set_config(fc);
+            file->set_inspector(inspector);
+        }
     }
     return file;
 }
index dbb049b55934f2ff2b7c60f32a7530eabb72d7ce..8a05e46daa66ca0663693faf6d3671f37eba1fa7 100644 (file)
@@ -189,6 +189,8 @@ public:
     void reset();
     void set_config(FileConfig* fc) { config = fc; }
     FileConfig* get_config() { return config; }
+    void set_inspector(FileInspect* ins) { inspector = ins; }
+    FileInspect* get_inspector() { return inspector; }
 private:
     uint64_t processed_bytes = 0;
     void* file_type_context;