HomeFreeBSD

bpf: Fix incorrect cleanup

Description

bpf: Fix incorrect cleanup

Cleaning up a bpf_if is a two stage process. We first move it to the
bpf_freelist (in bpfdetach()) and only later do we actually free it (in
bpf_ifdetach()).

We cannot set the ifp->if_bpf to NULL from bpf_ifdetach() because it's
possible that the ifnet has already gone away, or that it has been assigned
a new bpf_if.
This can lead to a struct ifnet which is up, but has if_bpf set to NULL,
which will panic when we try to send the next packet.

Keep track of the pointer to the bpf_if (because it's not always
ifp->if_bpf), and NULL it immediately in bpfdetach().

PR: 213896
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D11782

Details

Provenance
kpAuthored on
Differential Revision
D11782: bpf: Fix incorrect cleanup
Parents
rS322589: force use of ld.bfd for linking i386 libc, even when using lld
Branches
Unknown
Tags
Unknown