summaryrefslogtreecommitdiff
path: root/sys/net/bpf.c
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2004-09-09 04:11:12 +0000
committerRobert Watson <rwatson@FreeBSD.org>2004-09-09 04:11:12 +0000
commit46448b5a1bd84793e1a44c6805a40d527cc2b97b (patch)
treebf1639e5d58833d329b96282b40988eb95568cb7 /sys/net/bpf.c
parent9f0cd8478fc3dc5fb24ab8539374676deb22e3f2 (diff)
downloadsrc-test2-46448b5a1bd84793e1a44c6805a40d527cc2b97b.tar.gz
src-test2-46448b5a1bd84793e1a44c6805a40d527cc2b97b.zip
Notes
Diffstat (limited to 'sys/net/bpf.c')
-rw-r--r--sys/net/bpf.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 856abbbd0ce5..bfe8a91188e2 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -271,17 +271,35 @@ bpf_detachd(d)
{
int error;
struct bpf_if *bp;
+ struct ifnet *ifp;
- /* XXX locking */
bp = d->bd_bif;
+ BPFIF_LOCK(bp);
+ BPFD_LOCK(d);
+ ifp = d->bd_bif->bif_ifp;
+
+ /*
+ * Remove d from the interface's descriptor list.
+ */
+ LIST_REMOVE(d, bd_next);
+
+ /*
+ * Let the driver know that there are no more listeners.
+ */
+ if (LIST_EMPTY(&bp->bif_dlist))
+ *bp->bif_driverp = NULL;
+
d->bd_bif = NULL;
+ BPFD_UNLOCK(d);
+ BPFIF_UNLOCK(bp);
+
/*
* Check if this descriptor had requested promiscuous mode.
* If so, turn it off.
*/
if (d->bd_promisc) {
d->bd_promisc = 0;
- error = ifpromisc(bp->bif_ifp, 0);
+ error = ifpromisc(ifp, 0);
if (error != 0 && error != ENXIO) {
/*
* ENXIO can happen if a pccard is unplugged
@@ -293,15 +311,6 @@ bpf_detachd(d)
"bpf_detach: ifpromisc failed (%d)\n", error);
}
}
- /* Remove d from the interface's descriptor list. */
- BPFIF_LOCK(bp);
- LIST_REMOVE(d, bd_next);
- if (LIST_EMPTY(&bp->bif_dlist))
- /*
- * Let the driver know that there are no more listeners.
- */
- *bp->bif_driverp = NULL;
- BPFIF_UNLOCK(bp);
}
/*