commit 53e068e7fbe2f5c7a98c2202481a50e6cb1cb936 Author: Ryota Ozaki <ozaki-r@iij.ad.jp> Date: Thu Feb 22 16:13:08 2018 +0900 Don't beleave softnet_lock diff --git a/sys/netinet/in.c b/sys/netinet/in.c index ed7e27e6b26..831bda16572 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -751,9 +751,10 @@ in_control(struct socket *so, u_long cmd, void *data, struct ifnet *ifp) { int error; - SOFTNET_LOCK_UNLESS_NET_MPSAFE(); +#ifndef NET_MPSAFE + KASSERT(KERNEL_LOCKED_P()); +#endif error = in_control0(so, cmd, data, ifp); - SOFTNET_UNLOCK_UNLESS_NET_MPSAFE(); return error; } diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 6878751536b..ddaf8909a15 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -404,11 +404,11 @@ ipintr(void *arg __unused) KASSERT(cpu_softintr_p()); - SOFTNET_LOCK_UNLESS_NET_MPSAFE(); + SOFTNET_KERNEL_LOCK_UNLESS_NET_MPSAFE(); while ((m = pktq_dequeue(ip_pktq)) != NULL) { ip_input(m); } - SOFTNET_UNLOCK_UNLESS_NET_MPSAFE(); + SOFTNET_KERNEL_UNLOCK_UNLESS_NET_MPSAFE(); } /* diff --git a/sys/netinet/wqinput.c b/sys/netinet/wqinput.c index 1faf6603df5..f0adebe5393 100644 --- a/sys/netinet/wqinput.c +++ b/sys/netinet/wqinput.c @@ -26,6 +26,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#ifdef _KERNEL_OPT +#include "opt_net_mpsafe.h" +#endif + #include <sys/param.h> #include <sys/kmem.h> #include <sys/mbuf.h> @@ -210,7 +214,9 @@ wqinput_work(struct work *wk, void *arg) while ((work = wqinput_work_get(wwl)) != NULL) { mutex_enter(softnet_lock); + KERNEL_LOCK_UNLESS_NET_MPSAFE(); wqi->wqi_input(work->ww_mbuf, work->ww_off, work->ww_proto); + KERNEL_UNLOCK_UNLESS_NET_MPSAFE(); mutex_exit(softnet_lock); pool_put(&wqi->wqi_work_pool, work); diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 6e9f39b6aa4..37422e34f36 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -767,9 +767,10 @@ in6_control(struct socket *so, u_long cmd, void *data, struct ifnet *ifp) } s = splsoftnet(); - SOFTNET_LOCK_UNLESS_NET_MPSAFE(); +#ifndef NET_MPSAFE + KASSERT(KERNEL_LOCKED_P()); +#endif error = in6_control1(so , cmd, data, ifp); - SOFTNET_UNLOCK_UNLESS_NET_MPSAFE(); splx(s); return error; } diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index bc631f665f5..669a92a8c19 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -218,7 +218,7 @@ ip6intr(void *arg __unused) { struct mbuf *m; - SOFTNET_LOCK_UNLESS_NET_MPSAFE(); + SOFTNET_KERNEL_LOCK_UNLESS_NET_MPSAFE(); while ((m = pktq_dequeue(ip6_pktq)) != NULL) { struct psref psref; struct ifnet *rcvif = m_get_rcvif_psref(m, &psref); @@ -238,7 +238,7 @@ ip6intr(void *arg __unused) ip6_input(m, rcvif); m_put_rcvif_psref(rcvif, &psref); } - SOFTNET_UNLOCK_UNLESS_NET_MPSAFE(); + SOFTNET_KERNEL_UNLOCK_UNLESS_NET_MPSAFE(); } void diff --git a/sys/rump/net/lib/libnetinet/netinet_component.c b/sys/rump/net/lib/libnetinet/netinet_component.c index 820fa283271..9b050560ee9 100644 --- a/sys/rump/net/lib/libnetinet/netinet_component.c +++ b/sys/rump/net/lib/libnetinet/netinet_component.c @@ -94,9 +94,11 @@ RUMP_COMPONENT(RUMP_COMPONENT_NET_IFCFG) sin->sin_len = sizeof(struct sockaddr_in); sin->sin_addr.s_addr = inet_addr("127.255.255.255"); + KERNEL_LOCK(1, NULL); IFNET_LOCK(lo0ifp); in_control(so, SIOCAIFADDR, &ia, lo0ifp); IFNET_UNLOCK(lo0ifp); + KERNEL_UNLOCK_ONE(NULL); if_up(lo0ifp); soclose(so); }