summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2016-12-22 13:39:33 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2016-12-22 13:39:33 +0000
commita95accb4b6fe08eade0e623a11d035c4bae47531 (patch)
tree6b0ac91921ee472ef5a25bb03a82ce52ce5baa60 /sys
parentea3d4d42e38c1add904ee19a1893ddcf005c2851 (diff)
Remove all splsoftnet() from ND6 converting the non-recrusive ones to
NET_LOCK(). ok bluhm@
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet6/nd6.c28
-rw-r--r--sys/netinet6/nd6_nbr.c13
-rw-r--r--sys/netinet6/nd6_rtr.c44
3 files changed, 40 insertions, 45 deletions
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index cf59c02f31e..f8135150e42 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6.c,v 1.199 2016/12/20 18:33:43 bluhm Exp $ */
+/* $OpenBSD: nd6.c,v 1.200 2016/12/22 13:39:32 mpi Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
@@ -127,7 +127,7 @@ nd6_init(void)
nd6_init_done = 1;
/* start timer */
- timeout_set(&nd6_slowtimo_ch, nd6_slowtimo, NULL);
+ timeout_set_proc(&nd6_slowtimo_ch, nd6_slowtimo, NULL);
timeout_add_sec(&nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL);
nd6_rs_init();
@@ -430,12 +430,13 @@ nd6_llinfo_timer(void *arg)
void
nd6_timer_work(void *null)
{
- int s;
struct nd_defrouter *dr, *ndr;
struct nd_prefix *pr, *npr;
struct in6_ifaddr *ia6, *nia6;
+ int s;
+
+ NET_LOCK(s);
- s = splsoftnet();
timeout_set(&nd6_timer_ch, nd6_timer, NULL);
timeout_add_sec(&nd6_timer_ch, nd6_prune);
@@ -482,7 +483,7 @@ nd6_timer_work(void *null)
prelist_remove(pr);
}
}
- splx(s);
+ NET_UNLOCK(s);
}
void
@@ -1120,7 +1121,8 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
struct in6_nbrinfo *nbi = (struct in6_nbrinfo *)data;
struct rtentry *rt;
int error = 0;
- int s;
+
+ splsoftassert(IPL_SOFTNET);
switch (cmd) {
case SIOCGIFINFO_IN6:
@@ -1142,7 +1144,6 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
/* flush all the prefix advertised by routers */
struct nd_prefix *pr, *npr;
- s = splsoftnet();
/* First purge the addresses referenced by a prefix. */
LIST_FOREACH_SAFE(pr, &nd_prefix, ndpr_entry, npr) {
struct in6_ifaddr *ia6, *ia6_next;
@@ -1170,7 +1171,6 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
prelist_remove(pr);
}
- splx(s);
break;
}
case SIOCSRTRFLUSH_IN6:
@@ -1178,12 +1178,10 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
/* flush all the default routers */
struct nd_defrouter *dr, *ndr;
- s = splsoftnet();
defrouter_reset();
TAILQ_FOREACH_SAFE(dr, &nd_defrouter, dr_entry, ndr)
defrtrlist_del(dr);
defrouter_select();
- splx(s);
break;
}
case SIOCGNBRINFO_IN6:
@@ -1204,13 +1202,11 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
*idp = htons(ifp->if_index);
}
- s = splsoftnet();
rt = nd6_lookup(&nb_addr, 0, ifp, ifp->if_rdomain);
if (rt == NULL ||
(ln = (struct llinfo_nd6 *)rt->rt_llinfo) == NULL) {
error = EINVAL;
rtfree(rt);
- splx(s);
break;
}
expire = ln->ln_rt->rt_expire;
@@ -1224,7 +1220,6 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
nbi->isrouter = ln->ln_router;
nbi->expire = expire;
rtfree(rt);
- splx(s);
break;
}
@@ -1478,12 +1473,15 @@ fail:
void
nd6_slowtimo(void *ignored_arg)
{
- int s = splsoftnet();
struct nd_ifinfo *nd6if;
struct ifnet *ifp;
+ int s;
+
+ NET_LOCK(s);
timeout_set(&nd6_slowtimo_ch, nd6_slowtimo, NULL);
timeout_add_sec(&nd6_slowtimo_ch, ND6_SLOWTIMER_INTERVAL);
+
TAILQ_FOREACH(ifp, &ifnet, if_list) {
nd6if = ND_IFINFO(ifp);
if (nd6if->basereachable && /* already initialized */
@@ -1498,7 +1496,7 @@ nd6_slowtimo(void *ignored_arg)
nd6if->reachable = ND_COMPUTE_RTIME(nd6if->basereachable);
}
}
- splx(s);
+ NET_UNLOCK(s);
}
int
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index 5380475e141..b0d1793b3fa 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_nbr.c,v 1.112 2016/12/21 12:30:19 mpi Exp $ */
+/* $OpenBSD: nd6_nbr.c,v 1.113 2016/12/22 13:39:32 mpi Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@@ -572,6 +572,8 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
union nd_opts ndopts;
char addr[INET6_ADDRSTRLEN], addr0[INET6_ADDRSTRLEN];
+ splsoftassert(IPL_SOFTNET);
+
ifp = if_get(m->m_pkthdr.ph_ifidx);
if (ifp == NULL)
goto freeit;
@@ -825,7 +827,6 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
*/
struct nd_defrouter *dr;
struct in6_addr *in6;
- int s;
in6 = &satosin6(rt_key(rt))->sin6_addr;
@@ -835,7 +836,6 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
* is only called under the network software interrupt
* context. However, we keep it just for safety.
*/
- s = splsoftnet();
dr = defrouter_lookup(in6, rt->rt_ifidx);
if (dr)
defrtrlist_del(dr);
@@ -849,7 +849,6 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len)
*/
rt6_flush(&ip6->ip6_src, ifp);
}
- splx(s);
}
ln->ln_router = is_router;
}
@@ -1080,7 +1079,7 @@ void
nd6_dad_starttimer(struct dadq *dp, int ticks)
{
- timeout_set(&dp->dad_timer_ch, nd6_dad_timer, dp->dad_ifa);
+ timeout_set_proc(&dp->dad_timer_ch, nd6_dad_timer, dp->dad_ifa);
timeout_add(&dp->dad_timer_ch, ticks);
}
@@ -1190,7 +1189,7 @@ nd6_dad_timer(void *xifa)
char addr[INET6_ADDRSTRLEN];
int s;
- s = splsoftnet(); /* XXX */
+ NET_LOCK(s);
/* Sanity check */
if (ia6 == NULL) {
@@ -1281,7 +1280,7 @@ nd6_dad_timer(void *xifa)
}
done:
- splx(s);
+ NET_UNLOCK(s);
}
void
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 78e070b2499..4885c37cdb9 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_rtr.c,v 1.153 2016/11/28 14:14:39 mpi Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.154 2016/12/22 13:39:32 mpi Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
@@ -94,7 +94,7 @@ int nd6_rs_timeout_count = 0;
void
nd6_rs_init(void)
{
- timeout_set(&nd6_rs_output_timer, nd6_rs_output_timo, NULL);
+ timeout_set_proc(&nd6_rs_output_timer, nd6_rs_output_timo, NULL);
}
@@ -202,7 +202,9 @@ nd6_rs_output(struct ifnet* ifp, struct in6_ifaddr *ia6)
struct nd_router_solicit *rs;
struct ip6_moptions im6o;
caddr_t mac;
- int icmp6len, maxlen, s;
+ int icmp6len, maxlen;
+
+ splsoftassert(IPL_SOFTNET);
KASSERT(ia6 != NULL);
KASSERT(ifp->if_flags & IFF_RUNNING);
@@ -272,9 +274,7 @@ nd6_rs_output(struct ifnet* ifp, struct in6_ifaddr *ia6)
ip6->ip6_plen = htons((u_short)icmp6len);
- s = splsoftnet();
ip6_output(m, NULL, NULL, 0, &im6o, NULL);
- splx(s);
icmp6stat.icp6s_outhist[ND_ROUTER_SOLICIT]++;
}
@@ -291,6 +291,7 @@ nd6_rs_output_timo(void *ignored_arg)
{
struct ifnet *ifp;
struct in6_ifaddr *ia6;
+ int s;
if (nd6_rs_timeout_count == 0)
return;
@@ -301,6 +302,7 @@ nd6_rs_output_timo(void *ignored_arg)
if (nd6_rs_output_timeout > ND6_RS_OUTPUT_INTERVAL)
nd6_rs_output_timeout = ND6_RS_OUTPUT_INTERVAL;
+ NET_LOCK(s);
TAILQ_FOREACH(ifp, &ifnet, if_list) {
if (ISSET(ifp->if_flags, IFF_RUNNING) &&
ISSET(ifp->if_xflags, IFXF_AUTOCONF6)) {
@@ -309,6 +311,7 @@ nd6_rs_output_timo(void *ignored_arg)
nd6_rs_output(ifp, ia6);
}
}
+ NET_UNLOCK(s);
nd6_rs_output_set_timo(nd6_rs_output_timeout);
}
@@ -1104,8 +1107,10 @@ void
prelist_remove(struct nd_prefix *pr)
{
struct nd_pfxrouter *pfr, *next;
- int e, s;
struct in6_ifextra *ext = pr->ndpr_ifp->if_afdata[AF_INET6];
+ int e;
+
+ splsoftassert(IPL_SOFTNET);
/* make sure to invalidate the prefix until it is really freed. */
pr->ndpr_vltime = 0;
@@ -1114,8 +1119,8 @@ prelist_remove(struct nd_prefix *pr)
if ((pr->ndpr_stateflags & NDPRF_ONLINK) != 0 &&
(e = nd6_prefix_offlink(pr)) != 0) {
char addr[INET6_ADDRSTRLEN];
- nd6log((LOG_ERR, "prelist_remove: failed to make %s/%d offlink "
- "on %s, errno=%d\n",
+ nd6log((LOG_ERR, "%s: failed to make %s/%d offlink "
+ "on %s, errno=%d\n", __func__,
inet_ntop(AF_INET6, &pr->ndpr_prefix.sin6_addr,
addr, sizeof(addr)),
pr->ndpr_plen, pr->ndpr_ifp->if_xname, e));
@@ -1125,8 +1130,6 @@ prelist_remove(struct nd_prefix *pr)
if (pr->ndpr_refcnt > 0)
return; /* notice here? */
- s = splsoftnet();
-
/* unlink ndpr_entry from nd_prefix list */
LIST_REMOVE(pr, ndpr_entry);
@@ -1136,14 +1139,13 @@ prelist_remove(struct nd_prefix *pr)
ext->nprefixes--;
if (ext->nprefixes < 0) {
- log(LOG_WARNING, "prelist_remove: negative count on %s\n",
+ log(LOG_WARNING, "%s: negative count on %s\n", __func__,
pr->ndpr_ifp->if_xname);
}
free(pr, M_IP6NDP, sizeof(*pr));
pfxlist_onlink_check();
- splx(s);
}
/*
@@ -1406,7 +1408,7 @@ nd6_addr_add(void *prptr)
struct ifaddr *ifa;
int ifa_plen, autoconf, privacy, s;
- s = splsoftnet();
+ NET_LOCK(s);
autoconf = 1;
privacy = (pr->ndpr_ifp->if_xflags & IFXF_INET6_NOPRIVACY) == 0;
@@ -1472,7 +1474,7 @@ nd6_addr_add(void *prptr)
if (--pr->ndpr_refcnt == 0)
prelist_remove(pr);
- splx(s);
+ NET_UNLOCK(s);
}
/*
@@ -1592,9 +1594,8 @@ pfxlist_onlink_check(void)
if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0 &&
(pr->ndpr_stateflags & NDPRF_ONLINK) != 0) {
if ((e = nd6_prefix_offlink(pr)) != 0) {
- nd6log((LOG_ERR,
- "pfxlist_onlink_check: failed to "
- "make %s/%d offlink, errno=%d\n",
+ nd6log((LOG_ERR, "%s: failed to make %s/%d "
+ "offlink, errno=%d\n", __func__,
inet_ntop(AF_INET6,
&pr->ndpr_prefix.sin6_addr,
addr, sizeof(addr)),
@@ -1605,9 +1606,8 @@ pfxlist_onlink_check(void)
(pr->ndpr_stateflags & NDPRF_ONLINK) == 0 &&
pr->ndpr_raf_onlink) {
if ((e = nd6_prefix_onlink(pr)) != 0) {
- nd6log((LOG_ERR,
- "pfxlist_onlink_check: failed to "
- "make %s/%d offlink, errno=%d\n",
+ nd6log((LOG_ERR, "%s: failed to make %s/%d "
+ "offlink, errno=%d\n", __func__,
inet_ntop(AF_INET6,
&pr->ndpr_prefix.sin6_addr,
addr, sizeof(addr)),
@@ -2000,7 +2000,7 @@ in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6)
void
rt6_flush(struct in6_addr *gateway, struct ifnet *ifp)
{
- int s;
+ splsoftassert(IPL_SOFTNET);
/* We'll care only link-local addresses */
if (!IN6_IS_ADDR_LINKLOCAL(gateway))
@@ -2009,9 +2009,7 @@ rt6_flush(struct in6_addr *gateway, struct ifnet *ifp)
/* XXX: hack for KAME's link-local address kludge */
gateway->s6_addr16[1] = htons(ifp->if_index);
- s = splsoftnet();
rtable_walk(ifp->if_rdomain, AF_INET6, rt6_deleteroute, gateway);
- splx(s);
}
int