Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Wrap if_ioctl_lock with IFNET_* macros (NFC)
details: https://anonhg.NetBSD.org/src/rev/e4c95167d620
branches: trunk
changeset: 358097:e4c95167d620
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Mon Dec 11 03:29:20 2017 +0000
description:
Wrap if_ioctl_lock with IFNET_* macros (NFC)
Also if_ioctl_lock perhaps needs to be renamed to something because it's now
not just for ioctl...
diffstat:
sys/net/if.c | 38 ++++++++++++------------
sys/net/if.h | 6 +++-
sys/net/if_bridge.c | 12 +++---
sys/net/if_spppsubr.c | 16 +++++-----
sys/net/if_vlan.c | 26 ++++++++--------
sys/rump/net/lib/libnetinet/netinet_component.c | 8 ++--
6 files changed, 55 insertions(+), 51 deletions(-)
diffs (truncated from 397 to 300 lines):
diff -r dccba40b04dd -r e4c95167d620 sys/net/if.c
--- a/sys/net/if.c Mon Dec 11 03:25:45 2017 +0000
+++ b/sys/net/if.c Mon Dec 11 03:29:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.412 2017/12/11 03:25:45 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.413 2017/12/11 03:29:20 ozaki-r 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.412 2017/12/11 03:25:45 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.413 2017/12/11 03:29:20 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -1313,9 +1313,9 @@
s = splnet();
sysctl_teardown(&ifp->if_sysctl_log);
- mutex_enter(ifp->if_ioctl_lock);
+ IFNET_LOCK(ifp);
if_deactivate(ifp);
- mutex_exit(ifp->if_ioctl_lock);
+ IFNET_UNLOCK(ifp);
IFNET_GLOBAL_LOCK();
ifindex2ifnet[ifp->if_index] = NULL;
@@ -1604,9 +1604,9 @@
return ENXIO;
/* We have to disable ioctls here */
- mutex_enter(ifp->if_ioctl_lock);
+ IFNET_LOCK(ifp);
ifp->if_ioctl = if_nullioctl;
- mutex_exit(ifp->if_ioctl_lock);
+ IFNET_UNLOCK(ifp);
/*
* We cannot call ifc_destroy with holding ifp.
@@ -2486,7 +2486,7 @@
if_down_locked(struct ifnet *ifp)
{
- KASSERT(mutex_owned(ifp->if_ioctl_lock));
+ KASSERT(IFNET_LOCKED(ifp));
_if_down(ifp);
}
@@ -2499,9 +2499,9 @@
if_down(struct ifnet *ifp)
{
- mutex_enter(ifp->if_ioctl_lock);
+ IFNET_LOCK(ifp);
if_down_locked(ifp);
- mutex_exit(ifp->if_ioctl_lock);
+ IFNET_UNLOCK(ifp);
}
/*
@@ -2515,7 +2515,7 @@
#endif
struct domain *dp;
- KASSERT(mutex_owned(ifp->if_ioctl_lock));
+ KASSERT(IFNET_LOCKED(ifp));
KASSERT(!if_is_deactivated(ifp));
ifp->if_flags |= IFF_UP;
@@ -2571,9 +2571,9 @@
if_up(struct ifnet *ifp)
{
- mutex_enter(ifp->if_ioctl_lock);
+ IFNET_LOCK(ifp);
if_up_locked(ifp);
- mutex_exit(ifp->if_ioctl_lock);
+ IFNET_UNLOCK(ifp);
}
/*
@@ -2588,7 +2588,7 @@
int pcount, ret = 0;
short nflags;
- KASSERT(mutex_owned(ifp->if_ioctl_lock));
+ KASSERT(IFNET_LOCKED(ifp));
pcount = ifp->if_pcount;
if (pswitch) {
@@ -2619,9 +2619,9 @@
{
int e;
- mutex_enter(ifp->if_ioctl_lock);
+ IFNET_LOCK(ifp);
e = ifpromisc_locked(ifp, pswitch);
- mutex_exit(ifp->if_ioctl_lock);
+ IFNET_UNLOCK(ifp);
return e;
}
@@ -3195,7 +3195,7 @@
oif_flags = ifp->if_flags;
KERNEL_LOCK_UNLESS_IFP_MPSAFE(ifp);
- mutex_enter(ifp->if_ioctl_lock);
+ IFNET_LOCK(ifp);
error = (*ifp->if_ioctl)(ifp, cmd, data);
if (error != ENOTTY)
@@ -3226,7 +3226,7 @@
ifreqn2o(oifr, ifr);
#endif
- mutex_exit(ifp->if_ioctl_lock);
+ IFNET_UNLOCK(ifp);
KERNEL_UNLOCK_UNLESS_IFP_MPSAFE(ifp);
out:
if_put(ifp, &psref);
@@ -3484,7 +3484,7 @@
{
int rc;
- KASSERT(mutex_owned(ifp->if_ioctl_lock));
+ KASSERT(IFNET_LOCKED(ifp));
if (ifp->if_initaddr != NULL)
rc = (*ifp->if_initaddr)(ifp, ifa, src);
else if (src ||
@@ -3532,7 +3532,7 @@
{
int rc;
- KASSERT(mutex_owned(ifp->if_ioctl_lock));
+ KASSERT(IFNET_LOCKED(ifp));
if (ifp->if_setflags != NULL)
rc = (*ifp->if_setflags)(ifp, flags);
diff -r dccba40b04dd -r e4c95167d620 sys/net/if.h
--- a/sys/net/if.h Mon Dec 11 03:25:45 2017 +0000
+++ b/sys/net/if.h Mon Dec 11 03:29:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.252 2017/12/11 03:25:45 ozaki-r Exp $ */
+/* $NetBSD: if.h,v 1.253 2017/12/11 03:29:20 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -1227,6 +1227,10 @@
} \
} while (0)
+#define IFNET_LOCK(ifp) mutex_enter((ifp)->if_ioctl_lock)
+#define IFNET_UNLOCK(ifp) mutex_exit((ifp)->if_ioctl_lock)
+#define IFNET_LOCKED(ifp) mutex_owned((ifp)->if_ioctl_lock)
+
extern struct pslist_head ifnet_pslist;
extern kmutex_t ifnet_mtx;
diff -r dccba40b04dd -r e4c95167d620 sys/net/if_bridge.c
--- a/sys/net/if_bridge.c Mon Dec 11 03:25:45 2017 +0000
+++ b/sys/net/if_bridge.c Mon Dec 11 03:29:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bridge.c,v 1.144 2017/12/08 04:03:51 ozaki-r Exp $ */
+/* $NetBSD: if_bridge.c,v 1.145 2017/12/11 03:29:20 ozaki-r Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.144 2017/12/08 04:03:51 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.145 2017/12/11 03:29:20 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_bridge_ipf.h"
@@ -772,9 +772,9 @@
}
/* FALLTHROUGH */
case IFT_L2TP:
- mutex_enter(ifs->if_ioctl_lock);
+ IFNET_LOCK(ifs);
error = ether_enable_vlan_mtu(ifs);
- mutex_exit(ifs->if_ioctl_lock);
+ IFNET_UNLOCK(ifs);
if (error > 0)
goto out;
/*
@@ -856,9 +856,9 @@
* Don't call it with holding a spin lock.
*/
(void) ifpromisc(ifs, 0);
- mutex_enter(ifs->if_ioctl_lock);
+ IFNET_LOCK(ifs);
(void) ether_disable_vlan_mtu(ifs);
- mutex_exit(ifs->if_ioctl_lock);
+ IFNET_UNLOCK(ifs);
break;
default:
#ifdef DIAGNOSTIC
diff -r dccba40b04dd -r e4c95167d620 sys/net/if_spppsubr.c
--- a/sys/net/if_spppsubr.c Mon Dec 11 03:25:45 2017 +0000
+++ b/sys/net/if_spppsubr.c Mon Dec 11 03:29:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_spppsubr.c,v 1.176 2017/12/07 03:16:24 ozaki-r Exp $ */
+/* $NetBSD: if_spppsubr.c,v 1.177 2017/12/11 03:29:20 ozaki-r Exp $ */
/*
* Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.176 2017/12/07 03:16:24 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.177 2017/12/11 03:29:20 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@@ -5271,7 +5271,7 @@
uint32_t myaddr = 0, hisaddr = 0;
int s;
- mutex_enter(ifp->if_ioctl_lock);
+ IFNET_LOCK(ifp);
/*
* Pick the first AF_INET address from the list,
@@ -5336,7 +5336,7 @@
ifp->if_xname, ifp->if_mtu);
}
- mutex_exit(ifp->if_ioctl_lock);
+ IFNET_UNLOCK(ifp);
sppp_notify_con(sp);
}
@@ -5369,7 +5369,7 @@
struct sockaddr_in *si, *dest;
int s;
- mutex_enter(ifp->if_ioctl_lock);
+ IFNET_LOCK(ifp);
/*
* Pick the first AF_INET address from the list,
@@ -5421,7 +5421,7 @@
ifp->if_xname, ifp->if_mtu);
}
- mutex_exit(ifp->if_ioctl_lock);
+ IFNET_UNLOCK(ifp);
}
static void
@@ -5539,7 +5539,7 @@
int s;
struct psref psref;
- mutex_enter(ifp->if_ioctl_lock);
+ IFNET_LOCK(ifp);
/*
* Pick the first link-local AF_INET6 address from the list,
@@ -5579,7 +5579,7 @@
ifa_release(ifa, &psref);
}
- mutex_exit(ifp->if_ioctl_lock);
+ IFNET_UNLOCK(ifp);
}
#endif
diff -r dccba40b04dd -r e4c95167d620 sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Mon Dec 11 03:25:45 2017 +0000
+++ b/sys/net/if_vlan.c Mon Dec 11 03:29:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vlan.c,v 1.118 2017/12/08 04:03:51 ozaki-r Exp $ */
+/* $NetBSD: if_vlan.c,v 1.119 2017/12/11 03:29:20 ozaki-r Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.118 2017/12/08 04:03:51 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.119 2017/12/11 03:29:20 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -397,9 +397,9 @@
LIST_REMOVE(ifv, ifv_list);
mutex_exit(&ifv_list.lock);
- mutex_enter(ifp->if_ioctl_lock);
+ IFNET_LOCK(ifp);
vlan_unconfig(ifp);
Home |
Main Index |
Thread Index |
Old Index