From: Victor Julien Date: Fri, 8 Sep 2023 08:01:41 +0000 (+0200) Subject: macset: remove dead flow init/cleanup code X-Git-Tag: suricata-7.0.3~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9789%2Fhead;p=thirdparty%2Fsuricata.git macset: remove dead flow init/cleanup code FlowInit() will only be called on a newly allocated, or a fully cleaned up flow, so no existing storage will exist. The only caller of `FLOW_RECYCLE` first calls `FlowFreeStorage()`, so the reset logic in `FLOW_RECYCLE` can never trigger. Remove now unused MacSetReset logic. --- diff --git a/src/flow-util.c b/src/flow-util.c index 3572c0823f..dc6a7103a6 100644 --- a/src/flow-util.c +++ b/src/flow-util.c @@ -200,13 +200,9 @@ void FlowInit(Flow *f, const Packet *p) f->timeout_at = timeout_at; if (MacSetFlowStorageEnabled()) { - MacSet *ms = FlowGetStorageById(f, MacSetGetFlowStorageID()); - if (ms != NULL) { - MacSetReset(ms); - } else { - ms = MacSetInit(10); - FlowSetStorageById(f, MacSetGetFlowStorageID(), ms); - } + DEBUG_VALIDATE_BUG_ON(FlowGetStorageById(f, MacSetGetFlowStorageID()) != NULL); + MacSet *ms = MacSetInit(10); + FlowSetStorageById(f, MacSetGetFlowStorageID(), ms); } SCReturn; diff --git a/src/flow-util.h b/src/flow-util.h index 4bdb9e2d3e..3d0d978b5a 100644 --- a/src/flow-util.h +++ b/src/flow-util.h @@ -115,12 +115,6 @@ (f)->sgh_toclient = NULL; \ GenericVarFree((f)->flowvar); \ (f)->flowvar = NULL; \ - if (MacSetFlowStorageEnabled()) { \ - MacSet *ms = FlowGetStorageById((f), MacSetGetFlowStorageID()); \ - if (ms != NULL) { \ - MacSetReset(ms); \ - } \ - } \ RESET_COUNTERS((f)); \ } while (0) diff --git a/src/util-macset.c b/src/util-macset.c index 3f540a23a1..9853a32416 100644 --- a/src/util-macset.c +++ b/src/util-macset.c @@ -259,14 +259,6 @@ int MacSetSize(const MacSet *ms) return size; } -void MacSetReset(MacSet *ms) -{ - if (ms == NULL) - return; - ms->state[MAC_SET_SRC] = ms->state[MAC_SET_DST] = EMPTY_SET; - ms->last[MAC_SET_SRC] = ms->last[MAC_SET_DST] = 0; -} - void MacSetFree(MacSet *ms) { size_t total_free = 0; @@ -334,16 +326,6 @@ static int MacSetTest01(void) ret = MacSetForEach(ms, CheckTest1Membership, &i); FAIL_IF_NOT(ret == 0); - MacSetReset(ms); - FAIL_IF_NOT(MacSetSize(ms) == 0); - - MacSetAdd(ms, addr2, addr3); - FAIL_IF_NOT(MacSetSize(ms) == 2); - - i = 1; - ret = MacSetForEach(ms, CheckTest1Membership, &i); - FAIL_IF_NOT(ret == 0); - MacSetFree(ms); PASS; }