From db645e7e79db9a723d92097c7bd3ab5f165640d6 Mon Sep 17 00:00:00 2001 From: kn Date: Tue, 8 Nov 2022 17:57:14 +0000 Subject: [PATCH] Push kernel lock inside ifioctl_get() After this mechanical move, I can unlock the individual SIOCG* in there. OK mvs --- sys/net/if.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 58a972b802c..74c97ecdeb4 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.667 2022/11/08 15:20:24 kn Exp $ */ +/* $OpenBSD: if.c,v 1.668 2022/11/08 17:57:14 kn Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -2426,34 +2426,44 @@ ifioctl_get(u_long cmd, caddr_t data) size_t bytesdone; const char *label; - KERNEL_LOCK(); - switch(cmd) { case SIOCGIFCONF: + KERNEL_LOCK(); NET_LOCK_SHARED(); error = ifconf(data); NET_UNLOCK_SHARED(); + KERNEL_UNLOCK(); return (error); case SIOCIFGCLONERS: + KERNEL_LOCK(); error = if_clone_list((struct if_clonereq *)data); + KERNEL_UNLOCK(); return (error); case SIOCGIFGMEMB: + KERNEL_LOCK(); NET_LOCK_SHARED(); error = if_getgroupmembers(data); NET_UNLOCK_SHARED(); + KERNEL_UNLOCK(); return (error); case SIOCGIFGATTR: + KERNEL_LOCK(); NET_LOCK_SHARED(); error = if_getgroupattribs(data); NET_UNLOCK_SHARED(); + KERNEL_UNLOCK(); return (error); case SIOCGIFGLIST: + KERNEL_LOCK(); NET_LOCK_SHARED(); error = if_getgrouplist(data); NET_UNLOCK_SHARED(); + KERNEL_UNLOCK(); return (error); } + KERNEL_LOCK(); + ifp = if_unit(ifr->ifr_name); if (ifp == NULL) { KERNEL_UNLOCK(); -- 2.20.1