summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2017-08-11 21:24:19 +0000
committermpi <mpi@openbsd.org>2017-08-11 21:24:19 +0000
commitaa28b9a6d024fc39940a8bf6e59c28dbaafc6950 (patch)
treead38cdfb637269384ad7ff4acea0c6e8e71932a7 /sys/net
parentBe consistent with goto labels, failure flag and use of FAIL macro. (diff)
downloadwireguard-openbsd-aa28b9a6d024fc39940a8bf6e59c28dbaafc6950.tar.xz
wireguard-openbsd-aa28b9a6d024fc39940a8bf6e59c28dbaafc6950.zip
Remove NET_LOCK()'s argument.
Tested by Hrvoje Popovski, ok bluhm@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/bpf.c8
-rw-r--r--sys/net/if.c55
-rw-r--r--sys/net/if_enc.c17
-rw-r--r--sys/net/if_gif.c12
-rw-r--r--sys/net/if_gre.c17
-rw-r--r--sys/net/if_pflog.c15
-rw-r--r--sys/net/if_pflow.c13
-rw-r--r--sys/net/if_pfsync.c25
-rw-r--r--sys/net/if_ppp.c25
-rw-r--r--sys/net/if_pppoe.c18
-rw-r--r--sys/net/if_pppx.c13
-rw-r--r--sys/net/if_spppsubr.c24
-rw-r--r--sys/net/if_trunk.c10
-rw-r--r--sys/net/if_tun.c26
-rw-r--r--sys/net/if_vxlan.c7
-rw-r--r--sys/net/pf.c7
-rw-r--r--sys/net/pf_ioctl.c7
-rw-r--r--sys/net/pfkeyv2.c8
-rw-r--r--sys/net/pipex.c13
-rw-r--r--sys/net/route.c7
-rw-r--r--sys/net/rtsock.c7
-rw-r--r--sys/net/switchctl.c6
22 files changed, 151 insertions, 189 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 2d8ebb7bbda..21f1799cbf6 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.163 2017/05/24 16:26:58 bluhm Exp $ */
+/* $OpenBSD: bpf.c,v 1.164 2017/08/11 21:24:19 mpi Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -580,7 +580,7 @@ bpfwrite(dev_t dev, struct uio *uio, int ioflag)
struct mbuf *m;
struct bpf_program *bf;
struct bpf_insn *fcode = NULL;
- int error, s;
+ int error;
struct sockaddr_storage dst;
u_int dlt;
@@ -626,9 +626,9 @@ bpfwrite(dev_t dev, struct uio *uio, int ioflag)
if (d->bd_hdrcmplt && dst.ss_family == AF_UNSPEC)
dst.ss_family = pseudo_AF_HDRCMPLT;
- NET_LOCK(s);
+ NET_LOCK();
error = ifp->if_output(ifp, m, sstosa(&dst), NULL);
- NET_UNLOCK(s);
+ NET_UNLOCK();
out:
bpf_put(d);
diff --git a/sys/net/if.c b/sys/net/if.c
index f65b0d3800f..0f75f4e229a 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.509 2017/08/10 16:48:25 bluhm Exp $ */
+/* $OpenBSD: if.c,v 1.510 2017/08/11 21:24:19 mpi Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -511,25 +511,21 @@ if_attachdomain(struct ifnet *ifp)
void
if_attachhead(struct ifnet *ifp)
{
- int s;
-
if_attach_common(ifp);
- NET_LOCK(s);
+ NET_LOCK();
TAILQ_INSERT_HEAD(&ifnet, ifp, if_list);
if_attachsetup(ifp);
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
void
if_attach(struct ifnet *ifp)
{
- int s;
-
if_attach_common(ifp);
- NET_LOCK(s);
+ NET_LOCK();
TAILQ_INSERT_TAIL(&ifnet, ifp, if_list);
if_attachsetup(ifp);
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
void
@@ -875,7 +871,7 @@ if_input_process(void *xifidx)
struct ifnet *ifp;
struct ifih *ifih;
struct srp_ref sr;
- int s, s2;
+ int s;
#ifdef IPSEC
int locked = 0;
#endif /* IPSEC */
@@ -916,7 +912,7 @@ if_input_process(void *xifidx)
* to PF globals, pipex globals, unicast and multicast addresses
* lists.
*/
- NET_LOCK(s2);
+ NET_LOCK();
s = splnet();
while ((m = ml_dequeue(&ml)) != NULL) {
/*
@@ -933,7 +929,7 @@ if_input_process(void *xifidx)
m_freem(m);
}
splx(s);
- NET_UNLOCK(s2);
+ NET_UNLOCK();
#ifdef IPSEC
if (locked)
@@ -947,17 +943,16 @@ void
if_netisr(void *unused)
{
int n, t = 0;
- int s;
KERNEL_LOCK();
- NET_LOCK(s);
+ NET_LOCK();
while ((n = netisr) != 0) {
/* Like sched_pause() but with a rwlock dance. */
if (curcpu()->ci_schedstate.spc_schedflags & SPCF_SHOULDYIELD) {
- NET_UNLOCK(s);
+ NET_UNLOCK();
yield();
- NET_LOCK(s);
+ NET_LOCK();
}
atomic_clearbits_int(&netisr, n);
@@ -1000,16 +995,14 @@ if_netisr(void *unused)
pfsyncintr();
#endif
- NET_UNLOCK(s);
+ NET_UNLOCK();
KERNEL_UNLOCK();
}
void
if_deactivate(struct ifnet *ifp)
{
- int s;
-
- NET_LOCK(s);
+ NET_LOCK();
/*
* Call detach hooks from head to tail. To make sure detach
* hooks are executed in the reverse order they were added, all
@@ -1022,7 +1015,7 @@ if_deactivate(struct ifnet *ifp)
if (ifp->if_carp && ifp->if_type != IFT_CARP)
carp_ifdetach(ifp);
#endif
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
/*
@@ -1035,7 +1028,7 @@ if_detach(struct ifnet *ifp)
struct ifaddr *ifa;
struct ifg_list *ifg;
struct domain *dp;
- int i, s, s2;
+ int i, s;
/* Undo pseudo-driver changes. */
if_deactivate(ifp);
@@ -1045,8 +1038,8 @@ if_detach(struct ifnet *ifp)
/* Other CPUs must not have a reference before we start destroying. */
if_idxmap_remove(ifp);
- NET_LOCK(s);
- s2 = splnet();
+ NET_LOCK();
+ s = splnet();
ifp->if_qstart = if_detached_qstart;
ifp->if_ioctl = if_detached_ioctl;
ifp->if_watchdog = NULL;
@@ -1118,8 +1111,8 @@ if_detach(struct ifnet *ifp)
/* Announce that the interface is gone. */
rtm_ifannounce(ifp, IFAN_DEPARTURE);
- splx(s2);
- NET_UNLOCK(s);
+ splx(s);
+ NET_UNLOCK();
for (i = 0; i < ifp->if_nifqs; i++)
ifq_destroy(ifp->if_ifqs[i]);
@@ -1523,9 +1516,8 @@ if_downall(void)
{
struct ifreq ifrq; /* XXX only partly built */
struct ifnet *ifp;
- int s;
- NET_LOCK(s);
+ NET_LOCK();
TAILQ_FOREACH(ifp, &ifnet, if_list) {
if ((ifp->if_flags & IFF_UP) == 0)
continue;
@@ -1536,7 +1528,7 @@ if_downall(void)
(caddr_t)&ifrq);
}
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
/*
@@ -1585,17 +1577,16 @@ if_linkstate_task(void *xifidx)
{
unsigned int ifidx = (unsigned long)xifidx;
struct ifnet *ifp;
- int s;
KERNEL_LOCK();
- NET_LOCK(s);
+ NET_LOCK();
ifp = if_get(ifidx);
if (ifp != NULL)
if_linkstate(ifp);
if_put(ifp);
- NET_UNLOCK(s);
+ NET_UNLOCK();
KERNEL_UNLOCK();
}
diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c
index a12ce47e2d1..35454fce639 100644
--- a/sys/net/if_enc.c
+++ b/sys/net/if_enc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_enc.c,v 1.68 2017/05/28 09:35:13 mpi Exp $ */
+/* $OpenBSD: if_enc.c,v 1.69 2017/08/11 21:24:19 mpi Exp $ */
/*
* Copyright (c) 2010 Reyk Floeter <reyk@vantronix.net>
@@ -72,7 +72,7 @@ enc_clone_create(struct if_clone *ifc, int unit)
struct ifnet *ifp;
struct ifnet **new;
size_t newlen;
- int s, error;
+ int error;
if (unit > ENC_MAX_UNITS)
return (EINVAL);
@@ -111,10 +111,10 @@ enc_clone_create(struct if_clone *ifc, int unit)
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_ENC, ENC_HDRLEN);
#endif
- NET_LOCK(s);
+ NET_LOCK();
error = enc_setif(ifp, 0);
if (error != 0) {
- NET_UNLOCK(s);
+ NET_UNLOCK();
if_detach(ifp);
free(sc, M_DEVBUF, 0);
return (error);
@@ -123,7 +123,7 @@ enc_clone_create(struct if_clone *ifc, int unit)
if (unit == 0 || unit > enc_max_unit) {
if ((new = mallocarray(unit + 1, sizeof(struct ifnet *),
M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) {
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (ENOBUFS);
}
newlen = sizeof(struct ifnet *) * (unit + 1);
@@ -137,7 +137,7 @@ enc_clone_create(struct if_clone *ifc, int unit)
enc_max_unit = unit;
}
enc_allifps[unit] = ifp;
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (0);
}
@@ -146,16 +146,15 @@ int
enc_clone_destroy(struct ifnet *ifp)
{
struct enc_softc *sc = ifp->if_softc;
- int s;
/* Protect users from removing enc0 */
if (sc->sc_unit == 0)
return (EPERM);
- NET_LOCK(s);
+ NET_LOCK();
enc_allifps[sc->sc_unit] = NULL;
enc_unsetif(ifp);
- NET_UNLOCK(s);
+ NET_UNLOCK();
if_detach(ifp);
free(sc, M_DEVBUF, 0);
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index 3b46296a63e..fa06072f877 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gif.c,v 1.98 2017/06/20 11:12:13 bluhm Exp $ */
+/* $OpenBSD: if_gif.c,v 1.99 2017/08/11 21:24:19 mpi Exp $ */
/* $KAME: if_gif.c,v 1.43 2001/02/20 08:51:07 itojun Exp $ */
/*
@@ -106,7 +106,6 @@ int
gif_clone_create(struct if_clone *ifc, int unit)
{
struct gif_softc *sc;
- int s;
sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!sc)
@@ -130,9 +129,9 @@ gif_clone_create(struct if_clone *ifc, int unit)
#if NBPFILTER > 0
bpfattach(&sc->gif_if.if_bpf, &sc->gif_if, DLT_LOOP, sizeof(u_int32_t));
#endif
- NET_LOCK(s);
+ NET_LOCK();
LIST_INSERT_HEAD(&gif_softc_list, sc, gif_list);
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (0);
}
@@ -141,11 +140,10 @@ int
gif_clone_destroy(struct ifnet *ifp)
{
struct gif_softc *sc = ifp->if_softc;
- int s;
- NET_LOCK(s);
+ NET_LOCK();
LIST_REMOVE(sc, gif_list);
- NET_UNLOCK(s);
+ NET_UNLOCK();
if_detach(ifp);
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index b3d24c1f988..b13acbb0eb0 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gre.c,v 1.86 2017/05/15 14:33:20 bluhm Exp $ */
+/* $OpenBSD: if_gre.c,v 1.87 2017/08/11 21:24:19 mpi Exp $ */
/* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
@@ -121,7 +121,6 @@ int
gre_clone_create(struct if_clone *ifc, int unit)
{
struct gre_softc *sc;
- int s;
sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!sc)
@@ -163,9 +162,9 @@ gre_clone_create(struct if_clone *ifc, int unit)
#if NBPFILTER > 0
bpfattach(&sc->sc_if.if_bpf, &sc->sc_if, DLT_LOOP, sizeof(u_int32_t));
#endif
- NET_LOCK(s);
+ NET_LOCK();
LIST_INSERT_HEAD(&gre_softc_list, sc, sc_list);
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (0);
}
@@ -174,13 +173,12 @@ int
gre_clone_destroy(struct ifnet *ifp)
{
struct gre_softc *sc = ifp->if_softc;
- int s;
timeout_del(&sc->sc_ka_snd);
timeout_del(&sc->sc_ka_hold);
- NET_LOCK(s);
+ NET_LOCK();
LIST_REMOVE(sc, sc_list);
- NET_UNLOCK(s);
+ NET_UNLOCK();
if_detach(ifp);
@@ -612,7 +610,6 @@ gre_send_keepalive(void *arg)
struct ip *ip;
struct gre_h *gh;
struct sockaddr dst;
- int s;
if (sc->sc_ka_timout)
timeout_add_sec(&sc->sc_ka_snd, sc->sc_ka_timout);
@@ -658,10 +655,10 @@ gre_send_keepalive(void *arg)
bzero(&dst, sizeof(dst));
dst.sa_family = AF_INET;
- NET_LOCK(s);
+ NET_LOCK();
/* should we care about the error? */
gre_output(&sc->sc_if, m, &dst, NULL);
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
void
diff --git a/sys/net/if_pflog.c b/sys/net/if_pflog.c
index fc8e1c60b3c..89473110cd0 100644
--- a/sys/net/if_pflog.c
+++ b/sys/net/if_pflog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pflog.c,v 1.79 2017/05/16 11:35:36 mpi Exp $ */
+/* $OpenBSD: if_pflog.c,v 1.80 2017/08/11 21:24:19 mpi Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -136,7 +136,6 @@ pflog_clone_create(struct if_clone *ifc, int unit)
{
struct ifnet *ifp;
struct pflog_softc *pflogif;
- int s;
if ((pflogif = malloc(sizeof(*pflogif),
M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL)
@@ -161,13 +160,13 @@ pflog_clone_create(struct if_clone *ifc, int unit)
bpfattach(&pflogif->sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN);
#endif
- NET_LOCK(s);
+ NET_LOCK();
if (unit + 1 > npflogifs && pflogifs_resize(unit + 1) != 0) {
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (ENOMEM);
}
pflogifs[unit] = ifp;
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (0);
}
@@ -176,15 +175,15 @@ int
pflog_clone_destroy(struct ifnet *ifp)
{
struct pflog_softc *pflogif = ifp->if_softc;
- int s, i;
+ int i;
- NET_LOCK(s);
+ NET_LOCK();
pflogifs[pflogif->sc_unit] = NULL;
for (i = npflogifs; i > 0 && pflogifs[i - 1] == NULL; i--)
; /* nothing */
if (i < npflogifs)
pflogifs_resize(i); /* error harmless here */
- NET_UNLOCK(s);
+ NET_UNLOCK();
if_detach(ifp);
free(pflogif, M_DEVBUF, 0);
diff --git a/sys/net/if_pflow.c b/sys/net/if_pflow.c
index 64a7e916a51..1a89cbd111a 100644
--- a/sys/net/if_pflow.c
+++ b/sys/net/if_pflow.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pflow.c,v 1.81 2017/08/10 19:20:43 mpi Exp $ */
+/* $OpenBSD: if_pflow.c,v 1.82 2017/08/11 21:24:19 mpi Exp $ */
/*
* Copyright (c) 2011 Florian Obser <florian@narrans.de>
@@ -145,7 +145,6 @@ pflow_clone_create(struct if_clone *ifc, int unit)
{
struct ifnet *ifp;
struct pflow_softc *pflowif;
- int s;
if ((pflowif = malloc(sizeof(*pflowif),
M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL)
@@ -267,9 +266,9 @@ pflow_clone_create(struct if_clone *ifc, int unit)
task_set(&pflowif->sc_outputtask, pflow_output_process, pflowif);
/* Insert into list of pflows */
- NET_LOCK(s);
+ NET_LOCK();
SLIST_INSERT_HEAD(&pflowif_list, pflowif, sc_next);
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (0);
}
@@ -277,7 +276,7 @@ int
pflow_clone_destroy(struct ifnet *ifp)
{
struct pflow_softc *sc = ifp->if_softc;
- int s, error;
+ int error;
error = 0;
@@ -300,9 +299,9 @@ pflow_clone_destroy(struct ifnet *ifp)
if (sc->sc_flowsrc != NULL)
free(sc->sc_flowsrc, M_DEVBUF, sc->sc_flowsrc->sa_len);
if_detach(ifp);
- NET_LOCK(s);
+ NET_LOCK();
SLIST_REMOVE(&pflowif_list, sc, pflow_softc, sc_next);
- NET_UNLOCK(s);
+ NET_UNLOCK();
free(sc, M_DEVBUF, sizeof(*sc));
return (error);
}
diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c
index bda5a865a42..bd5261c5192 100644
--- a/sys/net/if_pfsync.c
+++ b/sys/net/if_pfsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pfsync.c,v 1.253 2017/06/09 17:43:06 sashan Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.254 2017/08/11 21:24:19 mpi Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
@@ -1794,11 +1794,9 @@ pfsync_undefer(struct pfsync_deferral *pd, int drop)
void
pfsync_defer_tmo(void *arg)
{
- int s;
-
- NET_LOCK(s);
+ NET_LOCK();
pfsync_undefer(arg, 0);
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
void
@@ -2212,9 +2210,8 @@ pfsync_bulk_update(void *arg)
struct pfsync_softc *sc = arg;
struct pf_state *st;
int i = 0;
- int s;
- NET_LOCK(s);
+ NET_LOCK();
st = sc->sc_bulk_next;
for (;;) {
@@ -2245,7 +2242,7 @@ pfsync_bulk_update(void *arg)
break;
}
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
void
@@ -2275,10 +2272,8 @@ void
pfsync_bulk_fail(void *arg)
{
struct pfsync_softc *sc = arg;
- int s;
-
- NET_LOCK(s);
+ NET_LOCK();
if (sc->sc_bulk_tries++ < PFSYNC_MAX_BULKTRIES) {
/* Try again */
timeout_add_sec(&sc->sc_bulkfail_tmo, 5);
@@ -2303,7 +2298,7 @@ pfsync_bulk_fail(void *arg)
sc->sc_link_demoted = 0;
DPFPRINTF(LOG_ERR, "failed to receive bulk update");
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
void
@@ -2350,11 +2345,9 @@ pfsync_state_in_use(struct pf_state *st)
void
pfsync_timeout(void *arg)
{
- int s;
-
- NET_LOCK(s);
+ NET_LOCK();
pfsync_sendout();
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
/* this is a softnet/netisr handler */
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index fb970b1302f..500eb6014c9 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ppp.c,v 1.108 2017/05/30 07:50:37 mpi Exp $ */
+/* $OpenBSD: if_ppp.c,v 1.109 2017/08/11 21:24:19 mpi Exp $ */
/* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */
/*
@@ -204,7 +204,6 @@ int
ppp_clone_create(struct if_clone *ifc, int unit)
{
struct ppp_softc *sc;
- int s;
sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!sc)
@@ -230,9 +229,9 @@ ppp_clone_create(struct if_clone *ifc, int unit)
#if NBPFILTER > 0
bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
#endif
- NET_LOCK(s);
+ NET_LOCK();
LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_list);
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (0);
}
@@ -241,14 +240,13 @@ int
ppp_clone_destroy(struct ifnet *ifp)
{
struct ppp_softc *sc = ifp->if_softc;
- int s;
if (sc->sc_devp != NULL)
return (EBUSY);
- NET_LOCK(s);
+ NET_LOCK();
LIST_REMOVE(sc, sc_list);
- NET_UNLOCK(s);
+ NET_UNLOCK();
if_detach(ifp);
@@ -262,14 +260,14 @@ ppp_clone_destroy(struct ifnet *ifp)
struct ppp_softc *
pppalloc(pid_t pid)
{
- int i, s;
+ int i;
struct ppp_softc *sc;
- NET_LOCK(s);
+ NET_LOCK();
LIST_FOREACH(sc, &ppp_softc_list, sc_list) {
if (sc->sc_xfer == pid) {
sc->sc_xfer = 0;
- NET_UNLOCK(s);
+ NET_UNLOCK();
return sc;
}
}
@@ -277,7 +275,7 @@ pppalloc(pid_t pid)
if (sc->sc_devp == NULL)
break;
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
if (sc == NULL)
return NULL;
@@ -309,9 +307,8 @@ void
pppdealloc(struct ppp_softc *sc)
{
struct ppp_pkt *pkt;
- int s;
- NET_LOCK(s);
+ NET_LOCK();
if_down(&sc->sc_if);
sc->sc_if.if_flags &= ~IFF_RUNNING;
sc->sc_devp = NULL;
@@ -346,7 +343,7 @@ pppdealloc(struct ppp_softc *sc)
sc->sc_comp = 0;
}
#endif
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
/*
diff --git a/sys/net/if_pppoe.c b/sys/net/if_pppoe.c
index 04116ef1ee2..39454f012e0 100644
--- a/sys/net/if_pppoe.c
+++ b/sys/net/if_pppoe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pppoe.c,v 1.63 2017/07/19 06:59:16 claudio Exp $ */
+/* $OpenBSD: if_pppoe.c,v 1.64 2017/08/11 21:24:19 mpi Exp $ */
/* $NetBSD: if_pppoe.c,v 1.51 2003/11/28 08:56:48 keihan Exp $ */
/*
@@ -196,7 +196,6 @@ pppoe_clone_create(struct if_clone *ifc, int unit)
{
struct pppoe_softc *sc, *tmpsc;
u_int32_t unique;
- int s;
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_CANFAIL|M_ZERO);
if (sc == NULL)
@@ -232,7 +231,7 @@ pppoe_clone_create(struct if_clone *ifc, int unit)
bpfattach(&sc->sc_sppp.pp_if.if_bpf, &sc->sc_sppp.pp_if, DLT_PPP_ETHER, 0);
#endif
- NET_LOCK(s);
+ NET_LOCK();
retry:
unique = arc4random();
LIST_FOREACH(tmpsc, &pppoe_softc_list, sc_list)
@@ -240,7 +239,7 @@ retry:
goto retry;
sc->sc_unique = unique;
LIST_INSERT_HEAD(&pppoe_softc_list, sc, sc_list);
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (0);
}
@@ -250,11 +249,10 @@ int
pppoe_clone_destroy(struct ifnet *ifp)
{
struct pppoe_softc *sc = ifp->if_softc;
- int s;
- NET_LOCK(s);
+ NET_LOCK();
LIST_REMOVE(sc, sc_list);
- NET_UNLOCK(s);
+ NET_UNLOCK();
timeout_del(&sc->sc_timeout);
@@ -1054,11 +1052,11 @@ static void
pppoe_timeout(void *arg)
{
struct pppoe_softc *sc = (struct pppoe_softc *)arg;
- int s, x, retry_wait, err;
+ int x, retry_wait, err;
PPPOEDEBUG(("%s: timeout\n", sc->sc_sppp.pp_if.if_xname));
- NET_LOCK(s);
+ NET_LOCK();
switch (sc->sc_state) {
case PPPOE_STATE_PADI_SENT:
@@ -1130,7 +1128,7 @@ pppoe_timeout(void *arg)
break; /* all done, work in peace */
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
/* Start a connection (i.e. initiate discovery phase). */
diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c
index 1bb9e45dc2f..aac69060956 100644
--- a/sys/net/if_pppx.c
+++ b/sys/net/if_pppx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pppx.c,v 1.61 2017/05/30 07:50:37 mpi Exp $ */
+/* $OpenBSD: if_pppx.c,v 1.62 2017/08/11 21:24:19 mpi Exp $ */
/*
* Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org>
@@ -277,7 +277,6 @@ pppxread(dev_t dev, struct uio *uio, int ioflag)
struct pppx_dev *pxd = pppx_dev2pxd(dev);
struct mbuf *m, *m0;
int error = 0;
- int s;
size_t len;
if (!pxd)
@@ -287,11 +286,11 @@ pppxread(dev_t dev, struct uio *uio, int ioflag)
if (ISSET(ioflag, IO_NDELAY))
return (EWOULDBLOCK);
- NET_LOCK(s);
+ NET_LOCK();
pxd->pxd_waiting = 1;
error = rwsleep(pxd, &netlock,
(PZERO + 1)|PCATCH, "pppxread", 0);
- NET_UNLOCK(s);
+ NET_UNLOCK();
if (error != 0) {
return (error);
}
@@ -414,9 +413,9 @@ int
pppxioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
{
struct pppx_dev *pxd = pppx_dev2pxd(dev);
- int s, error = 0;
+ int error = 0;
- NET_LOCK(s);
+ NET_LOCK();
switch (cmd) {
case PIPEXSMODE:
/*
@@ -466,7 +465,7 @@ pppxioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
error = ENOTTY;
break;
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (error);
}
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index e2d759c0044..4b541535bda 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_spppsubr.c,v 1.169 2017/08/11 15:13:25 reyk Exp $ */
+/* $OpenBSD: if_spppsubr.c,v 1.170 2017/08/11 21:24:19 mpi Exp $ */
/*
* Synchronous PPP link level subroutines.
*
@@ -4048,10 +4048,10 @@ void
sppp_keepalive(void *dummy)
{
struct sppp *sp;
- int s, sl;
+ int s;
struct timeval tv;
- NET_LOCK(sl);
+ NET_LOCK();
s = splnet();
getmicrouptime(&tv);
for (sp=spppq; sp; sp=sp->pp_next) {
@@ -4103,7 +4103,7 @@ sppp_keepalive(void *dummy)
}
}
splx(s);
- NET_UNLOCK(sl);
+ NET_UNLOCK();
timeout_add_sec(&keepalive_ch, 10);
}
@@ -4192,7 +4192,6 @@ sppp_set_ip_addrs(void *arg1)
struct ifaddr *ifa;
struct sockaddr_in *si;
struct sockaddr_in *dest;
- int s;
sppp_get_ip_addrs(sp, &myaddr, &hisaddr, NULL);
if ((sp->ipcp.flags & IPCP_MYADDR_DYN) &&
@@ -4203,7 +4202,7 @@ sppp_set_ip_addrs(void *arg1)
hisaddr = sp->ipcp.req_hisaddr;
- NET_LOCK(s);
+ NET_LOCK();
/*
* Pick the first AF_INET address from the list,
* aliases don't make any sense on a p2p link anyway.
@@ -4247,7 +4246,7 @@ sppp_set_ip_addrs(void *arg1)
sppp_update_gw(ifp);
}
out:
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
/*
@@ -4264,9 +4263,8 @@ sppp_clear_ip_addrs(void *arg1)
struct sockaddr_in *si;
struct sockaddr_in *dest;
u_int32_t remote;
- int s;
- NET_LOCK(s);
+ NET_LOCK();
if (sp->ipcp.flags & IPCP_HISADDR_DYN)
remote = sp->ipcp.saved_hisaddr;
@@ -4308,7 +4306,7 @@ sppp_clear_ip_addrs(void *arg1)
sppp_update_gw(ifp);
}
out:
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
@@ -4359,9 +4357,9 @@ sppp_update_ip6_addr(void *arg)
struct in6_aliasreq *ifra = &sp->ipv6cp.req_ifid;
struct in6_addr mask = in6mask128;
struct in6_ifaddr *ia6;
- int s, error;
+ int error;
- NET_LOCK(s);
+ NET_LOCK();
ia6 = in6ifa_ifpforlinklocal(ifp, 0);
if (ia6 == NULL) {
@@ -4402,7 +4400,7 @@ sppp_update_ip6_addr(void *arg)
SPP_ARGS(ifp), error);
}
out:
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
/*
diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c
index d9a6d9995ee..7b2c6ad676c 100644
--- a/sys/net/if_trunk.c
+++ b/sys/net/if_trunk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_trunk.c,v 1.132 2017/05/28 15:03:53 mpi Exp $ */
+/* $OpenBSD: if_trunk.c,v 1.133 2017/08/11 21:24:19 mpi Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -210,20 +210,20 @@ trunk_clone_destroy(struct ifnet *ifp)
{
struct trunk_softc *tr = (struct trunk_softc *)ifp->if_softc;
struct trunk_port *tp;
- int s, error;
+ int error;
/* Remove any multicast groups that we may have joined. */
trunk_ether_purgemulti(tr);
/* Shutdown and remove trunk ports, return on error */
- NET_LOCK(s);
+ NET_LOCK();
while ((tp = SLIST_FIRST(&tr->tr_ports)) != NULL) {
if ((error = trunk_port_destroy(tp)) != 0) {
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (error);
}
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
ifmedia_delete_instance(&tr->tr_media, IFM_INST_ANY);
ether_ifdetach(ifp);
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 80eaabff78e..eabbaad9236 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.177 2017/06/03 11:58:54 mpi Exp $ */
+/* $OpenBSD: if_tun.c,v 1.178 2017/08/11 21:24:19 mpi Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -309,12 +309,12 @@ tunopen(dev_t dev, int flag, int mode, struct proc *p)
if ((tp = tun_lookup(minor(dev))) == NULL) { /* create on demand */
char xname[IFNAMSIZ];
- int s, error;
+ int error;
snprintf(xname, sizeof(xname), "%s%d", "tun", minor(dev));
- NET_LOCK(s);
+ NET_LOCK();
error = if_clone_create(xname, rdomain);
- NET_UNLOCK(s);
+ NET_UNLOCK();
if (error != 0)
return (error);
@@ -334,12 +334,12 @@ tapopen(dev_t dev, int flag, int mode, struct proc *p)
if ((tp = tap_lookup(minor(dev))) == NULL) { /* create on demand */
char xname[IFNAMSIZ];
- int s, error;
+ int error;
snprintf(xname, sizeof(xname), "%s%d", "tap", minor(dev));
- NET_LOCK(s);
+ NET_LOCK();
error = if_clone_create(xname, rdomain);
- NET_UNLOCK(s);
+ NET_UNLOCK();
if (error != 0)
return (error);
@@ -399,7 +399,7 @@ tapclose(dev_t dev, int flag, int mode, struct proc *p)
int
tun_dev_close(struct tun_softc *tp, int flag, int mode, struct proc *p)
{
- int s, error = 0;
+ int error = 0;
struct ifnet *ifp;
ifp = &tp->tun_if;
@@ -415,9 +415,9 @@ tun_dev_close(struct tun_softc *tp, int flag, int mode, struct proc *p)
TUNDEBUG(("%s: closed\n", ifp->if_xname));
if (!(tp->tun_flags & TUN_STAYUP)) {
- NET_LOCK(s);
+ NET_LOCK();
error = if_clone_destroy(ifp->if_xname);
- NET_UNLOCK(s);
+ NET_UNLOCK();
} else {
tp->tun_pgid = 0;
selwakeup(&tp->tun_rsel);
@@ -837,7 +837,7 @@ tun_dev_write(struct tun_softc *tp, struct uio *uio, int ioflag)
struct ifnet *ifp;
u_int32_t *th;
struct mbuf *top, **mp, *m;
- int error = 0, tlen, s;
+ int error = 0, tlen;
size_t mlen;
ifp = &tp->tun_if;
@@ -930,7 +930,7 @@ tun_dev_write(struct tun_softc *tp, struct uio *uio, int ioflag)
ifp->if_ipackets++;
ifp->if_ibytes += top->m_pkthdr.len;
- NET_LOCK(s);
+ NET_LOCK();
switch (ntohl(*th)) {
case AF_INET:
@@ -947,7 +947,7 @@ tun_dev_write(struct tun_softc *tp, struct uio *uio, int ioflag)
break;
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (error);
}
diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c
index 18a1dfb47bd..c2d296f1681 100644
--- a/sys/net/if_vxlan.c
+++ b/sys/net/if_vxlan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vxlan.c,v 1.61 2017/08/10 18:38:33 reyk Exp $ */
+/* $OpenBSD: if_vxlan.c,v 1.62 2017/08/11 21:24:19 mpi Exp $ */
/*
* Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org>
@@ -178,11 +178,10 @@ int
vxlan_clone_destroy(struct ifnet *ifp)
{
struct vxlan_softc *sc = ifp->if_softc;
- int s;
- NET_LOCK(s);
+ NET_LOCK();
vxlan_multicast_cleanup(ifp);
- NET_UNLOCK(s);
+ NET_UNLOCK();
vxlan_enable--;
LIST_REMOVE(sc, sc_entry);
diff --git a/sys/net/pf.c b/sys/net/pf.c
index f8c2e49e1d4..721568314a2 100644
--- a/sys/net/pf.c
+++ b/sys/net/pf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf.c,v 1.1038 2017/08/06 13:16:11 mpi Exp $ */
+/* $OpenBSD: pf.c,v 1.1039 2017/08/11 21:24:19 mpi Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -1213,10 +1213,9 @@ void
pf_purge(void *xnloops)
{
int *nloops = xnloops;
- int s;
KERNEL_LOCK();
- NET_LOCK(s);
+ NET_LOCK();
PF_LOCK();
/* process a fraction of the state table every second */
@@ -1237,7 +1236,7 @@ pf_purge(void *xnloops)
pf_purge_expired_fragments();
*nloops = 0;
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
KERNEL_UNLOCK();
timeout_add(&pf_purge_to, 1 * hz);
diff --git a/sys/net/pf_ioctl.c b/sys/net/pf_ioctl.c
index f6711c89b63..de40e934112 100644
--- a/sys/net/pf_ioctl.c
+++ b/sys/net/pf_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_ioctl.c,v 1.321 2017/08/06 13:16:11 mpi Exp $ */
+/* $OpenBSD: pf_ioctl.c,v 1.322 2017/08/11 21:24:19 mpi Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -905,7 +905,6 @@ pf_addr_copyout(struct pf_addr_wrap *addr)
int
pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
{
- int s;
int error = 0;
/* XXX keep in sync with switch() below */
@@ -1003,7 +1002,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
return (EACCES);
}
- NET_LOCK(s);
+ NET_LOCK();
PF_LOCK();
switch (cmd) {
@@ -2476,7 +2475,7 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
}
fail:
PF_UNLOCK();
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (error);
}
diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c
index ad6f6cb89d1..988903448c1 100644
--- a/sys/net/pfkeyv2.c
+++ b/sys/net/pfkeyv2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkeyv2.c,v 1.164 2017/07/26 21:15:57 claudio Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.165 2017/08/11 21:24:19 mpi Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
@@ -934,7 +934,7 @@ pfkeyv2_get_proto_alg(u_int8_t satype, u_int8_t *sproto, int *alg)
int
pfkeyv2_send(struct socket *so, void *message, int len)
{
- int i, j, s, rval = 0, mode = PFKEYV2_SENDMESSAGE_BROADCAST;
+ int i, j, rval = 0, mode = PFKEYV2_SENDMESSAGE_BROADCAST;
int delflag = 0;
struct sockaddr_encap encapdst, encapnetmask;
struct ipsec_policy *ipo, *tmpipo;
@@ -959,7 +959,7 @@ pfkeyv2_send(struct socket *so, void *message, int len)
u_int rdomain;
- NET_LOCK(s);
+ NET_LOCK();
/* Verify that we received this over a legitimate pfkeyv2 socket */
bzero(headers, sizeof(headers));
@@ -1833,7 +1833,7 @@ ret:
rval = pfkeyv2_sendmessage(headers, mode, so, 0, 0, rdomain);
realret:
- NET_UNLOCK(s);
+ NET_UNLOCK();
if (freeme)
free(freeme, M_PFKEY, 0);
diff --git a/sys/net/pipex.c b/sys/net/pipex.c
index 6ba44d75ec8..9f4d1604ff0 100644
--- a/sys/net/pipex.c
+++ b/sys/net/pipex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pipex.c,v 1.104 2017/08/11 20:56:15 mestre Exp $ */
+/* $OpenBSD: pipex.c,v 1.105 2017/08/11 21:24:19 mpi Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -203,9 +203,9 @@ pipex_iface_fini(struct pipex_iface_context *pipex_iface)
int
pipex_ioctl(struct pipex_iface_context *pipex_iface, u_long cmd, caddr_t data)
{
- int s, pipexmode, ret = 0;
+ int pipexmode, ret = 0;
- NET_LOCK(s);
+ NET_LOCK();
switch (cmd) {
case PIPEXSMODE:
pipexmode = *(int *)data;
@@ -248,7 +248,7 @@ pipex_ioctl(struct pipex_iface_context *pipex_iface, u_long cmd, caddr_t data)
ret = ENOTTY;
break;
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
return (ret);
}
@@ -749,13 +749,12 @@ pipex_timer_stop(void)
Static void
pipex_timer(void *ignored_arg)
{
- int s;
struct pipex_session *session;
struct pipex_session *session_next;
timeout_add_sec(&pipex_timer_ch, pipex_prune);
- NET_LOCK(s);
+ NET_LOCK();
/* walk through */
for (session = LIST_FIRST(&pipex_session_list); session;
session = session_next) {
@@ -800,7 +799,7 @@ pipex_timer(void *ignored_arg)
}
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
}
/***********************************************************************
diff --git a/sys/net/route.c b/sys/net/route.c
index 8327614ca79..61914bab2e0 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.365 2017/08/02 07:42:11 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.366 2017/08/11 21:24:19 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -1414,11 +1414,10 @@ rt_timer_timer(void *arg)
struct rttimer_queue *rtq;
struct rttimer *r;
long current_time;
- int s;
current_time = time_uptime;
- NET_LOCK(s);
+ NET_LOCK();
LIST_FOREACH(rtq, &rttimer_queue_head, rtq_link) {
while ((r = TAILQ_FIRST(&rtq->rtq_head)) != NULL &&
(r->rtt_time + rtq->rtq_timeout) < current_time) {
@@ -1432,7 +1431,7 @@ rt_timer_timer(void *arg)
printf("rt_timer_timer: rtq_count reached 0\n");
}
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
timeout_add_sec(to, 1);
}
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index efcc5012d39..94aa5a5fbc8 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.247 2017/08/10 13:00:30 mpi Exp $ */
+/* $OpenBSD: rtsock.c,v 1.248 2017/08/11 21:24:19 mpi Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -744,9 +744,8 @@ rtm_output(struct rt_msghdr *rtm, struct rtentry **prt,
struct sockaddr_mpls *psa_mpls;
#endif
int plen, newgate = 0, error = 0;
- int s;
- NET_LOCK(s);
+ NET_LOCK();
switch (rtm->rtm_type) {
case RTM_ADD:
if (info->rti_info[RTAX_GATEWAY] == NULL) {
@@ -1023,7 +1022,7 @@ change:
error = ESRCH;
break;
}
- NET_UNLOCK(s);
+ NET_UNLOCK();
*prt = rt;
return (error);
diff --git a/sys/net/switchctl.c b/sys/net/switchctl.c
index b90b1576892..9365260ad52 100644
--- a/sys/net/switchctl.c
+++ b/sys/net/switchctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: switchctl.c,v 1.11 2017/01/16 11:25:14 reyk Exp $ */
+/* $OpenBSD: switchctl.c,v 1.12 2017/08/11 21:24:19 mpi Exp $ */
/*
* Copyright (c) 2016 Kazuya GODA <goda@openbsd.org>
@@ -88,9 +88,9 @@ switchopen(dev_t dev, int flags, int mode, struct proc *p)
if ((sc = switch_dev2sc(dev)) == NULL) {
snprintf(name, sizeof(name), "switch%d", minor(dev));
- NET_LOCK(s);
+ NET_LOCK();
rv = if_clone_create(name, rdomain);
- NET_UNLOCK(s);
+ NET_UNLOCK();
if (rv != 0)
return (rv);
if ((sc = switch_dev2sc(dev)) == NULL)