]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
profiling: fix profiling with sample rate
authorEric Leblond <el@stamus-networks.com>
Wed, 17 Nov 2021 15:43:23 +0000 (16:43 +0100)
committerVictor Julien <vjulien@oisf.net>
Fri, 19 Nov 2021 16:41:13 +0000 (17:41 +0100)
Rules profiling was returning invalid results when used with sample
rate. The problem was that the sample condition was run twice in the
packet flow. As a result, the second pass was not initializing the
variable storing the initial CPU ticks and the resulting performance
counters were reporting invalid values.

Bug: #4836.

src/util-profiling.c

index 3947f927f050db164ef48ba10f1d938ed178b61f..6034d20d1fd268a7effc383357140d8ceaa4db01 100644 (file)
@@ -1243,6 +1243,8 @@ int SCProfileRuleStart(Packet *p)
         return 1;
     }
 #endif
+    if (p->flags & PKT_PROFILE)
+        return 1;
     return 0;
 }