summaryrefslogtreecommitdiff
path: root/sys/netinet6
diff options
context:
space:
mode:
authorozaki-r <ozaki-r@NetBSD.org>2017-09-27 10:05:04 +0000
committerozaki-r <ozaki-r@NetBSD.org>2017-09-27 10:05:04 +0000
commit9ec002730b264aad540a9cedca53e2578486d785 (patch)
treeb7b85b81b17189ce1adec9079459c490de9912ad /sys/netinet6
parent0cd953860d6624511a69e27fee0a4e91c1bd509b (diff)
Take softnet_lock on pr_input properly if NET_MPSAFE
Currently softnet_lock is taken unnecessarily in some cases, e.g., icmp_input and encap4_input from ip_input, or not taken even if needed, e.g., udp_input and tcp_input from ipsec4_common_input_cb. Fix them. NFC if NET_MPSAFE is disabled (default).
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6_proto.c38
-rw-r--r--sys/netinet6/ip6_input.c6
-rw-r--r--sys/netinet6/ip6protosw.h15
3 files changed, 52 insertions, 7 deletions
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index f7ff2029964..455daf6bf15 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_proto.c,v 1.118 2017/09/21 07:15:35 ozaki-r Exp $ */
+/* $NetBSD: in6_proto.c,v 1.119 2017/09/27 10:05:05 ozaki-r Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.118 2017/09/21 07:15:35 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.119 2017/09/27 10:05:05 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_gateway.h"
@@ -70,6 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.118 2017/09/21 07:15:35 ozaki-r Exp
#include "opt_ipsec.h"
#include "opt_dccp.h"
#include "opt_sctp.h"
+#include "opt_net_mpsafe.h"
#endif
#include <sys/param.h>
@@ -184,6 +185,39 @@ PR_WRAP_CTLOUTPUT(sctp_ctloutput)
#define sctp_ctloutput sctp_ctloutput_wrapper
#endif
+#ifdef NET_MPSAFE
+PR_WRAP_INPUT6(udp6_input)
+PR_WRAP_INPUT6(tcp6_input)
+#ifdef DCCP
+PR_WRAP_INPUT6(dccp6_input)
+#endif
+#ifdef SCTP
+PR_WRAP_INPUT6(sctp6_input)
+#endif
+PR_WRAP_INPUT6(rip6_input)
+PR_WRAP_INPUT6(dest6_input)
+PR_WRAP_INPUT6(route6_input)
+PR_WRAP_INPUT6(frag6_input)
+#if NETHERIP > 0
+PR_WRAP_INPUT6(ip6_etherip_input)
+#endif
+#if NPFSYNC > 0
+PR_WRAP_INPUT6(pfsync_input)
+#endif
+PR_WRAP_INPUT6(pim6_input)
+
+#define udp6_input udp6_input_wrapper
+#define tcp6_input tcp6_input_wrapper
+#define dccp6_input dccp6_input_wrapper
+#define sctp6_input sctp6_input_wrapper
+#define rip6_input rip6_input_wrapper
+#define dest6_input dest6_input_wrapper
+#define route6_input route6_input_wrapper
+#define frag6_input frag6_input_wrapper
+#define ip6_etherip_input ip6_etherip_input_wrapper
+#define pim6_input pim6_input_wrapper
+#endif
+
#if defined(IPSEC)
#ifdef IPSEC_RUMPKERNEL
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index ab1b7943512..17a0a88f49e 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_input.c,v 1.181 2017/07/27 06:59:28 ozaki-r Exp $ */
+/* $NetBSD: ip6_input.c,v 1.182 2017/09/27 10:05:05 ozaki-r Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.181 2017/07/27 06:59:28 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.182 2017/09/27 10:05:05 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_gateway.h"
@@ -797,9 +797,7 @@ ip6_input(struct mbuf *m, struct ifnet *rcvif)
}
#endif /* IPSEC */
- SOFTNET_LOCK();
nxt = (*inet6sw[ip6_protox[nxt]].pr_input)(&m, &off, nxt);
- SOFTNET_UNLOCK();
}
return;
diff --git a/sys/netinet6/ip6protosw.h b/sys/netinet6/ip6protosw.h
index fdbd99dc5f7..7d8c97ecfaa 100644
--- a/sys/netinet6/ip6protosw.h
+++ b/sys/netinet6/ip6protosw.h
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6protosw.h,v 1.25 2016/01/21 15:41:30 riastradh Exp $ */
+/* $NetBSD: ip6protosw.h,v 1.26 2017/09/27 10:05:05 ozaki-r Exp $ */
/* $KAME: ip6protosw.h,v 1.22 2001/02/08 18:02:08 itojun Exp $ */
/*
@@ -140,6 +140,19 @@ struct ip6protosw {
(void);
};
+#ifdef _KERNEL
+#define PR_WRAP_INPUT6(name) \
+static int \
+name##_wrapper(struct mbuf **mp, int *offp, int proto) \
+{ \
+ int rv; \
+ mutex_enter(softnet_lock); \
+ rv = name(mp, offp, proto); \
+ mutex_exit(softnet_lock); \
+ return rv; \
+}
+#endif
+
extern const struct ip6protosw inet6sw[];
#endif /* !_NETINET6_IP6PROTOSW_H_ */