FreeBSD/src 9ce40d3 (r322590)sys/net bpf.c

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
DeltaFile
+3-7sys/net/bpf.c
+3-71 files

UnifiedSplitRaw