From 5f0853599b15adafdf47399375728d70a94c9867 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Tue, 27 Feb 2024 16:55:59 -0600 Subject: [PATCH] pfring: fix leak of configuration data and in single mode Fix leak of configuration data on exit. Also, in single mode set thread count to one instead of the CPU count. Bug: #4734 --- src/runmode-pfring.c | 5 ++++- src/source-pfring.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runmode-pfring.c b/src/runmode-pfring.c index b0af83b4bf..7f1f74f40f 100644 --- a/src/runmode-pfring.c +++ b/src/runmode-pfring.c @@ -200,6 +200,7 @@ static void *ParsePfringConfig(const char *iface) cluster_type default_ctype = CLUSTER_FLOW; int getctype = 0; int bool_val; + const char *active_runmode = RunmodeGetActive(); if (unlikely(pfconf == NULL)) { return NULL; @@ -244,7 +245,9 @@ static void *ParsePfringConfig(const char *iface) if_default = NULL; } - if (ConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) { + if (active_runmode && !strcmp("single", active_runmode)) { + pfconf->threads = 1; + } else if (ConfGetChildValueWithDefault(if_root, if_default, "threads", &threadsstr) != 1) { pfconf->threads = 1; } else if (threadsstr != NULL) { if (strcmp(threadsstr, "auto") == 0) { diff --git a/src/source-pfring.c b/src/source-pfring.c index 09efe8ac04..3ec02327f9 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -701,6 +701,7 @@ TmEcode ReceivePfringThreadDeinit(ThreadVars *tv, void *data) } pfring_close(ptv->pd); + SCFree(ptv); return TM_ECODE_OK; } -- 2.47.2