]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow: more accurate flow counters
authorEric Leblond <el@stamus-networks.com>
Sat, 14 Aug 2021 21:05:03 +0000 (23:05 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 1 Sep 2021 10:20:58 +0000 (12:20 +0200)
Don't increment the flow timeout counter for flows that are not
really timeout (as use_cnt is non zero). And also don't take into
account bypassed flows in the counter for flow timeout in use.

(cherry picked from commit 9a4ef6b8fc290a83ad0d17c036d8a93b5c02689c)

src/flow-manager.c

index 397cc89d8ac710d6886e602bdf8ee90fbabd7f5f..24d632d4ee63edcd26a0eb3d266f4af59732a2b0 100644 (file)
@@ -392,20 +392,22 @@ static void FlowManagerHashRowTimeout(FlowManagerTimeoutThread *td,
 
         Flow *next_flow = f->next;
 
-        counters->flows_timeout++;
-
         /* never prune a flow that is used by a packet we
          * are currently processing in one of the threads */
         if (f->use_cnt > 0 || !FlowBypassedTimeout(f, ts, counters)) {
             FLOWLOCK_UNLOCK(f);
             prev_f = f;
-            counters->flows_timeout_inuse++;
+            if (f->use_cnt > 0) {
+                counters->flows_timeout_inuse++;
+            }
             f = f->next;
             continue;
         }
 
         f->flow_end_flags |= FLOW_END_FLAG_TIMEOUT;
 
+        counters->flows_timeout++;
+
         RemoveFromHash(f, prev_f);
 
         FlowQueuePrivateAppendFlow(&td->aside_queue, f);