summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-05-30 06:42:14 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-05-30 06:42:14 +0000
commitf841d5fa9002f9335cc6dcebbabc605a54538512 (patch)
tree73b0a19af72a98a6ab89c3d11ef2fac61b3175e7 /sys/net
parent024403aa7c5fc50c1a0404469c388fe313c79bfc (diff)
Clear the internal table used by if_get(9) and sleep until all
remaining ifp references are released *without* the NET_LOCK(). It's safe to do so because the KERNEL_LOCK() serializes accesses to ``if_map''. More importantly this fix possible deadlocks between if_get() and the NET_LOCK(). It is now possible to call them in whatever order. ok visa@, dlg@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index d519ddcfeba..29ec9034760 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.500 2017/05/29 06:08:21 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.501 2017/05/30 06:42:13 mpi Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -1014,11 +1014,11 @@ if_detach(struct ifnet *ifp)
ifq_clr_oactive(&ifp->if_snd);
- NET_LOCK(s);
- s2 = splnet();
/* Other CPUs must not have a reference before we start destroying. */
if_idxmap_remove(ifp);
+ NET_LOCK(s);
+ s2 = splnet();
ifp->if_qstart = if_detached_qstart;
ifp->if_ioctl = if_detached_ioctl;
ifp->if_watchdog = NULL;