From: Eric Leblond Date: Wed, 17 Nov 2021 15:43:23 +0000 (+0100) Subject: profiling: fix profiling with sample rate X-Git-Tag: suricata-5.0.9~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba14b58b1807875ca70f3f1326dc5bfc99373d86;p=thirdparty%2Fsuricata.git profiling: fix profiling with sample rate 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. (cherry picked from commit 6d5f59696dda77e1e7b2c45f51413b76690da4e9) --- diff --git a/src/util-profiling.c b/src/util-profiling.c index 3fbcd6b6a4..b0b7551d1e 100644 --- a/src/util-profiling.c +++ b/src/util-profiling.c @@ -1246,6 +1246,8 @@ int SCProfileRuleStart(Packet *p) return 1; } #endif + if (p->flags & PKT_PROFILE) + return 1; return 0; }