Page MenuHomeFreeBSD

pf: fix pfi_ifnet leak on interface removal
ClosedPublic

Authored by kp on Nov 30 2022, 4:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 31 2024, 10:22 AM
Unknown Object (File)
Dec 22 2023, 11:02 PM
Unknown Object (File)
Dec 11 2023, 3:45 AM
Unknown Object (File)
Nov 29 2023, 4:57 AM
Unknown Object (File)
Nov 24 2023, 1:26 AM
Unknown Object (File)
Nov 12 2023, 9:07 PM
Unknown Object (File)
Oct 28 2023, 9:09 PM
Unknown Object (File)
Oct 7 2023, 12:39 PM

Details

Summary

The detach of the interface and group were leaving pfi_ifnet memory
behind. Check if the kif still has references, and clean it up if it
doesn't

On interface detach, the group deletion was notified first and then a
change notification was sent. This would recreate the group in the kif
layer. Reorder the change to before the delete.

PR: 257218
MFC after: 2 weeks

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 48570
Build 45456: arc lint + arc unit

Event Timeline

kp requested review of this revision.Nov 30 2022, 4:16 PM

Some design concerns:
For interface groups, typically there're four kinds of event:

  1. new group added ( with a joining member )
  2. a new member joins
  3. a existing member leaves
  4. a group deleted ( also the last member leaves )

The current implementation triggers a group_attach_event for 1, and a group_detach_event for 4, and also triggers a group_change_event for all kinds of event.

In principal both group_attach_event and group_detach_event imply that group member changed, then it seems there's no need to trigger a redundant group_change_event.

For the current implementation I think it may ease consumers of group_change_event. But for consumers that are also aware of group_attach_event and group_detach_event it may be POLA.

So can we refine group_attach_event and group_detach_event so that they no longger implies member joining or leaving ?

Currently in base system pf is the only consumer of those events.

sys/net/if.c
1548

This is definitely the correct order ( of if group events ) !

In D37569#854380, @zlei wrote:

Some design concerns:
For interface groups, typically there're four kinds of event:

  1. new group added ( with a joining member )
  2. a new member joins
  3. a existing member leaves
  4. a group deleted ( also the last member leaves )

The current implementation triggers a group_attach_event for 1, and a group_detach_event for 4, and also triggers a group_change_event for all kinds of event.

In principal both group_attach_event and group_detach_event imply that group member changed, then it seems there's no need to trigger a redundant group_change_event.

For the current implementation I think it may ease consumers of group_change_event. But for consumers that are also aware of group_attach_event and group_detach_event it may be POLA.

So can we refine group_attach_event and group_detach_event so that they no longger implies member joining or leaving ?

Your analysis is, I believe largely correct, but I think you're missing one point. It's not possible to have a group without members. Essentially, interfaces keep a list of groups they're a member of. So every group_attach_event always implies that at least one interface is a member of that group. That means there should be a group_change_event for that group at the same time. (Arguably we could define group_attach_event as implying a group_change_event, but that seems like a bigger POLA than fixing the incorrect order of events on group_detach_event).

This revision was not accepted when it landed; it landed in state Needs Review.Dec 14 2022, 9:20 AM
This revision was automatically updated to reflect the committed changes.