From 7e119dafdd61b2a9d6ea84db9e635de73872d169 Mon Sep 17 00:00:00 2001 From: kn Date: Fri, 21 Oct 2022 14:20:03 +0000 Subject: [PATCH] Grab the non-exclusive net lock to read-only traverse the interface list Destroying lo(4) interfaces checks for other interfaces in the same rdomain(4) first which does not modify anything, so allow other readers. All interface ioctl(2)s currently run with the kernel lock held, so this should not make a real difference... OK mvs --- sys/net/if_loop.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index a15820420ef..4077198b637 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_loop.c,v 1.92 2022/09/08 10:22:06 kn Exp $ */ +/* $OpenBSD: if_loop.c,v 1.93 2022/10/21 14:20:03 kn Exp $ */ /* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */ /* @@ -204,16 +204,16 @@ loop_clone_destroy(struct ifnet *ifp) return (EPERM); /* if there is any other interface in this rdomain, deny */ - NET_LOCK(); + NET_LOCK_SHARED(); TAILQ_FOREACH(p, &ifnetlist, if_list) { if (p->if_rdomain != ifp->if_rdomain) continue; if (p->if_index == ifp->if_index) continue; - NET_UNLOCK(); + NET_UNLOCK_SHARED(); return (EBUSY); } - NET_UNLOCK(); + NET_UNLOCK_SHARED(); rdomain = ifp->if_rdomain; } -- 2.20.1