]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util/thash: fix memcap consolidate function 5891/head
authorEric Leblond <eric@regit.org>
Thu, 11 Feb 2021 10:01:18 +0000 (11:01 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 22 Feb 2021 10:16:40 +0000 (11:16 +0100)
The function THashConsolidateMemcap is used to allow to load a
dataset even when the memcap is not set. But the implementation
was in fact resetting the memcap value to the max of memory
usaga after loading and default memcap. As a result, the
function was resetting memcap to the default memcap even if
a huge memcap was set in the dataset definition. In the case
of dataset where we add to the set it was leading to memcap
limit hitting despite the settings of memcap by the user.

This patch udpates the code to set the final memcap value to
the max of memory usage after loading and set memcap.

src/util-thash.c

index a90558066b1ea4d311b2eb8e8712559dad1be49c..93cf882f0bec64e980caccb2b11e36da9f508fa9 100644 (file)
@@ -336,7 +336,7 @@ THashTableContext *THashInit(const char *cnf_prefix, size_t data_size,
  * */
 void THashConsolidateMemcap(THashTableContext *ctx)
 {
-    ctx->config.memcap = MAX(SC_ATOMIC_GET(ctx->memuse), THASH_DEFAULT_MEMCAP);
+    ctx->config.memcap = MAX(SC_ATOMIC_GET(ctx->memuse), ctx->config.memcap);
     SCLogDebug("memcap after load set to: %" PRIu64, ctx->config.memcap);
 }