]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow/manager: fix multi instance row tracking 12302/head
authorVictor Julien <vjulien@oisf.net>
Tue, 3 Dec 2024 10:36:27 +0000 (11:36 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 17 Dec 2024 21:05:21 +0000 (22:05 +0100)
In multi instance flow manager setups, each flow manager gets a slice
of the hash table to manage. Due to a logic error in the chunked
scanning of the hash slice, instances beyond the first would always
rescan the same (first) subslice of their slice.

The `pos` variable that is used to keep the state of what the starting
position for the next scan was supposed to be, was treated as if it held
a relative value. Relative to the bounds of the slice. It was however,
holding an absolute position. This meant that when doing it's bounds
check it was always considered out of bounds. This would reset the sub-
slice to be scanned to the first part of the instances slice.

This patch addresses the issue by correctly handling the fact that the
value is absolute.

Bug: #7365.

Fixes: e9d2417e0ff3 ("flow/manager: adaptive hash eviction timing")
(cherry picked from commit ae072d5c07e0f5e02a8583127c7b3edd97f93d54)

src/flow-manager.c

index 725361204781e2ee91a221ba1d3e6d6b8fd88d17..f58bcf41ff25589c468b6c45dbce536edf1e3690 100644 (file)
@@ -506,7 +506,7 @@ static uint32_t FlowTimeoutHash(FlowManagerTimeoutThread *td, SCTime_t ts, const
  *  \param hash_max upper bound of the row slice
  *  \param counters Flow timeout counters to be passed
  *  \param rows number of rows for this worker unit
- *  \param pos position of the beginning of row slice in the hash table
+ *  \param pos absolute position of the beginning of row slice in the hash table
  *
  *  \retval number of successfully timed out flows
  */
@@ -520,7 +520,7 @@ static uint32_t FlowTimeoutHashInChunks(FlowManagerTimeoutThread *td, SCTime_t t
     uint32_t rows_left = rows;
 
 again:
-    start = hash_min + (*pos);
+    start = (*pos);
     if (start >= hash_max) {
         start = hash_min;
     }
@@ -800,7 +800,7 @@ static TmEcode FlowManager(ThreadVars *th_v, void *thread_data)
 
     uint32_t emerg_over_cnt = 0;
     uint64_t next_run_ms = 0;
-    uint32_t pos = 0;
+    uint32_t pos = ftd->min;
     uint32_t rows_sec = 0;
     uint32_t rows_per_wu = 0;
     uint64_t sleep_per_wu = 0;