Page MenuHomeFreeBSD

factor out remove logic from if_delgroup and if_delgroups
AbandonedPublic

Authored by jacob.e.keller_intel.com on Nov 1 2019, 5:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 2 2024, 2:56 AM
Unknown Object (File)
Dec 22 2023, 10:41 PM
Unknown Object (File)
Dec 10 2023, 9:55 PM
Unknown Object (File)
Oct 6 2023, 7:13 AM
Unknown Object (File)
Sep 6 2023, 2:54 AM
Unknown Object (File)
Aug 15 2023, 6:05 PM
Unknown Object (File)
Aug 14 2023, 8:49 PM
Unknown Object (File)
Mar 4 2023, 10:42 AM
Subscribers

Details

Reviewers
jhb
gallatin
erj
Group Reviewers
Intel Networking
Summary

The if_delgroups function failed to free the ifg_list structure pointer
memory. This results in a small leak on M_TEMP for each ifp group every
time an interface is detached.

This was caused because if_delgroup and if_delgroups duplicate the logic
for releasing the group memory.

Fix this by factoring out an if_freegroup function which can be called
by both if_delgroup and if_delgroups.

This results in slightly funky code, because we must drop the
IFNET_WLOCK before calling the event handler. However, we want the
IFNET_WLOCK around the group list search in if_delgroup and in the group
list iteration in if_delgroups. Further, if_delgroups must re-take the
lock after calling the new if_freegroups.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 27307
Build 25565: arc lint + arc unit

Event Timeline

This is likely the better approach to solving the leak described in https://reviews.freebsd.org/D22215

I don't know 100% though, because the fact that the function releases the lock smells weird and like it could be confusing to look at in the future. That's why I posted both potential fixes.

I think the refactor is fine.

sys/net/if.c
1504

Better to add an IFNET_WLOCK_ASSERT() or some such than to just document it in a comment.

This revision is now accepted and ready to land.Nov 1 2019, 6:08 PM

add an IFNET_WLOCK_ASSERT in if_freegroup

This revision now requires review to proceed.Nov 1 2019, 6:15 PM
erj requested changes to this revision.Jan 3 2020, 5:53 PM

Can this get regenerated? It no longer applies cleanly.

This revision now requires changes to proceed.Jan 3 2020, 5:53 PM

It looks like similar work was done via r355942, with slightly different (better) function names, and various style changes. This can be closed as essentially resolved/committed now.