diff options
Diffstat (limited to 'sys')
42 files changed, 283 insertions, 349 deletions
diff --git a/sys/dev/usb/if_umb.c b/sys/dev/usb/if_umb.c index 1fbf2ea9c15..3b46cb08c72 100644 --- a/sys/dev/usb/if_umb.c +++ b/sys/dev/usb/if_umb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_umb.c,v 1.14 2017/05/30 07:50:37 mpi Exp $ */ +/* $OpenBSD: if_umb.c,v 1.15 2017/08/11 21:24:19 mpi Exp $ */ /* * Copyright (c) 2016 genua mbH @@ -947,7 +947,7 @@ umb_state_task(void *arg) struct ifnet *ifp = GET_IFP(sc); struct ifreq ifr; struct in_aliasreq ifra; - int s, ns; + int s; int state; s = splnet(); @@ -971,7 +971,7 @@ umb_state_task(void *arg) */ memset(sc->sc_info.ipv4dns, 0, sizeof (sc->sc_info.ipv4dns)); - NET_LOCK(ns); + NET_LOCK(); if (in_ioctl(SIOCGIFADDR, (caddr_t)&ifr, ifp, 1) == 0 && satosin(&ifr.ifr_addr)->sin_addr.s_addr != INADDR_ANY) { @@ -980,7 +980,7 @@ umb_state_task(void *arg) sizeof (ifra.ifra_addr)); in_ioctl(SIOCDIFADDR, (caddr_t)&ifra, ifp, 1); } - NET_UNLOCK(ns); + NET_UNLOCK(); } if_link_state_change(ifp); } @@ -1613,7 +1613,7 @@ umb_decode_ip_configuration(struct umb_softc *sc, void *data, int len) { struct mbim_cid_ip_configuration_info *ic = data; struct ifnet *ifp = GET_IFP(sc); - int s, ns; + int s; uint32_t avail; uint32_t val; int n, i; @@ -1667,9 +1667,9 @@ umb_decode_ip_configuration(struct umb_softc *sc, void *data, int len) sin->sin_len = sizeof (ifra.ifra_mask); in_len2mask(&sin->sin_addr, ipv4elem.prefixlen); - NET_LOCK(ns); + NET_LOCK(); rv = in_ioctl(SIOCAIFADDR, (caddr_t)&ifra, ifp, 1); - NET_UNLOCK(ns); + NET_UNLOCK(); if (rv == 0) { if (ifp->if_flags & IFF_DEBUG) log(LOG_INFO, "%s: IPv4 addr %s, mask %s, " diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 7b71ccfde26..ae07c12e8e9 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.329 2017/06/20 14:11:46 gerhard Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.330 2017/08/11 21:24:19 mpi Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1302,9 +1302,8 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep, extern struct inpcbtable rawin6pcbtable; #endif struct inpcb *inp; - int s; - NET_LOCK(s); + NET_LOCK(); TAILQ_FOREACH(inp, &tcbtable.inpt_queue, inp_queue) FILLSO(inp->inp_socket); TAILQ_FOREACH(inp, &udbtable.inpt_queue, inp_queue) @@ -1316,7 +1315,7 @@ sysctl_file(int *name, u_int namelen, char *where, size_t *sizep, inp_queue) FILLSO(inp->inp_socket); #endif - NET_UNLOCK(s); + NET_UNLOCK(); } fp = LIST_FIRST(&filehead); /* don't FREF when f_count == 0 to avoid race in fdrop() */ diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index d842d0bd5c1..e73fc3f5603 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_socket.c,v 1.32 2017/07/24 09:29:15 mpi Exp $ */ +/* $OpenBSD: sys_socket.c,v 1.33 2017/08/11 21:24:19 mpi Exp $ */ /* $NetBSD: sys_socket.c,v 1.13 1995/08/12 23:59:09 mycroft Exp $ */ /* @@ -125,9 +125,9 @@ soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p) * different entry since a socket's unnecessary */ if (IOCGROUP(cmd) == 'i') { - NET_LOCK(s); + NET_LOCK(); error = ifioctl(so, cmd, data, p); - NET_UNLOCK(s); + NET_UNLOCK(); return (error); } if (IOCGROUP(cmd) == 'r') diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index ce7091b540c..b2a43a41cd5 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_domain.c,v 1.51 2017/05/27 08:02:40 claudio Exp $ */ +/* $OpenBSD: uipc_domain.c,v 1.52 2017/08/11 21:24:19 mpi Exp $ */ /* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */ /* @@ -165,7 +165,7 @@ net_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, { struct domain *dp; struct protosw *pr; - int s, error, family, protocol; + int error, family, protocol; /* * All sysctl names at this level are nonterminal. @@ -207,10 +207,10 @@ net_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, protocol = name[1]; for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_protocol == protocol && pr->pr_sysctl) { - NET_LOCK(s); + NET_LOCK(); error = (*pr->pr_sysctl)(name + 2, namelen - 2, oldp, oldlenp, newp, newlen); - NET_UNLOCK(s); + NET_UNLOCK(); return (error); } return (ENOPROTOOPT); @@ -238,15 +238,15 @@ pfslowtimo(void *arg) struct timeout *to = (struct timeout *)arg; struct domain *dp; struct protosw *pr; - int i, s; + int i; - NET_LOCK(s); + NET_LOCK(); for (i = 0; (dp = domains[i]) != NULL; i++) { for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_slowtimo) (*pr->pr_slowtimo)(); } - NET_UNLOCK(s); + NET_UNLOCK(); timeout_add_msec(to, 500); } @@ -256,14 +256,14 @@ pffasttimo(void *arg) struct timeout *to = (struct timeout *)arg; struct domain *dp; struct protosw *pr; - int i, s; + int i; - NET_LOCK(s); + NET_LOCK(); for (i = 0; (dp = domains[i]) != NULL; i++) { for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_fasttimo) (*pr->pr_fasttimo)(); } - NET_UNLOCK(s); + NET_UNLOCK(); timeout_add_msec(to, 200); } diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index edfdc993bb9..5fd36ea8156 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket2.c,v 1.85 2017/07/27 12:05:36 mpi Exp $ */ +/* $OpenBSD: uipc_socket2.c,v 1.86 2017/08/11 21:24:19 mpi Exp $ */ /* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */ /* @@ -276,12 +276,12 @@ socantrcvmore(struct socket *so) int solock(struct socket *so) { - int s; + int s = 0; if ((so->so_proto->pr_domain->dom_family != PF_LOCAL) && (so->so_proto->pr_domain->dom_family != PF_ROUTE) && (so->so_proto->pr_domain->dom_family != PF_KEY)) - NET_LOCK(s); + NET_LOCK(); else s = -42; @@ -292,7 +292,7 @@ void sounlock(int s) { if (s != -42) - NET_UNLOCK(s); + NET_UNLOCK(); } void 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) diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 9625c1fbb52..f1de465e4d3 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.230 2017/07/30 18:16:14 florian Exp $ */ +/* $OpenBSD: if_ether.c,v 1.231 2017/08/11 21:24:19 mpi Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -111,9 +111,8 @@ arptimer(void *arg) { struct timeout *to = (struct timeout *)arg; struct llinfo_arp *la, *nla; - int s; - NET_LOCK(s); + NET_LOCK(); timeout_add_sec(to, arpt_prune); LIST_FOREACH_SAFE(la, &arp_list, la_list, nla) { struct rtentry *rt = la->la_rt; @@ -121,7 +120,7 @@ arptimer(void *arg) if (rt->rt_expire && rt->rt_expire <= time_uptime) arptfree(rt); /* timer has expired; clear */ } - NET_UNLOCK(s); + NET_UNLOCK(); } void diff --git a/sys/netinet/ip_ah.c b/sys/netinet/ip_ah.c index fa7db0497d4..96c7a74cf04 100644 --- a/sys/netinet/ip_ah.c +++ b/sys/netinet/ip_ah.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ah.c,v 1.130 2017/05/30 16:07:22 deraadt Exp $ */ +/* $OpenBSD: ip_ah.c,v 1.131 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 @@ -700,7 +700,7 @@ ah_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) void ah_input_cb(struct cryptop *crp) { - int s, roff, rplen, skip, protoff; + int roff, rplen, skip, protoff; unsigned char calc[AH_ALEN_MAX]; struct mbuf *m1, *m0, *m; struct auth_hash *ahx; @@ -727,7 +727,7 @@ ah_input_cb(struct cryptop *crp) return; } - NET_LOCK(s); + NET_LOCK(); tdb = gettdb(tc->tc_rdomain, tc->tc_spi, &tc->tc_dst, tc->tc_proto); if (tdb == NULL) { @@ -745,7 +745,7 @@ ah_input_cb(struct cryptop *crp) /* Reset the session ID */ if (tdb->tdb_cryptoid != 0) tdb->tdb_cryptoid = crp->crp_sid; - NET_UNLOCK(s); + NET_UNLOCK(); crypto_dispatch(crp); return; } @@ -830,7 +830,7 @@ ah_input_cb(struct cryptop *crp) m1 = m_getptr(m, skip, &roff); if (m1 == NULL) { ahstat.ahs_hdrops++; - NET_UNLOCK(s); + NET_UNLOCK(); m_freem(m); DPRINTF(("ah_input(): bad mbuf chain for packet in SA " @@ -898,11 +898,11 @@ ah_input_cb(struct cryptop *crp) } ipsec_common_input_cb(m, tdb, skip, protoff); - NET_UNLOCK(s); + NET_UNLOCK(); return; baddone: - NET_UNLOCK(s); + NET_UNLOCK(); m_freem(m); @@ -1193,7 +1193,6 @@ ah_output_cb(struct cryptop *crp) struct tdb *tdb; struct mbuf *m; caddr_t ptr; - int s; tc = (struct tdb_crypto *) crp->crp_opaque; skip = tc->tc_skip; @@ -1210,7 +1209,7 @@ ah_output_cb(struct cryptop *crp) return; } - NET_LOCK(s); + NET_LOCK(); tdb = gettdb(tc->tc_rdomain, tc->tc_spi, &tc->tc_dst, tc->tc_proto); if (tdb == NULL) { @@ -1226,7 +1225,7 @@ ah_output_cb(struct cryptop *crp) /* Reset the session ID */ if (tdb->tdb_cryptoid != 0) tdb->tdb_cryptoid = crp->crp_sid; - NET_UNLOCK(s); + NET_UNLOCK(); crypto_dispatch(crp); return; } @@ -1249,11 +1248,11 @@ ah_output_cb(struct cryptop *crp) if (ipsp_process_done(m, tdb)) ahstat.ahs_outfail++; - NET_UNLOCK(s); + NET_UNLOCK(); return; baddone: - NET_UNLOCK(s); + NET_UNLOCK(); m_freem(m); diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 5e3a0c26faf..a18d778f2e9 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.314 2017/06/22 11:34:51 tom Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.315 2017/08/11 21:24:19 mpi Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -870,11 +870,10 @@ int carp_clone_destroy(struct ifnet *ifp) { struct carp_softc *sc = ifp->if_softc; - int s; - NET_LOCK(s); + NET_LOCK(); carpdetach(sc); - NET_UNLOCK(s); + NET_UNLOCK(); ether_ifdetach(ifp); if_detach(ifp); @@ -1036,11 +1035,9 @@ carp_vhe_send_ad_all(struct carp_softc *sc) void carp_timer_ad(void *v) { - int s; - - NET_LOCK(s); + NET_LOCK(); carp_send_ad(v); - NET_UNLOCK(s); + NET_UNLOCK(); } void @@ -1548,11 +1545,9 @@ done: void carp_timer_down(void *v) { - int s; - - NET_LOCK(s); + NET_LOCK(); carp_master_down(v); - NET_UNLOCK(s); + NET_UNLOCK(); } void diff --git a/sys/netinet/ip_esp.c b/sys/netinet/ip_esp.c index f118e4e4583..c4a79f2f54d 100644 --- a/sys/netinet/ip_esp.c +++ b/sys/netinet/ip_esp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_esp.c,v 1.149 2017/05/30 16:07:22 deraadt Exp $ */ +/* $OpenBSD: ip_esp.c,v 1.150 2017/08/11 21:24:20 mpi Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -531,7 +531,7 @@ void esp_input_cb(struct cryptop *crp) { u_int8_t lastthree[3], aalg[AH_HMAC_MAX_HASHLEN]; - int s, hlen, roff, skip, protoff; + int hlen, roff, skip, protoff; struct mbuf *m1, *mo, *m; struct auth_hash *esph; struct tdb_crypto *tc; @@ -556,7 +556,7 @@ esp_input_cb(struct cryptop *crp) return; } - NET_LOCK(s); + NET_LOCK(); tdb = gettdb(tc->tc_rdomain, tc->tc_spi, &tc->tc_dst, tc->tc_proto); if (tdb == NULL) { @@ -574,7 +574,7 @@ esp_input_cb(struct cryptop *crp) /* Reset the session ID */ if (tdb->tdb_cryptoid != 0) tdb->tdb_cryptoid = crp->crp_sid; - NET_UNLOCK(s); + NET_UNLOCK(); crypto_dispatch(crp); return; } @@ -662,7 +662,7 @@ esp_input_cb(struct cryptop *crp) m1 = m_getptr(m, skip, &roff); if (m1 == NULL) { espstat.esps_hdrops++; - NET_UNLOCK(s); + NET_UNLOCK(); DPRINTF(("esp_input_cb(): bad mbuf chain, SA %s/%08x\n", ipsp_address(&tdb->tdb_dst, buf, sizeof(buf)), ntohl(tdb->tdb_spi))); @@ -720,7 +720,7 @@ esp_input_cb(struct cryptop *crp) /* Verify pad length */ if (lastthree[1] + 2 > m->m_pkthdr.len - skip) { espstat.esps_badilen++; - NET_UNLOCK(s); + NET_UNLOCK(); DPRINTF(("esp_input_cb(): invalid padding length %d for " "packet in SA %s/%08x\n", lastthree[1], ipsp_address(&tdb->tdb_dst, buf, sizeof(buf)), @@ -732,7 +732,7 @@ esp_input_cb(struct cryptop *crp) /* Verify correct decryption by checking the last padding bytes */ if ((lastthree[1] != lastthree[0]) && (lastthree[1] != 0)) { espstat.esps_badenc++; - NET_UNLOCK(s); + NET_UNLOCK(); DPRINTF(("esp_input(): decryption failed for packet in " "SA %s/%08x\n", ipsp_address(&tdb->tdb_dst, buf, sizeof(buf)), ntohl(tdb->tdb_spi))); @@ -748,11 +748,11 @@ esp_input_cb(struct cryptop *crp) /* Back to generic IPsec input processing */ ipsec_common_input_cb(m, tdb, skip, protoff); - NET_UNLOCK(s); + NET_UNLOCK(); return; baddone: - NET_UNLOCK(s); + NET_UNLOCK(); m_freem(m); @@ -1041,7 +1041,6 @@ esp_output_cb(struct cryptop *crp) struct tdb_crypto *tc; struct tdb *tdb; struct mbuf *m; - int s; tc = (struct tdb_crypto *) crp->crp_opaque; @@ -1057,7 +1056,7 @@ esp_output_cb(struct cryptop *crp) } - NET_LOCK(s); + NET_LOCK(); tdb = gettdb(tc->tc_rdomain, tc->tc_spi, &tc->tc_dst, tc->tc_proto); if (tdb == NULL) { @@ -1073,7 +1072,7 @@ esp_output_cb(struct cryptop *crp) /* Reset the session ID */ if (tdb->tdb_cryptoid != 0) tdb->tdb_cryptoid = crp->crp_sid; - NET_UNLOCK(s); + NET_UNLOCK(); crypto_dispatch(crp); return; } @@ -1091,11 +1090,11 @@ esp_output_cb(struct cryptop *crp) /* Call the IPsec input callback. */ if (ipsp_process_done(m, tdb)) espstat.esps_outfail++; - NET_UNLOCK(s); + NET_UNLOCK(); return; baddone: - NET_UNLOCK(s); + NET_UNLOCK(); m_freem(m); diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index e1f7483f409..67f2f27d749 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.317 2017/08/08 12:23:56 bluhm Exp $ */ +/* $OpenBSD: ip_input.c,v 1.318 2017/08/11 21:24:20 mpi Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -1794,7 +1794,6 @@ ip_send_dispatch(void *xmq) struct mbuf_queue *mq = xmq; struct mbuf *m; struct mbuf_list ml; - int s; #ifdef IPSEC int locked = 0; #endif /* IPSEC */ @@ -1816,11 +1815,11 @@ ip_send_dispatch(void *xmq) } #endif /* IPSEC */ - NET_LOCK(s); + NET_LOCK(); while ((m = ml_dequeue(&ml)) != NULL) { ip_output(m, NULL, NULL, 0, NULL, NULL, 0); } - NET_UNLOCK(s); + NET_UNLOCK(); #ifdef IPSEC if (locked) diff --git a/sys/netinet/ip_ipcomp.c b/sys/netinet/ip_ipcomp.c index 163f4d00002..b251af9ae6b 100644 --- a/sys/netinet/ip_ipcomp.c +++ b/sys/netinet/ip_ipcomp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipcomp.c,v 1.56 2017/04/05 22:27:03 dhill Exp $ */ +/* $OpenBSD: ip_ipcomp.c,v 1.57 2017/08/11 21:24:20 mpi Exp $ */ /* * Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org) @@ -192,7 +192,7 @@ ipcomp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) void ipcomp_input_cb(struct cryptop *crp) { - int s, skip, protoff, roff, hlen = IPCOMP_HLENGTH, clen; + int skip, protoff, roff, hlen = IPCOMP_HLENGTH, clen; u_int8_t nproto; struct mbuf *m, *m1, *mo; struct tdb_crypto *tc; @@ -217,7 +217,7 @@ ipcomp_input_cb(struct cryptop *crp) return; } - NET_LOCK(s); + NET_LOCK(); tdb = gettdb(tc->tc_rdomain, tc->tc_spi, &tc->tc_dst, tc->tc_proto); if (tdb == NULL) { @@ -252,7 +252,7 @@ ipcomp_input_cb(struct cryptop *crp) /* Reset the session ID */ if (tdb->tdb_cryptoid != 0) tdb->tdb_cryptoid = crp->crp_sid; - NET_UNLOCK(s); + NET_UNLOCK(); crypto_dispatch(crp); return; } @@ -332,11 +332,11 @@ ipcomp_input_cb(struct cryptop *crp) /* Back to generic IPsec input processing */ ipsec_common_input_cb(m, tdb, skip, protoff); - NET_UNLOCK(s); + NET_UNLOCK(); return; baddone: - NET_UNLOCK(s); + NET_UNLOCK(); m_freem(m); @@ -523,7 +523,7 @@ ipcomp_output_cb(struct cryptop *crp) struct tdb_crypto *tc; struct tdb *tdb; struct mbuf *m, *mo; - int s, skip, rlen, roff; + int skip, rlen, roff; u_int16_t cpi; struct ip *ip; #ifdef INET6 @@ -549,7 +549,7 @@ ipcomp_output_cb(struct cryptop *crp) return; } - NET_LOCK(s); + NET_LOCK(); tdb = gettdb(tc->tc_rdomain, tc->tc_spi, &tc->tc_dst, tc->tc_proto); if (tdb == NULL) { @@ -565,7 +565,7 @@ ipcomp_output_cb(struct cryptop *crp) /* Reset the session ID */ if (tdb->tdb_cryptoid != 0) tdb->tdb_cryptoid = crp->crp_sid; - NET_UNLOCK(s); + NET_UNLOCK(); crypto_dispatch(crp); return; } @@ -583,7 +583,7 @@ ipcomp_output_cb(struct cryptop *crp) crypto_freereq(crp); if (ipsp_process_done(m, tdb)) ipcompstat.ipcomps_outfail++; - NET_UNLOCK(s); + NET_UNLOCK(); return; } @@ -632,11 +632,11 @@ ipcomp_output_cb(struct cryptop *crp) if (ipsp_process_done(m, tdb)) ipcompstat.ipcomps_outfail++; - NET_UNLOCK(s); + NET_UNLOCK(); return; baddone: - NET_UNLOCK(s); + NET_UNLOCK(); m_freem(m); diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c index 085557cf2bd..185df6f3728 100644 --- a/sys/netinet/ip_ipsp.c +++ b/sys/netinet/ip_ipsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipsp.c,v 1.225 2017/06/26 09:08:00 patrick Exp $ */ +/* $OpenBSD: ip_ipsp.c,v 1.226 2017/08/11 21:24:20 mpi Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr), @@ -536,67 +536,63 @@ void tdb_timeout(void *v) { struct tdb *tdb = v; - int s; if (!(tdb->tdb_flags & TDBF_TIMER)) return; - NET_LOCK(s); + NET_LOCK(); /* If it's an "invalid" TDB do a silent expiration. */ if (!(tdb->tdb_flags & TDBF_INVALID)) pfkeyv2_expire(tdb, SADB_EXT_LIFETIME_HARD); tdb_delete(tdb); - NET_UNLOCK(s); + NET_UNLOCK(); } void tdb_firstuse(void *v) { struct tdb *tdb = v; - int s; if (!(tdb->tdb_flags & TDBF_SOFT_FIRSTUSE)) return; - NET_LOCK(s); + NET_LOCK(); /* If the TDB hasn't been used, don't renew it. */ if (tdb->tdb_first_use != 0) pfkeyv2_expire(tdb, SADB_EXT_LIFETIME_HARD); tdb_delete(tdb); - NET_UNLOCK(s); + NET_UNLOCK(); } void tdb_soft_timeout(void *v) { struct tdb *tdb = v; - int s; if (!(tdb->tdb_flags & TDBF_SOFT_TIMER)) return; - NET_LOCK(s); + NET_LOCK(); /* Soft expirations. */ pfkeyv2_expire(tdb, SADB_EXT_LIFETIME_SOFT); tdb->tdb_flags &= ~TDBF_SOFT_TIMER; - NET_UNLOCK(s); + NET_UNLOCK(); } void tdb_soft_firstuse(void *v) { struct tdb *tdb = v; - int s; if (!(tdb->tdb_flags & TDBF_SOFT_FIRSTUSE)) return; - NET_LOCK(s); + NET_LOCK(); /* If the TDB hasn't been used, don't renew it. */ if (tdb->tdb_first_use != 0) pfkeyv2_expire(tdb, SADB_EXT_LIFETIME_SOFT); tdb->tdb_flags &= ~TDBF_SOFT_FIRSTUSE; - NET_UNLOCK(s); + NET_UNLOCK(); } void @@ -993,18 +989,17 @@ void ipsp_ids_timeout(void *arg) { struct ipsec_ids *ids = arg; - int s; DPRINTF(("%s: ids %p count %d\n", __func__, ids, ids->id_refcount)); KASSERT(ids->id_refcount == 0); - NET_LOCK(s); + NET_LOCK(); RBT_REMOVE(ipsec_ids_tree, &ipsec_ids_tree, ids); RBT_REMOVE(ipsec_ids_flows, &ipsec_ids_flows, ids); free(ids->id_local, M_CREDENTIALS, 0); free(ids->id_remote, M_CREDENTIALS, 0); free(ids, M_CREDENTIALS, 0); - NET_UNLOCK(s); + NET_UNLOCK(); } /* decrements refcount, actual free happens in timeout */ diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index c847ceec16d..52c206f0bf5 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.346 2017/06/26 09:32:32 mpi Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.347 2017/08/11 21:24:20 mpi Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -3455,9 +3455,8 @@ void syn_cache_timer(void *arg) { struct syn_cache *sc = arg; - int s; - NET_LOCK(s); + NET_LOCK(); if (sc->sc_flags & SCF_DEAD) goto out; @@ -3483,14 +3482,14 @@ syn_cache_timer(void *arg) SYN_CACHE_TIMER_ARM(sc); out: - NET_UNLOCK(s); + NET_UNLOCK(); return; dropit: tcpstat_inc(tcps_sc_timed_out); syn_cache_rm(sc); syn_cache_put(sc); - NET_UNLOCK(s); + NET_UNLOCK(); } void diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 3d4bc5d0600..3f063ed9936 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_timer.c,v 1.56 2017/05/16 12:24:02 mpi Exp $ */ +/* $OpenBSD: tcp_timer.c,v 1.57 2017/08/11 21:24:20 mpi Exp $ */ /* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */ /* @@ -105,20 +105,19 @@ void tcp_delack(void *arg) { struct tcpcb *tp = arg; - int s; /* * If tcp_output() wasn't able to transmit the ACK * for whatever reason, it will restart the delayed * ACK callout. */ - NET_LOCK(s); + NET_LOCK(); if (tp->t_flags & TF_DEAD) goto out; tp->t_flags |= TF_ACKNOW; (void) tcp_output(tp); out: - NET_UNLOCK(s); + NET_UNLOCK(); } /* @@ -187,9 +186,8 @@ tcp_timer_rexmt(void *arg) { struct tcpcb *tp = arg; uint32_t rto; - int s; - NET_LOCK(s); + NET_LOCK(); if (tp->t_flags & TF_DEAD) goto out; @@ -369,7 +367,7 @@ tcp_timer_rexmt(void *arg) (void) tcp_output(tp); out: - NET_UNLOCK(s); + NET_UNLOCK(); } void @@ -377,9 +375,8 @@ tcp_timer_persist(void *arg) { struct tcpcb *tp = arg; uint32_t rto; - int s; - NET_LOCK(s); + NET_LOCK(); if ((tp->t_flags & TF_DEAD) || TCP_TIMER_ISARMED(tp, TCPT_REXMT)) { goto out; @@ -407,16 +404,15 @@ tcp_timer_persist(void *arg) (void) tcp_output(tp); tp->t_force = 0; out: - NET_UNLOCK(s); + NET_UNLOCK(); } void tcp_timer_keep(void *arg) { struct tcpcb *tp = arg; - int s; - NET_LOCK(s); + NET_LOCK(); if (tp->t_flags & TF_DEAD) goto out; @@ -448,22 +444,21 @@ tcp_timer_keep(void *arg) } else TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle); out: - NET_UNLOCK(s); + NET_UNLOCK(); return; dropit: tcpstat_inc(tcps_keepdrops); tp = tcp_drop(tp, ETIMEDOUT); - NET_UNLOCK(s); + NET_UNLOCK(); } void tcp_timer_2msl(void *arg) { struct tcpcb *tp = arg; - int s; - NET_LOCK(s); + NET_LOCK(); if (tp->t_flags & TF_DEAD) goto out; @@ -478,5 +473,5 @@ tcp_timer_2msl(void *arg) tp = tcp_close(tp); out: - NET_UNLOCK(s); + NET_UNLOCK(); } diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 63c7a635d10..db87b569dc0 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_input.c,v 1.200 2017/08/08 12:23:56 bluhm Exp $ */ +/* $OpenBSD: ip6_input.c,v 1.201 2017/08/11 21:24:20 mpi Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -1442,7 +1442,6 @@ ip6_send_dispatch(void *xmq) struct mbuf_queue *mq = xmq; struct mbuf *m; struct mbuf_list ml; - int s; #ifdef IPSEC int locked = 0; #endif /* IPSEC */ @@ -1464,11 +1463,11 @@ ip6_send_dispatch(void *xmq) } #endif /* IPSEC */ - NET_LOCK(s); + NET_LOCK(); while ((m = ml_dequeue(&ml)) != NULL) { ip6_output(m, NULL, NULL, IPV6_MINMTU, NULL, NULL); } - NET_UNLOCK(s); + NET_UNLOCK(); #ifdef IPSEC if (locked) diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index c93413369e4..066cb5c5dfc 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.218 2017/08/10 13:05:58 bluhm Exp $ */ +/* $OpenBSD: nd6.c,v 1.219 2017/08/11 21:24:20 mpi Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -311,21 +311,20 @@ nd6_llinfo_settimer(struct llinfo_nd6 *ln, int secs) void nd6_llinfo_timer(void *arg) { - int s; struct llinfo_nd6 *ln; struct rtentry *rt; struct sockaddr_in6 *dst; struct ifnet *ifp; struct nd_ifinfo *ndi = NULL; - NET_LOCK(s); + NET_LOCK(); ln = (struct llinfo_nd6 *)arg; if ((rt = ln->ln_rt) == NULL) panic("ln->ln_rt == NULL"); if ((ifp = if_get(rt->rt_ifidx)) == NULL) { - NET_UNLOCK(s); + NET_UNLOCK(); return; } ndi = ND_IFINFO(ifp); @@ -409,7 +408,7 @@ nd6_llinfo_timer(void *arg) } if_put(ifp); - NET_UNLOCK(s); + NET_UNLOCK(); } void @@ -457,10 +456,9 @@ void nd6_expire(void *unused) { struct ifnet *ifp; - int s; KERNEL_LOCK(); - NET_LOCK(s); + NET_LOCK(); TAILQ_FOREACH(ifp, &ifnet, if_list) { struct ifaddr *ifa, *nifa; @@ -481,7 +479,7 @@ nd6_expire(void *unused) } } - NET_UNLOCK(s); + NET_UNLOCK(); KERNEL_UNLOCK(); } @@ -1293,9 +1291,8 @@ nd6_slowtimo(void *ignored_arg) { struct nd_ifinfo *nd6if; struct ifnet *ifp; - int s; - NET_LOCK(s); + NET_LOCK(); timeout_add_sec(&nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL); @@ -1313,7 +1310,7 @@ nd6_slowtimo(void *ignored_arg) nd6if->reachable = ND_COMPUTE_RTIME(nd6if->basereachable); } } - NET_UNLOCK(s); + NET_UNLOCK(); } int diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index 90086d33d65..7dc48780275 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_nbr.c,v 1.120 2017/07/28 09:01:09 mpi Exp $ */ +/* $OpenBSD: nd6_nbr.c,v 1.121 2017/08/11 21:24:20 mpi Exp $ */ /* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */ /* @@ -1173,9 +1173,8 @@ nd6_dad_timer(void *xifa) struct in6_ifaddr *ia6 = ifatoia6(ifa); struct dadq *dp; char addr[INET6_ADDRSTRLEN]; - int s; - NET_LOCK(s); + NET_LOCK(); /* Sanity check */ if (ia6 == NULL) { @@ -1266,7 +1265,7 @@ nd6_dad_timer(void *xifa) } done: - NET_UNLOCK(s); + NET_UNLOCK(); } void diff --git a/sys/nfs/nfs_boot.c b/sys/nfs/nfs_boot.c index 814b7902c7b..f4e8dff56a2 100644 --- a/sys/nfs/nfs_boot.c +++ b/sys/nfs/nfs_boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_boot.c,v 1.42 2017/07/19 12:32:13 claudio Exp $ */ +/* $OpenBSD: nfs_boot.c,v 1.43 2017/08/11 21:24:20 mpi Exp $ */ /* $NetBSD: nfs_boot.c,v 1.26 1996/05/07 02:51:25 thorpej Exp $ */ /* @@ -122,7 +122,7 @@ nfs_boot_init(struct nfs_diskless *nd, struct proc *procp) struct socket *so; struct ifaddr *ifa; char addr[INET_ADDRSTRLEN]; - int s, error; + int error; /* * Find an interface, rarp for its ip address, stuff it, the @@ -159,15 +159,15 @@ nfs_boot_init(struct nfs_diskless *nd, struct proc *procp) */ if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0)) != 0) panic("nfs_boot: socreate, error=%d", error); - NET_LOCK(s); + NET_LOCK(); error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)&ireq, procp); - NET_UNLOCK(s); + NET_UNLOCK(); if (error) panic("nfs_boot: GIFFLAGS, error=%d", error); ireq.ifr_flags |= IFF_UP; - NET_LOCK(s); + NET_LOCK(); error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)&ireq, procp); - NET_UNLOCK(s); + NET_UNLOCK(); if (error) panic("nfs_boot: SIFFLAGS, error=%d", error); @@ -190,9 +190,9 @@ nfs_boot_init(struct nfs_diskless *nd, struct proc *procp) sin->sin_len = sizeof(*sin); sin->sin_family = AF_INET; sin->sin_addr.s_addr = my_ip.s_addr; - NET_LOCK(s); + NET_LOCK(); error = ifioctl(so, SIOCAIFADDR, (caddr_t)&ifra, procp); - NET_UNLOCK(s); + NET_UNLOCK(); if (error) panic("nfs_boot: set if addr, error=%d", error); diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index 5ed5a9ed26a..9924a5e5edc 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_socket.c,v 1.122 2017/08/10 19:20:43 mpi Exp $ */ +/* $OpenBSD: nfs_socket.c,v 1.123 2017/08/11 21:24:20 mpi Exp $ */ /* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */ /* @@ -1137,9 +1137,9 @@ nfs_timer(void *arg) struct nfsreq *rep; struct mbuf *m; struct socket *so; - int timeo, s, error; + int timeo, error; - NET_LOCK(s); + NET_LOCK(); TAILQ_FOREACH(rep, &nmp->nm_reqsq, r_chain) { if (rep->r_mrep || (rep->r_flags & R_SOFTTERM)) continue; @@ -1222,7 +1222,7 @@ nfs_timer(void *arg) } } } - NET_UNLOCK(s); + NET_UNLOCK(); timeout_add(&nmp->nm_rtimeout, nfs_ticks); } diff --git a/sys/sys/systm.h b/sys/sys/systm.h index f83c12ffcdd..7a4c2fa2ed4 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.132 2017/07/27 12:08:19 mpi Exp $ */ +/* $OpenBSD: systm.h,v 1.133 2017/08/11 21:24:20 mpi Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -296,15 +296,13 @@ int uiomove(void *, size_t, struct uio *); extern struct rwlock netlock; -#define NET_LOCK(s) \ +#define NET_LOCK() \ do { \ rw_enter_write(&netlock); \ - s = IPL_SOFTNET; \ } while (0) -#define NET_UNLOCK(s) \ +#define NET_UNLOCK() \ do { \ - (void)s; \ rw_exit_write(&netlock); \ } while (0) |