As soon as we ensure that ifioctl() is always called at IPL_SOFTNET
we can remove all of these.
Recursions still exist, but this is a good step forward.
Index: net/if.c
===================================================================
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.462
diff -u -p -r1.462 if.c
--- net/if.c 21 Nov 2016 09:09:06 -0000 1.462
+++ net/if.c 21 Nov 2016 10:31:30 -0000
@@ -133,6 +133,8 @@
void if_attachsetup(struct ifnet *);
void if_attachdomain(struct ifnet *);
void if_attach_common(struct ifnet *);
+int if_setrdomain(struct ifnet *, int);
+void if_slowtimo(void *);
void if_detached_start(struct ifnet *);
int if_detached_ioctl(struct ifnet *, u_long, caddr_t);
@@ -402,6 +404,8 @@ if_attachsetup(struct ifnet *ifp)
{
unsigned long ifidx;
+ splsoftassert(IPL_SOFTNET);
+
TAILQ_INIT(&ifp->if_groups);
if_addgroup(ifp, IFG_ALL);
@@ -501,17 +505,25 @@ if_attachdomain(struct ifnet *ifp)
void
if_attachhead(struct ifnet *ifp)
{
+ int s;
+
+ s = splsoftnet();
if_attach_common(ifp);
TAILQ_INSERT_HEAD(&ifnet, ifp, if_list);
if_attachsetup(ifp);
+ splx(s);
}
void
if_attach(struct ifnet *ifp)
{
+ int s;
+
+ s = splsoftnet();
if_attach_common(ifp);
TAILQ_INSERT_TAIL(&ifnet, ifp, if_list);
if_attachsetup(ifp);
+ splx(s);
}
void
@@ -1036,7 +1048,9 @@ if_clone_create(const char *name, int rd
{
struct if_clone *ifc;
struct ifnet *ifp;
- int unit, ret, s;
+ int unit, ret;
+
+ splsoftassert(IPL_SOFTNET);
ifc = if_clone_lookup(name, &unit);
if (ifc == NULL)
@@ -1045,9 +1059,7 @@ if_clone_create(const char *name, int rd
if (ifunit(name) != NULL)
return (EEXIST);
- s = splsoftnet();
ret = (*ifc->ifc_create)(ifc, unit);
- splx(s);
if (ret != 0 || (ifp = ifunit(name)) == NULL)
return (ret);
@@ -1067,7 +1079,8 @@ if_clone_destroy(const char *name)
{
struct if_clone *ifc;
struct ifnet *ifp;
- int error, s;
+
+ splsoftassert(IPL_SOFTNET);
ifc = if_clone_lookup(name, NULL);
if (ifc == NULL)
@@ -1081,15 +1094,13 @@ if_clone_destroy(const char *name)
return (EOPNOTSUPP);
if (ifp->if_flags & IFF_UP) {
+ int s;
s = splnet();
if_down(ifp);
splx(s);
}
- s = splsoftnet();
- error = (*ifc->ifc_destroy)(ifp);
- splx(s);
- return (error);
+ return ((*ifc->ifc_destroy)(ifp));
}
/*
@@ -1594,7 +1605,7 @@ int
if_setrdomain(struct ifnet *ifp, int rdomain)
{
struct ifreq ifr;
- int s, error;
+ int error;
if (rdomain < 0 || rdomain > RT_TABLEID_MAX)
return (EINVAL);
@@ -1618,11 +1629,8 @@ if_setrdomain(struct ifnet *ifp, int rdo
if (error && (ifp != loifp || error != EEXIST))
return (error);
-
- s = splsoftnet();
if ((error = rtable_add(rdomain)) == 0)
rtable_l2set(rdomain, rdomain, loifp->if_index);
- splx(s);
if (error) {
if_clone_destroy(loifname);
return (error);
@@ -1638,6 +1646,8 @@ if_setrdomain(struct ifnet *ifp, int rdo
/* remove all routing entries when switching domains */
/* XXX this is a bit ugly */
if (rdomain != ifp->if_rdomain) {
+ int s;
+
s = splnet();
/*
* We are tearing down the world.
@@ -1725,20 +1735,15 @@ ifioctl(struct socket *so, u_long cmd, c
switch (ifar->ifar_af) {
case AF_INET:
/* attach is a noop for AF_INET */
- if (cmd == SIOCIFAFDETACH) {
- s = splsoftnet();
+ if (cmd == SIOCIFAFDETACH)
in_ifdetach(ifp);
- splx(s);
- }
return (0);
#ifdef INET6
case AF_INET6:
- s = splsoftnet();
if (cmd == SIOCIFAFATTACH)
error = in6_ifattach(ifp);
else
in6_ifdetach(ifp);
- splx(s);
return (error);
#endif /* INET6 */
default:
@@ -1804,9 +1809,7 @@ ifioctl(struct socket *so, u_long cmd, c
#ifdef INET6
if (ISSET(ifr->ifr_flags, IFXF_AUTOCONF6)) {
- s = splsoftnet();
error = in6_ifattach(ifp);
- splx(s);
if (error != 0)
return (error);
}
@@ -1869,9 +1872,7 @@ ifioctl(struct socket *so, u_long cmd, c
ifp->if_xflags = (ifp->if_xflags & IFXF_CANTCHANGE) |
(ifr->ifr_flags & ~IFXF_CANTCHANGE);
- s = splsoftnet();
rt_ifmsg(ifp);
- splx(s);
break;
case SIOCSIFMETRIC:
@@ -2046,11 +2047,9 @@ ifioctl(struct socket *so, u_long cmd, c
default:
if (so->so_proto == 0)
return (EOPNOTSUPP);
- s = splsoftnet();
error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL,
(struct mbuf *) cmd, (struct mbuf *) data,
(struct mbuf *) ifp, p));
- splx(s);
break;
}
Index: net/if.h
===================================================================
RCS file: /cvs/src/sys/net/if.h,v
retrieving revision 1.180
diff -u -p -r1.180 if.h
--- net/if.h 27 Oct 2016 03:00:35 -0000 1.180
+++ net/if.h 21 Nov 2016 10:31:30 -0000
@@ -467,7 +467,6 @@ void if_detach(struct ifnet *);
void if_down(struct ifnet *);
void if_downall(void);
void if_link_state_change(struct ifnet *);
-void if_slowtimo(void *);
void if_up(struct ifnet *);
int ifconf(u_long, caddr_t);
void ifinit(void);
@@ -485,7 +484,6 @@ void if_congestion(void);
int if_congested(void);
__dead void unhandled_af(int);
int if_setlladdr(struct ifnet *, const uint8_t *);
-int if_setrdomain(struct ifnet *, int);
#endif /* _KERNEL */
Index: net/if_tun.c
===================================================================
RCS file: /cvs/src/sys/net/if_tun.c,v
retrieving revision 1.169
diff -u -p -r1.169 if_tun.c
--- net/if_tun.c 4 Sep 2016 15:46:39 -0000 1.169
+++ net/if_tun.c 21 Nov 2016 10:31:30 -0000
@@ -312,14 +312,17 @@ int
tunopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct tun_softc *tp;
- int error;
+ unsigned int rdomain = rtable_l2(p->p_p->ps_rtableid);
if ((tp = tun_lookup(minor(dev))) == NULL) { /* create on demand */
char xname[IFNAMSIZ];
+ int s, error;
snprintf(xname, sizeof(xname), "%s%d", "tun", minor(dev));
- if ((error = if_clone_create(xname,
- rtable_l2(p->p_p->ps_rtableid))) != 0)
+ s = splsoftnet();
+ error = if_clone_create(xname, rdomain);
+ splx(s);
+ if (error != 0)
return (error);
if ((tp = tun_lookup(minor(dev))) == NULL)
@@ -334,14 +337,17 @@ int
tapopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct tun_softc *tp;
- int error;
+ unsigned int rdomain = rtable_l2(p->p_p->ps_rtableid);
if ((tp = tap_lookup(minor(dev))) == NULL) { /* create on demand */
char xname[IFNAMSIZ];
+ int s, error;
snprintf(xname, sizeof(xname), "%s%d", "tap", minor(dev));
- if ((error = if_clone_create(xname,
- rtable_l2(p->p_p->ps_rtableid))) != 0)
+ s = splsoftnet();
+ error = if_clone_create(xname, rdomain);
+ splx(s);
+ if (error != 0)
return (error);
if ((tp = tap_lookup(minor(dev))) == NULL)
@@ -403,7 +409,7 @@ tapclose(dev_t dev, int flag, int mode,
int
tun_dev_close(struct tun_softc *tp, int flag, int mode, struct proc *p)
{
- int s;
+ int s, error = 0;
struct ifnet *ifp;
ifp = &tp->tun_if;
@@ -420,14 +426,16 @@ tun_dev_close(struct tun_softc *tp, int
TUNDEBUG(("%s: closed\n", ifp->if_xname));
- if (!(tp->tun_flags & TUN_STAYUP))
- return (if_clone_destroy(ifp->if_xname));
- else {
+ if (!(tp->tun_flags & TUN_STAYUP)) {
+ s = splsoftnet();
+ error = if_clone_destroy(ifp->if_xname);
+ splx(s);
+ } else {
tp->tun_pgid = 0;
selwakeup(&tp->tun_rsel);
}
- return (0);
+ return (error);
}
int
Index: net/pf_if.c
===================================================================
RCS file: /cvs/src/sys/net/pf_if.c,v
retrieving revision 1.87
diff -u -p -r1.87 pf_if.c
--- net/pf_if.c 16 Nov 2016 08:46:05 -0000 1.87
+++ net/pf_if.c 21 Nov 2016 10:31:30 -0000
@@ -223,10 +223,8 @@ void
pfi_attach_ifnet(struct ifnet *ifp)
{
struct pfi_kif *kif;
- int s;
pfi_initialize();
- s = splsoftnet();
pfi_update++;
if ((kif = pfi_kif_get(ifp->if_xname)) == NULL)
panic("pfi_kif_get failed");
@@ -240,20 +238,16 @@ pfi_attach_ifnet(struct ifnet *ifp)
ifp->if_xname);
pfi_kif_update(kif);
-
- splx(s);
}
void
pfi_detach_ifnet(struct ifnet *ifp)
{
- int s;
struct pfi_kif *kif;
if ((kif = (struct pfi_kif *)ifp->if_pf_kif) == NULL)
return;
- s = splsoftnet();
pfi_update++;
hook_disestablish(ifp->if_addrhooks, kif->pfik_ah_cookie);
pfi_kif_update(kif);
@@ -261,60 +255,47 @@ pfi_detach_ifnet(struct ifnet *ifp)
kif->pfik_ifp = NULL;
ifp->if_pf_kif = NULL;
pfi_kif_unref(kif, PFI_KIF_REF_NONE);
-
- splx(s);
}
void
pfi_attach_ifgroup(struct ifg_group *ifg)
{
struct pfi_kif *kif;
- int s;
pfi_initialize();
- s = splsoftnet();
pfi_update++;
if ((kif = pfi_kif_get(ifg->ifg_group)) == NULL)
panic("pfi_kif_get failed");
kif->pfik_group = ifg;
ifg->ifg_pf_kif = (caddr_t)kif;
-
- splx(s);
}
void
pfi_detach_ifgroup(struct ifg_group *ifg)
{
- int s;
struct pfi_kif *kif;
if ((kif = (struct pfi_kif *)ifg->ifg_pf_kif) == NULL)
return;
- s = splsoftnet();
pfi_update++;
kif->pfik_group = NULL;
ifg->ifg_pf_kif = NULL;
pfi_kif_unref(kif, PFI_KIF_REF_NONE);
- splx(s);
}
void
pfi_group_change(const char *group)
{
struct pfi_kif *kif;
- int s;
- s = splsoftnet();
pfi_update++;
if ((kif = pfi_kif_get(group)) == NULL)
panic("pfi_kif_get failed");
pfi_kif_update(kif);
-
- splx(s);
}
int
@@ -611,13 +592,12 @@ pfi_dynaddr_copyout(struct pf_addr_wrap
void
pfi_kifaddr_update(void *v)
{
- int s;
struct pfi_kif *kif = (struct pfi_kif *)v;
- s = splsoftnet();
+ splsoftassert(IPL_SOFTNET);
+
pfi_update++;
pfi_kif_update(kif);
- splx(s);
}
int
Index: net/route.c
===================================================================
RCS file: /cvs/src/sys/net/route.c,v
retrieving revision 1.339
diff -u -p -r1.339 route.c
--- net/route.c 21 Nov 2016 10:30:42 -0000 1.339
+++ net/route.c 21 Nov 2016 10:31:30 -0000
@@ -237,9 +237,10 @@ struct rtentry *
rt_match(struct sockaddr *dst, uint32_t *src, int flags, unsigned int tableid)
{
struct rtentry *rt0, *rt = NULL;
- int s, error = 0;
+ int error = 0;
+
+ splsoftassert(IPL_SOFTNET);
- s = splsoftnet();
rt = rtable_match(tableid, dst, src);
if (rt != NULL) {
if ((rt->rt_flags & RTF_CLONING) && ISSET(flags, RT_RESOLVE)) {
@@ -266,7 +267,6 @@ rt_match(struct sockaddr *dst, uint32_t
rt->rt_use++;
} else
rtstat.rts_unreach++;
- splx(s);
return (rt);
}
Index: netinet/igmp.c
===================================================================
RCS file: /cvs/src/sys/netinet/igmp.c,v
retrieving revision 1.54
diff -u -p -r1.54 igmp.c
--- netinet/igmp.c 11 Nov 2015 10:01:46 -0000 1.54
+++ netinet/igmp.c 21 Nov 2016 10:31:30 -0000
@@ -498,10 +498,9 @@ void
igmp_joingroup(struct in_multi *inm)
{
struct ifnet* ifp;
- int i, s;
+ int i;
ifp = if_get(inm->inm_ifidx);
- s = splsoftnet();
inm->inm_state = IGMP_IDLE_MEMBER;
@@ -519,7 +518,6 @@ igmp_joingroup(struct in_multi *inm)
inm->inm_timer = 0;
out:
- splx(s);
if_put(ifp);
}
@@ -527,10 +525,8 @@ void
igmp_leavegroup(struct in_multi *inm)
{
struct ifnet* ifp;
- int s;
ifp = if_get(inm->inm_ifidx);
- s = splsoftnet();
switch (inm->inm_state) {
case IGMP_DELAYING_MEMBER:
@@ -546,7 +542,6 @@ igmp_leavegroup(struct in_multi *inm)
case IGMP_SLEEPING_MEMBER:
break;
}
- splx(s);
if_put(ifp);
}
@@ -554,7 +549,8 @@ void
igmp_fasttimo(void)
{
struct ifnet *ifp;
- int s;
+
+ splsoftassert(IPL_SOFTNET);
/*
* Quick check to see if any work needs to be done, in order
@@ -563,11 +559,9 @@ igmp_fasttimo(void)
if (!igmp_timers_are_running)
return;
- s = splsoftnet();
igmp_timers_are_running = 0;
TAILQ_FOREACH(ifp, &ifnet, if_list)
igmp_checktimer(ifp);
- splx(s);
}
@@ -605,16 +599,15 @@ void
igmp_slowtimo(void)
{
struct router_info *rti;
- int s;
- s = splsoftnet();
+ splsoftassert(IPL_SOFTNET);
+
for (rti = rti_head; rti != 0; rti = rti->rti_next) {
if (rti->rti_type == IGMP_v1_ROUTER &&
++rti->rti_age >= IGMP_AGE_THRESHOLD) {
rti->rti_type = IGMP_v2_ROUTER;
}
}
- splx(s);
}
void
Index: netinet/in.c
===================================================================
RCS file: /cvs/src/sys/netinet/in.c,v
retrieving revision 1.129
diff -u -p -r1.129 in.c
--- netinet/in.c 4 Sep 2016 10:32:01 -0000 1.129
+++ netinet/in.c 21 Nov 2016 10:31:30 -0000
@@ -212,6 +212,8 @@ in_ioctl(u_long cmd, caddr_t data, struc
int newifaddr;
int s;
+ splsoftassert(IPL_SOFTNET);
+
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
if (ifa->ifa_addr->sa_family == AF_INET) {
ia = ifatoia(ifa);
@@ -329,12 +331,10 @@ in_ioctl(u_long cmd, caddr_t data, struc
break;
case SIOCSIFADDR:
- s = splsoftnet();
in_ifscrub(ifp, ia);
error = in_ifinit(ifp, ia, satosin(&ifr->ifr_addr), newifaddr);
if (!error)
dohooks(ifp->if_addrhooks, 0);
- splx(s);
return (error);
case SIOCSIFNETMASK:
@@ -347,7 +347,6 @@ in_ioctl(u_long cmd, caddr_t data, struc
error = 0;
- s = splsoftnet();
if (ia->ia_addr.sin_family == AF_INET) {
if (ifra->ifra_addr.sin_len == 0)
ifra->ifra_addr = ia->ia_addr;
@@ -380,7 +379,6 @@ in_ioctl(u_long cmd, caddr_t data, struc
}
if (!error)
dohooks(ifp->if_addrhooks, 0);
- splx(s);
return (error);
}
case SIOCDIFADDR:
@@ -390,10 +388,8 @@ in_ioctl(u_long cmd, caddr_t data, struc
* should happen to a packet that was routed after
* the scrub but before the other steps?
*/
- s = splsoftnet();
in_purgeaddr(&ia->ia_ifa);
dohooks(ifp->if_addrhooks, 0);
- splx(s);
break;
default:
@@ -798,7 +794,8 @@ in_addmulti(struct in_addr *ap, struct i
{
struct in_multi *inm;
struct ifreq ifr;
- int s;
+
+ splsoftassert(IPL_SOFTNET);
/*
* See if address already in list.
@@ -839,10 +836,8 @@ in_addmulti(struct in_addr *ap, struct i
return (NULL);
}
- s = splsoftnet();
TAILQ_INSERT_HEAD(&ifp->if_maddrlist, &inm->inm_ifma,
ifma_list);
- splx(s);
/*
* Let IGMP know that we have joined a new IP multicast group.
@@ -861,7 +856,8 @@ in_delmulti(struct in_multi *inm)
{
struct ifreq ifr;
struct ifnet *ifp;
- int s;
+
+ splsoftassert(IPL_SOFTNET);
if (--inm->inm_refcnt == 0) {
/*
@@ -883,10 +879,8 @@ in_delmulti(struct in_multi *inm)
satosin(&ifr.ifr_addr)->sin_addr = inm->inm_addr;
(*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)&ifr);
- s = splsoftnet();
TAILQ_REMOVE(&ifp->if_maddrlist, &inm->inm_ifma,
ifma_list);
- splx(s);
}
if_put(ifp);
Index: netinet/ip_input.c
===================================================================
RCS file: /cvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.285
diff -u -p -r1.285 ip_input.c
--- netinet/ip_input.c 14 Nov 2016 04:27:03 -0000 1.285
+++ netinet/ip_input.c 21 Nov 2016 10:31:30 -0000
@@ -978,7 +978,8 @@ void
ip_slowtimo(void)
{
struct ipq *fp, *nfp;
- int s = splsoftnet();
+
+ splsoftassert(IPL_SOFTNET);
for (fp = LIST_FIRST(&ipq); fp != NULL; fp = nfp) {
nfp = LIST_NEXT(fp, ipq_q);
@@ -987,7 +988,6 @@ ip_slowtimo(void)
ip_freef(fp);
}
}
- splx(s);
}
/*
Index: netinet/tcp_timer.c
===================================================================
RCS file: /cvs/src/sys/netinet/tcp_timer.c,v
retrieving revision 1.51
diff -u -p -r1.51 tcp_timer.c
--- netinet/tcp_timer.c 7 Nov 2016 09:08:06 -0000 1.51
+++ netinet/tcp_timer.c 21 Nov 2016 10:31:30 -0000
@@ -129,13 +129,11 @@ tcp_delack(void *arg)
void
tcp_slowtimo(void)
{
- int s;
+ splsoftassert(IPL_SOFTNET);
- s = splsoftnet();
tcp_maxidle = TCPTV_KEEPCNT * tcp_keepintvl;
tcp_iss += TCP_ISSINCR2/PR_SLOWHZ; /* increment iss */
tcp_now++; /* for timestamps */
- splx(s);
}
/*
Index: netinet6/frag6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/frag6.c,v
retrieving revision 1.70
diff -u -p -r1.70 frag6.c
--- netinet6/frag6.c 24 Oct 2016 11:09:05 -0000 1.70
+++ netinet6/frag6.c 21 Nov 2016 10:31:30 -0000
@@ -602,9 +602,9 @@ void
frag6_slowtimo(void)
{
struct ip6q *q6, *nq6;
- int s;
- s = splsoftnet();
+ splsoftassert(IPL_SOFTNET);
+
IP6Q_LOCK();
TAILQ_FOREACH_SAFE(q6, &frag6_queue, ip6q_queue, nq6)
if (--q6->ip6q_ttl == 0) {
@@ -623,7 +623,6 @@ frag6_slowtimo(void)
frag6_freef(TAILQ_LAST(&frag6_queue, ip6q_head));
}
IP6Q_UNLOCK();
- splx(s);
}
/*
Index: netinet6/in6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.194
diff -u -p -r1.194 in6.c
--- netinet6/in6.c 4 Oct 2016 14:04:19 -0000 1.194
+++ netinet6/in6.c 21 Nov 2016 10:31:30 -0000
@@ -190,7 +190,8 @@ in6_ioctl(u_long cmd, caddr_t data, stru
struct in6_ifaddr *ia6 = NULL;
struct in6_aliasreq *ifra = (struct in6_aliasreq *)data;
struct sockaddr_in6 *sa6;
- int s;
+
+ splsoftassert(IPL_SOFTNET);
if (ifp == NULL)
return (EOPNOTSUPP);
@@ -423,14 +424,10 @@ in6_ioctl(u_long cmd, caddr_t data, stru
* and link it to the list. try to enable inet6 if there
* is no link-local yet.
*/
- s = splsoftnet();
error = in6_ifattach(ifp);
- if (error != 0) {
- splx(s);
+ if (error != 0)
return (error);
- }
error = in6_update_ifa(ifp, ifra, ia6);
- splx(s);
if (error != 0)
return (error);
@@ -458,24 +455,19 @@ in6_ioctl(u_long cmd, caddr_t data, stru
break; /* No need to install a connected route. */
}
- s = splsoftnet();
error = rt_ifa_add(&ia6->ia_ifa, RTF_CLONING | RTF_CONNECTED,
ia6->ia_ifa.ifa_addr);
if (error) {
in6_purgeaddr(&ia6->ia_ifa);
- splx(s);
return (error);
}
dohooks(ifp->if_addrhooks, 0);
- splx(s);
break;
}
case SIOCDIFADDR_IN6:
- s = splsoftnet();
in6_purgeaddr(&ia6->ia_ifa);
dohooks(ifp->if_addrhooks, 0);
- splx(s);
break;
default:
@@ -1231,7 +1223,8 @@ in6_addmulti(struct in6_addr *maddr6, st
{
struct in6_ifreq ifr;
struct in6_multi *in6m;
- int s;
+
+ splsoftassert(IPL_SOFTNET);
*errorp = 0;
/*
@@ -1277,10 +1270,8 @@ in6_addmulti(struct in6_addr *maddr6, st
return (NULL);
}
- s = splsoftnet();
TAILQ_INSERT_HEAD(&ifp->if_maddrlist, &in6m->in6m_ifma,
ifma_list);
- splx(s);
/*
* Let MLD6 know that we have joined a new IP6 multicast
Index: netinet6/in6_ifattach.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6_ifattach.c,v
retrieving revision 1.100
diff -u -p -r1.100 in6_ifattach.c
--- netinet6/in6_ifattach.c 30 Jun 2016 08:19:03 -0000 1.100
+++ netinet6/in6_ifattach.c 21 Nov 2016 10:31:30 -0000
@@ -294,7 +294,9 @@ in6_ifattach_linklocal(struct ifnet *ifp
{
struct in6_aliasreq ifra;
struct in6_ifaddr *ia6;
- int s, error, flags;
+ int error, flags;
+
+ splsoftassert(IPL_SOFTNET);
/*
* configure link-local address.
@@ -338,9 +340,7 @@ in6_ifattach_linklocal(struct ifnet *ifp
if (in6if_do_dad(ifp) && ((ifp->if_flags & IFF_POINTOPOINT) == 0))
ifra.ifra_flags |= IN6_IFF_TENTATIVE;
- s = splsoftnet();
error = in6_update_ifa(ifp, &ifra, in6ifa_ifpforlinklocal(ifp, 0));
- splx(s);
if (error != 0)
return (error);
@@ -359,15 +359,12 @@ in6_ifattach_linklocal(struct ifnet *ifp
if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
flags |= RTF_CLONING;
- s = splsoftnet();
error = rt_ifa_add(&ia6->ia_ifa, flags, ia6->ia_ifa.ifa_addr);
if (error) {
in6_purgeaddr(&ia6->ia_ifa);
- splx(s);
return (error);
}
dohooks(ifp->if_addrhooks, 0);
- splx(s);
return (0);
}
Index: netinet6/mld6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/mld6.c,v
retrieving revision 1.48
diff -u -p -r1.48 mld6.c
--- netinet6/mld6.c 5 Jul 2016 10:17:14 -0000 1.48
+++ netinet6/mld6.c 21 Nov 2016 10:31:30 -0000
@@ -117,7 +117,7 @@ mld6_init(void)
void
mld6_start_listening(struct in6_multi *in6m)
{
- int s = splsoftnet();
+ splsoftassert(IPL_SOFTNET);
/*
* RFC2710 page 10:
@@ -139,13 +139,12 @@ mld6_start_listening(struct in6_multi *i
in6m->in6m_state = MLD_IREPORTEDLAST;
mld_timers_are_running = 1;
}
- splx(s);
}
void
mld6_stop_listening(struct in6_multi *in6m)
{
- int s = splsoftnet();
+ splsoftassert(IPL_SOFTNET);
mld_all_nodes_linklocal.s6_addr16[1] = htons(in6m->in6m_ifidx);/* XXX */
mld_all_routers_linklocal.s6_addr16[1] =
@@ -156,7 +155,6 @@ mld6_stop_listening(struct in6_multi *in
__IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) >
__IPV6_ADDR_SCOPE_INTFACELOCAL)
mld6_sendpkt(in6m, MLD_LISTENER_DONE,
&mld_all_routers_linklocal);
- splx(s);
}
void
@@ -331,7 +329,8 @@ void
mld6_fasttimeo(void)
{
struct ifnet *ifp;
- int s;
+
+ splsoftassert(IPL_SOFTNET);
/*
* Quick check to see if any work needs to be done, in order
@@ -340,11 +339,9 @@ mld6_fasttimeo(void)
if (!mld_timers_are_running)
return;
- s = splsoftnet();
mld_timers_are_running = 0;
TAILQ_FOREACH(ifp, &ifnet, if_list)
mld6_checktimer(ifp);
- splx(s);
}
void
Index: netinet6/nd6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6.c,v
retrieving revision 1.195
diff -u -p -r1.195 nd6.c
--- netinet6/nd6.c 15 Nov 2016 13:12:24 -0000 1.195
+++ netinet6/nd6.c 21 Nov 2016 11:03:03 -0000
@@ -502,6 +502,8 @@ nd6_purge(struct ifnet *ifp)
struct nd_defrouter *dr, *ndr;
struct nd_prefix *pr, *npr;
+ splsoftassert(IPL_SOFTNET);
+
/*
* Nuke default router list entries toward ifp.
* We defer removal of default router list entries that is installed
@@ -731,7 +733,8 @@ nd6_free(struct rtentry *rt, int gc)
struct in6_addr in6 = satosin6(rt_key(rt))->sin6_addr;
struct nd_defrouter *dr;
struct ifnet *ifp;
- int s;
+
+ splsoftassert(IPL_SOFTNET);
/*
* we used to have pfctlinput(PRC_HOSTDEAD) here.
@@ -739,7 +742,6 @@ nd6_free(struct rtentry *rt, int gc)
*/
ifp = if_get(rt->rt_ifidx);
- s = splsoftnet();
if (!ip6_forwarding) {
dr = defrouter_lookup(&satosin6(rt_key(rt))->sin6_addr,
rt->rt_ifidx);
@@ -763,7 +765,6 @@ nd6_free(struct rtentry *rt, int gc)
dr->expire - time_uptime);
} else
nd6_llinfo_settimer(ln, nd6_gctimer);
- splx(s);
if_put(ifp);
return (TAILQ_NEXT(ln, ln_list));
}
@@ -823,7 +824,6 @@ nd6_free(struct rtentry *rt, int gc)
*/
if (!ISSET(rt->rt_flags, RTF_STATIC|RTF_CACHED))
rtdeletemsg(rt, ifp, ifp->if_rdomain);
- splx(s);
if_put(ifp);
Index: netinet6/nd6.h
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6.h,v
retrieving revision 1.64
diff -u -p -r1.64 nd6.h
--- netinet6/nd6.h 21 Nov 2016 10:52:08 -0000 1.64
+++ netinet6/nd6.h 21 Nov 2016 11:05:04 -0000
@@ -288,13 +288,10 @@ void nd6_rs_detach(struct ifnet *);
void nd6_rs_input(struct mbuf *, int, int);
void prelist_del(struct nd_prefix *);
-void defrouter_addreq(struct nd_defrouter *);
void defrouter_reset(void);
void defrouter_select(void);
void defrtrlist_del(struct nd_defrouter *);
void prelist_remove(struct nd_prefix *);
-int nd6_prelist_add(struct nd_prefix *, struct nd_defrouter *,
- struct nd_prefix **);
void pfxlist_onlink_check(void);
struct nd_defrouter *defrouter_lookup(struct in6_addr *, unsigned int);
Index: netinet6/nd6_nbr.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6_nbr.c,v
retrieving revision 1.110
diff -u -p -r1.110 nd6_nbr.c
--- netinet6/nd6_nbr.c 23 Aug 2016 11:03:10 -0000 1.110
+++ netinet6/nd6_nbr.c 21 Nov 2016 11:00:51 -0000
@@ -1101,7 +1101,8 @@ nd6_dad_start(struct ifaddr *ifa)
struct in6_ifaddr *ia6 = ifatoia6(ifa);
struct dadq *dp;
char addr[INET6_ADDRSTRLEN];
- int s;
+
+ splsoftassert(IPL_SOFTNET);
if (!dad_init) {
TAILQ_INIT(&dadq);
@@ -1126,16 +1127,14 @@ nd6_dad_start(struct ifaddr *ifa)
dp = malloc(sizeof(*dp), M_IP6NDP, M_NOWAIT | M_ZERO);
if (dp == NULL) {
- log(LOG_ERR, "nd6_dad_start: memory allocation failed for "
- "%s(%s)\n",
- inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr,
+ log(LOG_ERR, "%s: memory allocation failed for %s(%s)\n",
+ __func__, inet_ntop(AF_INET6, &ia6->ia_addr.sin6_addr,
addr, sizeof(addr)),
ifa->ifa_ifp ? ifa->ifa_ifp->if_xname : "???");
return;
}
bzero(&dp->dad_timer_ch, sizeof(dp->dad_timer_ch));
- s = splsoftnet();
TAILQ_INSERT_TAIL(&dadq, (struct dadq *)dp, dad_list);
ip6_dad_pending++;
@@ -1156,7 +1155,6 @@ nd6_dad_start(struct ifaddr *ifa)
nd6_dad_ns_output(dp, ifa);
nd6_dad_starttimer(dp,
(long)ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000);
- splx(s);
}
/*
Index: netinet6/nd6_rtr.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6_rtr.c,v
retrieving revision 1.151
diff -u -p -r1.151 nd6_rtr.c
--- netinet6/nd6_rtr.c 21 Nov 2016 10:56:26 -0000 1.151
+++ netinet6/nd6_rtr.c 21 Nov 2016 11:06:33 -0000
@@ -70,6 +70,9 @@ int nd6_prefix_onlink(struct nd_prefix *
int nd6_prefix_offlink(struct nd_prefix *);
void in6_init_address_ltimes(struct nd_prefix *, struct in6_addrlifetime *);
int prelist_update(struct nd_prefix *, struct nd_defrouter *, struct mbuf *);
+int nd6_prelist_add(struct nd_prefix *, struct nd_defrouter *,
+ struct nd_prefix **);
+void defrouter_addreq(struct nd_defrouter *);
int rt6_deleteroute(struct rtentry *, void *, unsigned int);
void nd6_addr_add(void *);
@@ -578,7 +581,6 @@ defrouter_addreq(struct nd_defrouter *ne
struct rt_addrinfo info;
struct sockaddr_in6 def, mask, gate;
struct rtentry *rt;
- int s;
int error;
memset(&def, 0, sizeof(def));
@@ -597,7 +599,6 @@ defrouter_addreq(struct nd_defrouter *ne
info.rti_info[RTAX_GATEWAY] = sin6tosa(&gate);
info.rti_info[RTAX_NETMASK] = sin6tosa(&mask);
- s = splsoftnet();
error = rtrequest(RTM_ADD, &info, RTP_DEFAULT, &rt,
new->ifp->if_rdomain);
if (error == 0) {
@@ -605,8 +606,6 @@ defrouter_addreq(struct nd_defrouter *ne
rtfree(rt);
new->installed = 1;
}
- splx(s);
- return;
}
struct nd_defrouter *
@@ -758,14 +757,12 @@ defrouter_select(void)
struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL;
struct rtentry *rt = NULL;
struct llinfo_nd6 *ln = NULL;
- int s = splsoftnet();
/*
* Let's handle easy case (3) first:
* If default router list is empty, there's nothing to be done.
*/
if (TAILQ_EMPTY(&nd_defrouter)) {
- splx(s);
return;
}
@@ -830,9 +827,6 @@ defrouter_select(void)
defrouter_delreq(installed_dr);
defrouter_addreq(selected_dr);
}
-
- splx(s);
- return;
}
/*
@@ -1049,14 +1043,14 @@ nd6_prelist_add(struct nd_prefix *pr, st
struct nd_prefix **newp)
{
struct nd_prefix *new = NULL;
- int i, s;
struct in6_ifextra *ext = pr->ndpr_ifp->if_afdata[AF_INET6];
+ int i;
+
+ splsoftassert(IPL_SOFTNET);
if (ip6_maxifprefixes >= 0) {
if (ext->nprefixes >= ip6_maxifprefixes / 2) {
- s = splsoftnet();
purge_detached(pr->ndpr_ifp);
- splx(s);
}
if (ext->nprefixes >= ip6_maxifprefixes)
return(ENOMEM);
@@ -1079,7 +1073,6 @@ nd6_prelist_add(struct nd_prefix *pr, st
task_set(&new->ndpr_task, nd6_addr_add, new);
- s = splsoftnet();
/* link ndpr_entry to nd_prefix list */
LIST_INSERT_HEAD(&nd_prefix, new, ndpr_entry);
@@ -1089,8 +1082,8 @@ nd6_prelist_add(struct nd_prefix *pr, st
int e;
if ((e = nd6_prefix_onlink(new)) != 0) {
- nd6log((LOG_ERR, "nd6_prelist_add: failed to make "
- "the prefix %s/%d on-link on %s (errno=%d)\n",
+ nd6log((LOG_ERR, "%s: failed to make the prefix %s/%d"
+ " on-link 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));
@@ -1100,7 +1093,6 @@ nd6_prelist_add(struct nd_prefix *pr, st
if (dr)
pfxrtr_add(new, dr);
- splx(s);
ext->nprefixes++;