diff options
author | mvs <mvs@cvs.openbsd.org> | 2020-07-20 13:55:33 +0000 |
---|---|---|
committer | mvs <mvs@cvs.openbsd.org> | 2020-07-20 13:55:33 +0000 |
commit | 57630f52259e2d2249c692ca791521aa36f801e7 (patch) | |
tree | 77e81b1b9e774fb1b0909346a00c0a00bbf77327 /sys/net/if.c | |
parent | a23e2b1322d923410fc99491cb25d2b62c0e954c (diff) |
Move insertions to `if_list' out of NET_LOCK() because KERNEL_LOCK()
protects this list. Also corresponding assertion added to be sure the
required lock was held.
This is the step to clean locking mess around `if_list'.
Also we are going to protect `if_list' by it's own lock and this will
allow us to avoid lock order issues in future.
ok dlg@
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 791c4579ddd..a7aacb0c6c8 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.613 2020/07/17 08:56:41 mvs Exp $ */ +/* $OpenBSD: if.c,v 1.614 2020/07/20 13:55:32 mvs Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -523,8 +523,9 @@ void if_attachhead(struct ifnet *ifp) { if_attach_common(ifp); - NET_LOCK(); + KERNEL_ASSERT_LOCKED(); TAILQ_INSERT_HEAD(&ifnet, ifp, if_list); + NET_LOCK(); if_attachsetup(ifp); NET_UNLOCK(); } @@ -533,8 +534,9 @@ void if_attach(struct ifnet *ifp) { if_attach_common(ifp); - NET_LOCK(); + KERNEL_ASSERT_LOCKED(); TAILQ_INSERT_TAIL(&ifnet, ifp, if_list); + NET_LOCK(); if_attachsetup(ifp); NET_UNLOCK(); } @@ -1145,6 +1147,7 @@ if_detach(struct ifnet *ifp) pfi_detach_ifnet(ifp); #endif + KERNEL_ASSERT_LOCKED(); /* Remove the interface from the list of all interfaces. */ TAILQ_REMOVE(&ifnet, ifp, if_list); |