Module Name: src Committed By: jdolecek Date: Tue May 12 10:02:56 UTC 2020
Modified Files: src/sys/kern: kern_pmf.c Log Message: need to take IFNET_LOCK() around if_stop (on suspend) and if_init (on resume) calls, those need to read and/or manipulate if_flags and hence need the lock for IFEF_MPSAFE drivers; the drivers can't do IFNET_LOCK() themselves, because the ioctl path call these hooks with the lock held fixes KASSERT() in xennet(4) while investigating PR port-xen/55207 To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/kern/kern_pmf.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/kern/kern_pmf.c diff -u src/sys/kern/kern_pmf.c:1.42 src/sys/kern/kern_pmf.c:1.43 --- src/sys/kern/kern_pmf.c:1.42 Mon Apr 20 21:39:05 2020 +++ src/sys/kern/kern_pmf.c Tue May 12 10:02:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_pmf.c,v 1.42 2020/04/20 21:39:05 ad Exp $ */ +/* $NetBSD: kern_pmf.c,v 1.43 2020/05/12 10:02:56 jdolecek Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.42 2020/04/20 21:39:05 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.43 2020/05/12 10:02:56 jdolecek Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -893,7 +893,9 @@ pmf_class_network_suspend(device_t dev, int s; s = splnet(); + IFNET_LOCK(ifp); (*ifp->if_stop)(ifp, 0); + IFNET_UNLOCK(ifp); splx(s); return true; @@ -904,14 +906,21 @@ pmf_class_network_resume(device_t dev, c { struct ifnet *ifp = device_pmf_class_private(dev); int s; + bool restart = false; s = splnet(); + IFNET_LOCK(ifp); if (ifp->if_flags & IFF_UP) { ifp->if_flags &= ~IFF_RUNNING; if ((*ifp->if_init)(ifp) != 0) aprint_normal_ifnet(ifp, "resume failed\n"); - if_start_lock(ifp); + restart = true; } + IFNET_UNLOCK(ifp); + + if (restart) + if_start_lock(ifp); + splx(s); return true;