]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
macset: remove dead flow init/cleanup code 9789/head
authorVictor Julien <vjulien@oisf.net>
Fri, 8 Sep 2023 08:01:41 +0000 (10:01 +0200)
committerVictor Julien <victor@inliniac.net>
Tue, 14 Nov 2023 18:28:13 +0000 (19:28 +0100)
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.

src/flow-util.c
src/flow-util.h
src/util-macset.c

index 3572c0823f4e4ab941e0d1b474c60d57be32d332..dc6a7103a6bd57238d69a727b33ffa3fd87b2854 100644 (file)
@@ -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;
index 4bdb9e2d3e12da11563205fe95d53de446555966..3d0d978b5a76bffcf9973e755cb1e1ac502812c3 100644 (file)
         (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)
 
index 3f540a23a1d3342211fb0e8405b480996ea9ac8a..9853a32416808b5a646c1866d16dc3bc8934382a 100644 (file)
@@ -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;
 }