Skip to content

Commit

Permalink
macset: remove dead flow init/cleanup code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
victorjulien committed Nov 14, 2023
1 parent de14e3d commit 6bb882c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 31 deletions.
10 changes: 3 additions & 7 deletions src/flow-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 0 additions & 6 deletions src/flow-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
18 changes: 0 additions & 18 deletions src/util-macset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 6bb882c

Please sign in to comment.