summaryrefslogtreecommitdiff
path: root/sys/netinet
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/netinet
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/netinet')
-rw-r--r--sys/netinet/in_proto.c37
-rw-r--r--sys/netinet/ip_input.c6
2 files changed, 37 insertions, 6 deletions
diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c
index ef1d6879b16..9f054cd8863 100644
--- a/sys/netinet/in_proto.c
+++ b/sys/netinet/in_proto.c
@@ -1,4 +1,4 @@
-/* $NetBSD: in_proto.c,v 1.124 2017/09/21 07:15:34 ozaki-r Exp $ */
+/* $NetBSD: in_proto.c,v 1.125 2017/09/27 10:05:04 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.124 2017/09/21 07:15:34 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.125 2017/09/27 10:05:04 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_mrouting.h"
@@ -72,6 +72,7 @@ __KERNEL_RCSID(0, "$NetBSD: in_proto.c,v 1.124 2017/09/21 07:15:34 ozaki-r Exp $
#include "opt_dccp.h"
#include "opt_sctp.h"
#include "opt_compat_netbsd.h"
+#include "opt_net_mpsafe.h"
#endif
#include <sys/param.h>
@@ -185,6 +186,38 @@ PR_WRAP_CTLOUTPUT(sctp_ctloutput)
#define sctp_ctloutput sctp_ctloutput_wrapper
#endif
+#ifdef NET_MPSAFE
+PR_WRAP_INPUT(udp_input)
+PR_WRAP_INPUT(tcp_input)
+#ifdef DCCP
+PR_WRAP_INPUT(dccp_input)
+#endif
+#ifdef SCTP
+PR_WRAP_INPUT(sctp_input)
+#endif
+PR_WRAP_INPUT(rip_input)
+#if NETHERIP > 0
+PR_WRAP_INPUT(ip_etherip_input)
+#endif
+#if NPFSYNC > 0
+PR_WRAP_INPUT(pfsync_input)
+#endif
+PR_WRAP_INPUT(igmp_input)
+#ifdef PIM
+PR_WRAP_INPUT(pim_input)
+#endif
+
+#define udp_input udp_input_wrapper
+#define tcp_input tcp_input_wrapper
+#define dccp_input dccp_input_wrapper
+#define sctp_input sctp_input_wrapper
+#define rip_input rip_input_wrapper
+#define ip_etherip_input ip_etherip_input_wrapper
+#define pfsync_input pfsync_input_wrapper
+#define igmp_input igmp_input_wrapper
+#define pim_input pim_input_wrapper
+#endif
+
#if defined(IPSEC)
#ifdef IPSEC_RUMPKERNEL
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 2b5e5825358..c8940bb13b9 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_input.c,v 1.360 2017/07/27 06:59:28 ozaki-r Exp $ */
+/* $NetBSD: ip_input.c,v 1.361 2017/09/27 10:05:04 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.360 2017/07/27 06:59:28 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.361 2017/09/27 10:05:04 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -826,9 +826,7 @@ ours:
const int off = hlen, nh = ip->ip_p;
- SOFTNET_LOCK();
(*inetsw[ip_protox[nh]].pr_input)(m, off, nh);
- SOFTNET_UNLOCK();
return;
out: