]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/commit
MFC r229898:
authorlstewart <lstewart@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Sat, 21 Jan 2012 04:22:19 +0000 (04:22 +0000)
committerlstewart <lstewart@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Sat, 21 Jan 2012 04:22:19 +0000 (04:22 +0000)
commitfb7744bab09297f8539a35deb9339f9f2459985e
tree5c4d2baea4e1f48d32a8ebd31cdd43197d11d15e
parent987877e0c7b1eeed4086e0b48c99e828a549b0e0
MFC r229898:

Consumers of bpfdetach() expect it to remove all bpf_if structs from the
bpf_iflist list which reference the specified ifnet. The existing implementation
only removes the first matching bpf_if found in the list, effectively leaking
list entries if an ifnet has been bpfattach()ed multiple times with different
DLTs.

Fix the leak by performing the detach logic in a loop, stopping when all bpf_if
structs referencing the specified ifnet have been detached and removed from the
bpf_iflist list.

Whilst here, also:

- Remove the unnecessary "bp->bif_ifp == NULL" check, as a bpf_if should never
  exist in the list with a NULL ifnet pointer.

- Except when INVARIANTS is in the kernel config, silently ignore the case where
  no bpf_if referencing the specified ifnet is found, as it is harmless and does
  not require user attention.

Reviewed by: csjp

git-svn-id: svn://svn.freebsd.org/base/stable/8@230416 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/net/bpf.c