svn commit: r345794 - stable/12/sys/net
Andrey V. Elsukov
ae at FreeBSD.org
Tue Apr 2 09:31:39 UTC 2019
Author: ae
Date: Tue Apr 2 09:31:38 2019
New Revision: 345794
URL: https://svnweb.freebsd.org/changeset/base/345794
Log:
MFC r345292:
Convert allocation of bpf_if in bpfattach2 from M_NOWAIT to M_WAITOK
and remove possible panic condition.
It is already allowed to sleep in bpfattach[2], since BPF_LOCK was
converted to SX lock in r332388. Also move KASSERT() to the top of
function and make full initialization before bpf_if will be linked
to BPF's list of interfaces.
Modified:
stable/12/sys/net/bpf.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/net/bpf.c
==============================================================================
--- stable/12/sys/net/bpf.c Tue Apr 2 08:43:19 2019 (r345793)
+++ stable/12/sys/net/bpf.c Tue Apr 2 09:31:38 2019 (r345794)
@@ -2592,24 +2592,22 @@ bpfattach2(struct ifnet *ifp, u_int dlt, u_int hdrlen,
{
struct bpf_if *bp;
- bp = malloc(sizeof(*bp), M_BPF, M_NOWAIT | M_ZERO);
- if (bp == NULL)
- panic("bpfattach");
+ KASSERT(*driverp == NULL, ("bpfattach2: driverp already initialized"));
+ bp = malloc(sizeof(*bp), M_BPF, M_WAITOK | M_ZERO);
+
+ rw_init(&bp->bif_lock, "bpf interface lock");
LIST_INIT(&bp->bif_dlist);
LIST_INIT(&bp->bif_wlist);
bp->bif_ifp = ifp;
bp->bif_dlt = dlt;
- rw_init(&bp->bif_lock, "bpf interface lock");
- KASSERT(*driverp == NULL, ("bpfattach2: driverp already initialized"));
+ bp->bif_hdrlen = hdrlen;
bp->bif_bpf = driverp;
*driverp = bp;
BPF_LOCK();
LIST_INSERT_HEAD(&bpf_iflist, bp, bif_next);
BPF_UNLOCK();
-
- bp->bif_hdrlen = hdrlen;
if (bootverbose && IS_DEFAULT_VNET(curvnet))
if_printf(ifp, "bpf attached\n");
More information about the svn-src-stable-12
mailing list