Module Name: src Committed By: thorpej Date: Mon Jan 20 19:35:39 UTC 2020
Modified Files: src/sys/net: if_media.c Log Message: In ifmedia_ioctl(), go to splnet() before acquiring the KERNEL_LOCK. For non-NET_MPSAFE, this is benign, because we can nest raising to splnet(). For the NET_MPSAFE, it means that drivers don't need to raise to splnet() just in order to call ifmedia_ioctl(). To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/net/if_media.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if_media.c diff -u src/sys/net/if_media.c:1.48 src/sys/net/if_media.c:1.49 --- src/sys/net/if_media.c:1.48 Tue Oct 1 17:45:25 2019 +++ src/sys/net/if_media.c Mon Jan 20 19:35:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_media.c,v 1.48 2019/10/01 17:45:25 chs Exp $ */ +/* $NetBSD: if_media.c,v 1.49 2020/01/20 19:35:39 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.48 2019/10/01 17:45:25 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.49 2020/01/20 19:35:39 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -362,12 +362,21 @@ ifmedia_ioctl(struct ifnet *ifp, struct int e; /* - * If if_is_mpsafe(ifp), KERNEL_LOCK isn't held here, - * but ifmedia_ioctl_locked isn't MP-safe yet, so we must hold the lock. + * If if_is_mpsafe(ifp), KERNEL_LOCK isn't held here and + * ipl will not have been raised (well, maybe it has, but + * it doesn't matter), but ifmedia_ioctl_locked isn't MP-safe + * yet, so we go to splnet and grab the KERNEL_LOCK. + * + * In the non-mpsafe case, the interface's ioctl routine + * will already be running at splnet() and so raising it + * again is redundant, but also harmless. */ + int s = splnet(); KERNEL_LOCK_IF_IFP_MPSAFE(ifp); e = ifmedia_ioctl_locked(ifp, ifr, ifm, cmd); KERNEL_UNLOCK_IF_IFP_MPSAFE(ifp); + splx(s); + return e; }