Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[.joined/src/trunk]: .joined/src/sys/net sys/net: Assert IFNET_LOCKED in if_i...
details: https://anonhg.NetBSD.org/.joined/src/rev/44429a23c36c
branches: trunk
changeset: 359345:44429a23c36c
user: riastradh <riastradh%NetBSD.org@localhost>
date: Fri Dec 31 14:25:58 2021 +0000
description:
sys/net: Assert IFNET_LOCKED in if_ioctl, if_init, and if_stop.
Exception: Not for SIOCADDMULTI/SIOCDELMULTI, for which it is the
driver's responsibility to take internal locks. Typically this is
already done via struct ethercom::ec_lock.
diffstat:
sys/net/if.c | 29 ++++++++++++++++++-----------
1 files changed, 18 insertions(+), 11 deletions(-)
diffs (76 lines):
diff -r 105be8f5c7a7 -r 44429a23c36c sys/net/if.c
--- a/sys/net/if.c Fri Dec 31 14:25:47 2021 +0000
+++ b/sys/net/if.c Fri Dec 31 14:25:58 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.498 2021/12/31 14:24:50 riastradh Exp $ */
+/* $NetBSD: if.c,v 1.499 2021/12/31 14:25:58 riastradh Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.498 2021/12/31 14:24:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.499 2021/12/31 14:25:58 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -2733,13 +2733,25 @@
* Apply an ioctl command to the interface. Returns 0 on success,
* nonzero errno(3) number on failure.
*
- * May sleep. Caller must hold ifp->if_ioctl_lock.
+ * For SIOCADDMULTI/SIOCDELMULTI, caller need not hold locks -- it
+ * is the driver's responsibility to take any internal locks.
+ * (Kernel logic should generally invoke these only through
+ * if_mcast_op.)
+ *
+ * For all other ioctls, caller must hold ifp->if_ioctl_lock,
+ * a.k.a. IFNET_LOCK. May sleep.
*/
int
if_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
- KASSERT(1 || IFNET_LOCKED(ifp)); /* XXX not yet */
+ switch (cmd) {
+ case SIOCADDMULTI:
+ case SIOCDELMULTI:
+ break;
+ default:
+ KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
+ }
return (*ifp->if_ioctl)(ifp, cmd, data);
}
@@ -2758,7 +2770,7 @@
if_init(struct ifnet *ifp)
{
- KASSERT(1 || IFNET_LOCKED(ifp)); /* XXX not yet */
+ KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
return (*ifp->if_init)(ifp);
}
@@ -2777,7 +2789,7 @@
if_stop(struct ifnet *ifp, int disable)
{
- KASSERT(1 || IFNET_LOCKED(ifp)); /* XXX not yet */
+ KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
(*ifp->if_stop)(ifp, disable);
}
@@ -3864,11 +3876,6 @@
int rc;
struct ifreq ifr;
- /*
- * XXX NOMPSAFE - this calls if_ioctl without holding IFNET_LOCK()
- * in some cases - e.g. when called from vlan/netinet/netinet6 code
- * directly rather than via doifoictl()
- */
ifreq_setaddr(cmd, &ifr, sa);
rc = if_ioctl(ifp, cmd, &ifr);
Home |
Main Index |
Thread Index |
Old Index