]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
threads: clean up module flags
authorVictor Julien <vjulien@oisf.net>
Tue, 10 Jun 2025 10:40:21 +0000 (12:40 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 10 Jun 2025 20:13:54 +0000 (22:13 +0200)
Remove unused TM_FLAG_STREAM_TM.

Rename TM_FLAG_DETECT_TM to TM_FLAG_FLOWWORKER_TM as it was mostly used
to check if a thread is a flow worker. TM_FLAG_DETECT_TM was always set
for a flow worker, even when there was no detection in use.

src/detect-engine.c
src/flow-worker.c
src/log-flush.c
src/suricata.c
src/tm-modules.h
src/tmqh-packetpool.c

index ba3a54b93f72bbc082840af75ac96dc73d96098d..7c6e9c13630fcfddb37e0c3024bbafc164c255c0 100644 (file)
@@ -2324,7 +2324,7 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
     uint32_t i = 0;
 
     /* count detect threads in use */
-    uint32_t no_of_detect_tvs = TmThreadCountThreadsByTmmFlags(TM_FLAG_DETECT_TM);
+    uint32_t no_of_detect_tvs = TmThreadCountThreadsByTmmFlags(TM_FLAG_FLOWWORKER_TM);
     /* can be zero in unix socket mode */
     if (no_of_detect_tvs == 0) {
         return 0;
@@ -2343,12 +2343,12 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
     /* get reference to tv's and setup new_det_ctx array */
     SCMutexLock(&tv_root_lock);
     for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) {
-        if ((tv->tmm_flags & TM_FLAG_DETECT_TM) == 0) {
+        if ((tv->tmm_flags & TM_FLAG_FLOWWORKER_TM) == 0) {
             continue;
         }
         for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) {
             TmModule *tm = TmModuleGetById(s->tm_id);
-            if (!(tm->flags & TM_FLAG_DETECT_TM)) {
+            if (!(tm->flags & TM_FLAG_FLOWWORKER_TM)) {
                 continue;
             }
 
@@ -2378,12 +2378,12 @@ static int DetectEngineReloadThreads(DetectEngineCtx *new_de_ctx)
     /* atomically replace the det_ctx data */
     i = 0;
     for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) {
-        if ((tv->tmm_flags & TM_FLAG_DETECT_TM) == 0) {
+        if ((tv->tmm_flags & TM_FLAG_FLOWWORKER_TM) == 0) {
             continue;
         }
         for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) {
             TmModule *tm = TmModuleGetById(s->tm_id);
-            if (!(tm->flags & TM_FLAG_DETECT_TM)) {
+            if (!(tm->flags & TM_FLAG_FLOWWORKER_TM)) {
                 continue;
             }
             SCLogDebug("swapping new det_ctx - %p with older one - %p",
@@ -2432,7 +2432,7 @@ retry:
      * THV_DEINIT flag */
     if (i != no_of_detect_tvs) { // not all threads we swapped
         for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) {
-            if ((tv->tmm_flags & TM_FLAG_DETECT_TM) == 0) {
+            if ((tv->tmm_flags & TM_FLAG_FLOWWORKER_TM) == 0) {
                 continue;
             }
 
index 92ea75f432a4ea8594bf8c7b38cdeea205ff00e2..0bd4ae2785958cda7b41f05a2b55d9e93bf8a420 100644 (file)
@@ -819,5 +819,5 @@ void TmModuleFlowWorkerRegister (void)
     tmm_modules[TMM_FLOWWORKER].ThreadBusy = FlowWorkerIsBusy;
     tmm_modules[TMM_FLOWWORKER].ThreadDeinit = FlowWorkerThreadDeinit;
     tmm_modules[TMM_FLOWWORKER].cap_flags = 0;
-    tmm_modules[TMM_FLOWWORKER].flags = TM_FLAG_STREAM_TM|TM_FLAG_DETECT_TM;
+    tmm_modules[TMM_FLOWWORKER].flags = TM_FLAG_FLOWWORKER_TM;
 }
index 155154f38d8e2f6d99f1ab9fc4341fef678c2c8a..f9ab98b0688fd9458eb1ba60cf0fa628e339e6c4 100644 (file)
@@ -43,7 +43,7 @@ static void WorkerFlushLogs(void)
     SCEnter();
 
     /* count detect threads in use */
-    uint32_t no_of_detect_tvs = TmThreadCountThreadsByTmmFlags(TM_FLAG_DETECT_TM);
+    uint32_t no_of_detect_tvs = TmThreadCountThreadsByTmmFlags(TM_FLAG_FLOWWORKER_TM);
     /* can be zero in unix socket mode */
     if (no_of_detect_tvs == 0) {
         return;
@@ -61,12 +61,12 @@ static void WorkerFlushLogs(void)
     SCMutexLock(&tv_root_lock);
     /* get reference to tv's and setup fw_threads array */
     for (ThreadVars *tv = tv_root[TVT_PPT]; tv != NULL; tv = tv->next) {
-        if ((tv->tmm_flags & TM_FLAG_DETECT_TM) == 0) {
+        if ((tv->tmm_flags & TM_FLAG_FLOWWORKER_TM) == 0) {
             continue;
         }
         for (TmSlot *s = tv->tm_slots; s != NULL; s = s->slot_next) {
             TmModule *tm = TmModuleGetById(s->tm_id);
-            if (!(tm->flags & TM_FLAG_DETECT_TM)) {
+            if (!(tm->flags & TM_FLAG_FLOWWORKER_TM)) {
                 continue;
             }
 
index a862a0aaedbb2b78546451806c5e83a7fd6682bc..2158aaeea21be4635c6c59216455587dd67d59fc 100644 (file)
@@ -2292,7 +2292,7 @@ void PostRunDeinit(const int runmode, struct timeval *start_time)
     TmThreadDisableReceiveThreads();
     /* tell relevant packet threads to enter flow timeout loop */
     TmThreadDisablePacketThreads(
-            THV_REQ_FLOW_LOOP, THV_FLOW_LOOP, (TM_FLAG_RECEIVE_TM | TM_FLAG_DETECT_TM));
+            THV_REQ_FLOW_LOOP, THV_FLOW_LOOP, (TM_FLAG_RECEIVE_TM | TM_FLAG_FLOWWORKER_TM));
     /* run cleanup on the flow hash */
     FlowWorkToDoCleanup();
     /* gracefully shut down all packet threads */
index ef7b63f889d72e01e17c183ff8072e7a0f75899a..a557280d89f21143ba290fdb3b20d5f2e1347cfe 100644 (file)
 /* thread flags */
 #define TM_FLAG_RECEIVE_TM      0x01
 #define TM_FLAG_DECODE_TM       0x02
-#define TM_FLAG_STREAM_TM       0x04
-#define TM_FLAG_DETECT_TM       0x08
+#define TM_FLAG_FLOWWORKER_TM   0x04
+#define TM_FLAG_VERDICT_TM      0x08
 #define TM_FLAG_MANAGEMENT_TM   0x10
 #define TM_FLAG_COMMAND_TM      0x20
-#define TM_FLAG_VERDICT_TM      0x40
 
 /* all packet modules combined */
 #define TM_FLAG_PACKET_ALL                                                                         \
-    (TM_FLAG_RECEIVE_TM | TM_FLAG_DECODE_TM | TM_FLAG_STREAM_TM | TM_FLAG_DETECT_TM |              \
-            TM_FLAG_VERDICT_TM)
+    (TM_FLAG_RECEIVE_TM | TM_FLAG_DECODE_TM | TM_FLAG_FLOWWORKER_TM | TM_FLAG_VERDICT_TM)
 
 typedef TmEcode (*ThreadInitFunc)(ThreadVars *, const void *, void **);
 typedef TmEcode (*ThreadDeinitFunc)(ThreadVars *, void *);
index e301025730b8cd55336dc5451f06ea6b7ffcb0d9..9a812c644adba276cfb5d77a7f6e63b10f5062a5 100644 (file)
@@ -465,7 +465,7 @@ void PacketPoolPostRunmodes(void)
                    "must be at least %d",
                 RESERVED_PACKETS);
     }
-    uint32_t threads = TmThreadCountThreadsByTmmFlags(TM_FLAG_DETECT_TM);
+    uint32_t threads = TmThreadCountThreadsByTmmFlags(TM_FLAG_FLOWWORKER_TM);
     if (threads == 0)
         return;