Module Name: src
Committed By: martin
Date: Fri Jul 13 14:26:48 UTC 2018
Modified Files:
src/sys/net [netbsd-8]: if.h
src/sys/netinet [netbsd-8]: igmp.c in_l2tp.c ip_encap.c ip_icmp.c
ip_mroute.c
src/sys/netinet6 [netbsd-8]: in6_l2tp.c ip6_mroute.c
Log Message:
Pull up following revision(s) via patch (requested by knakahara in ticket #905):
sys/netinet/ip_mroute.c: revision 1.160
sys/netinet6/in6_l2tp.c: revision 1.16
sys/net/if.h: revision 1.263
sys/netinet/in_l2tp.c: revision 1.15
sys/netinet/ip_icmp.c: revision 1.172
sys/netinet/igmp.c: revision 1.68
sys/netinet/ip_encap.c: revision 1.69
sys/netinet6/ip6_mroute.c: revision 1.129
sbappendaddr() is required any lock. Currently, softnet_lock is appropriate.
When rip_input() is called as inetsw[].pr_input, rip_iput() is always called
with holding softnet_lock, that is, in case of !defined(NET_MPSAFE) it is
acquired in ipintr(), otherwise(defined(NET_MPSAFE)) it is acquire in
PR_WRAP_INPUT macro.
However, some function calls rip_input() directly without holding softnet_lock.
That causes assertion failure in sbappendaddr().
rip6_input() and icmp6_rip6_input() are also required softnet_lock for the same
reason.
To generate a diff of this commit:
cvs rdiff -u -r1.239.2.5 -r1.239.2.6 src/sys/net/if.h
cvs rdiff -u -r1.64.6.1 -r1.64.6.2 src/sys/netinet/igmp.c
cvs rdiff -u -r1.2.8.5 -r1.2.8.6 src/sys/netinet/in_l2tp.c
cvs rdiff -u -r1.65.2.2 -r1.65.2.3 src/sys/netinet/ip_encap.c
cvs rdiff -u -r1.161.6.2 -r1.161.6.3 src/sys/netinet/ip_icmp.c
cvs rdiff -u -r1.146.6.3 -r1.146.6.4 src/sys/netinet/ip_mroute.c
cvs rdiff -u -r1.5.8.5 -r1.5.8.6 src/sys/netinet6/in6_l2tp.c
cvs rdiff -u -r1.119.6.2 -r1.119.6.3 src/sys/netinet6/ip6_mroute.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.239.2.5 src/sys/net/if.h:1.239.2.6
--- src/sys/net/if.h:1.239.2.5 Sat Apr 14 10:16:19 2018
+++ src/sys/net/if.h Fri Jul 13 14:26:48 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.239.2.5 2018/04/14 10:16:19 martin Exp $ */
+/* $NetBSD: if.h,v 1.239.2.6 2018/07/13 14:26:48 martin Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -534,6 +534,11 @@ if_is_link_state_changeable(struct ifnet
#define SOFTNET_LOCK_UNLESS_NET_MPSAFE() do { } while (0)
#define SOFTNET_UNLOCK_UNLESS_NET_MPSAFE() do { } while (0)
+#define SOFTNET_LOCK_IF_NET_MPSAFE() \
+ do { mutex_enter(softnet_lock); } while (0)
+#define SOFTNET_UNLOCK_IF_NET_MPSAFE() \
+ do { mutex_exit(softnet_lock); } while (0)
+
#else /* NET_MPSAFE */
#define KERNEL_LOCK_UNLESS_NET_MPSAFE() \
@@ -546,6 +551,9 @@ if_is_link_state_changeable(struct ifnet
#define SOFTNET_UNLOCK_UNLESS_NET_MPSAFE() \
do { mutex_exit(softnet_lock); } while (0)
+#define SOFTNET_LOCK_IF_NET_MPSAFE() do { } while (0)
+#define SOFTNET_UNLOCK_IF_NET_MPSAFE() do { } while (0)
+
#endif /* NET_MPSAFE */
#define SOFTNET_KERNEL_LOCK_UNLESS_NET_MPSAFE() \
Index: src/sys/netinet/igmp.c
diff -u src/sys/netinet/igmp.c:1.64.6.1 src/sys/netinet/igmp.c:1.64.6.2
--- src/sys/netinet/igmp.c:1.64.6.1 Tue Jan 2 10:20:34 2018
+++ src/sys/netinet/igmp.c Fri Jul 13 14:26:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: igmp.c,v 1.64.6.1 2018/01/02 10:20:34 snj Exp $ */
+/* $NetBSD: igmp.c,v 1.64.6.2 2018/07/13 14:26:47 martin Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -40,7 +40,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.64.6.1 2018/01/02 10:20:34 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.64.6.2 2018/07/13 14:26:47 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_mrouting.h"
@@ -474,6 +474,11 @@ igmp_input(struct mbuf *m, ...)
* Pass all valid IGMP packets up to any process(es) listening
* on a raw IGMP socket.
*/
+ /*
+ * Currently, igmp_input() is always called holding softnet_lock
+ * by ipintr()(!NET_MPSAFE) or PR_INPUT_WRAP()(NET_MPSAFE).
+ */
+ KASSERT(mutex_owned(softnet_lock));
rip_input(m, iphlen, proto);
return;
Index: src/sys/netinet/in_l2tp.c
diff -u src/sys/netinet/in_l2tp.c:1.2.8.5 src/sys/netinet/in_l2tp.c:1.2.8.6
--- src/sys/netinet/in_l2tp.c:1.2.8.5 Thu May 17 14:07:03 2018
+++ src/sys/netinet/in_l2tp.c Fri Jul 13 14:26:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: in_l2tp.c,v 1.2.8.5 2018/05/17 14:07:03 martin Exp $ */
+/* $NetBSD: in_l2tp.c,v 1.2.8.6 2018/07/13 14:26:47 martin Exp $ */
/*
* Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.2.8.5 2018/05/17 14:07:03 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.2.8.6 2018/07/13 14:26:47 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_l2tp.h"
@@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v
#include <sys/ioctl.h>
#include <sys/syslog.h>
#include <sys/kernel.h>
+#include <sys/socketvar.h> /* For softnet_lock */
#include <net/if.h>
#include <net/route.h>
@@ -277,7 +278,9 @@ in_l2tp_input(struct mbuf *m, int off, i
* L2TPv3 control packet received.
* userland daemon(l2tpd?) should process.
*/
+ SOFTNET_LOCK_IF_NET_MPSAFE();
rip_input(m, off, proto);
+ SOFTNET_UNLOCK_IF_NET_MPSAFE();
return;
}
Index: src/sys/netinet/ip_encap.c
diff -u src/sys/netinet/ip_encap.c:1.65.2.2 src/sys/netinet/ip_encap.c:1.65.2.3
--- src/sys/netinet/ip_encap.c:1.65.2.2 Fri Mar 30 11:12:15 2018
+++ src/sys/netinet/ip_encap.c Fri Jul 13 14:26:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_encap.c,v 1.65.2.2 2018/03/30 11:12:15 martin Exp $ */
+/* $NetBSD: ip_encap.c,v 1.65.2.3 2018/07/13 14:26:47 martin Exp $ */
/* $KAME: ip_encap.c,v 1.73 2001/10/02 08:30:58 itojun Exp $ */
/*
@@ -68,7 +68,7 @@
#define USE_RADIX
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.65.2.2 2018/03/30 11:12:15 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.65.2.3 2018/07/13 14:26:47 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_mrouting.h"
@@ -374,7 +374,9 @@ encap4_input(struct mbuf *m, ...)
}
/* last resort: inject to raw socket */
+ SOFTNET_LOCK_IF_NET_MPSAFE();
rip_input(m, off, proto);
+ SOFTNET_UNLOCK_IF_NET_MPSAFE();
}
#endif
@@ -496,6 +498,7 @@ encap6_input(struct mbuf **mp, int *offp
const struct encapsw *esw;
struct encaptab *match;
struct psref match_psref;
+ int rv;
match = encap6_lookup(m, *offp, proto, INBOUND, &match_psref);
@@ -518,7 +521,10 @@ encap6_input(struct mbuf **mp, int *offp
}
/* last resort: inject to raw socket */
- return rip6_input(mp, offp, proto);
+ SOFTNET_LOCK_IF_NET_MPSAFE();
+ rv = rip6_input(mp, offp, proto);
+ SOFTNET_UNLOCK_IF_NET_MPSAFE();
+ return rv;
}
#endif
Index: src/sys/netinet/ip_icmp.c
diff -u src/sys/netinet/ip_icmp.c:1.161.6.2 src/sys/netinet/ip_icmp.c:1.161.6.3
--- src/sys/netinet/ip_icmp.c:1.161.6.2 Fri Jun 8 10:14:33 2018
+++ src/sys/netinet/ip_icmp.c Fri Jul 13 14:26:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_icmp.c,v 1.161.6.2 2018/06/08 10:14:33 martin Exp $ */
+/* $NetBSD: ip_icmp.c,v 1.161.6.3 2018/07/13 14:26:47 martin Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -94,7 +94,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.161.6.2 2018/06/08 10:14:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.161.6.3 2018/07/13 14:26:47 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@@ -709,6 +709,11 @@ reflect:
}
raw:
+ /*
+ * Currently, pim_input() is always called holding softnet_lock
+ * by ipintr()(!NET_MPSAFE) or PR_INPUT_WRAP()(NET_MPSAFE).
+ */
+ KASSERT(mutex_owned(softnet_lock));
rip_input(m, hlen, proto);
return;
Index: src/sys/netinet/ip_mroute.c
diff -u src/sys/netinet/ip_mroute.c:1.146.6.3 src/sys/netinet/ip_mroute.c:1.146.6.4
--- src/sys/netinet/ip_mroute.c:1.146.6.3 Mon Apr 9 13:34:10 2018
+++ src/sys/netinet/ip_mroute.c Fri Jul 13 14:26:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_mroute.c,v 1.146.6.3 2018/04/09 13:34:10 bouyer Exp $ */
+/* $NetBSD: ip_mroute.c,v 1.146.6.4 2018/07/13 14:26:47 martin Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -93,7 +93,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.146.6.3 2018/04/09 13:34:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.146.6.4 2018/07/13 14:26:47 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -2363,6 +2363,7 @@ rsvp_input(struct mbuf *m, struct ifnet
if (ip_rsvpd != NULL) {
RSVP_DPRINTF(("%s: Sending packet up old-style socket\n",
__func__));
+ /* rsvp_input() is not called, not care */
rip_input(m); /*XXX*/
return;
}
@@ -3463,6 +3464,11 @@ pim_input_to_daemon:
* XXX: the outer IP header pkt size of a Register is not adjust to
* reflect the fact that the inner multicast data is truncated.
*/
+ /*
+ * Currently, pim_input() is always called holding softnet_lock
+ * by ipintr()(!NET_MPSAFE) or PR_INPUT_WRAP()(NET_MPSAFE).
+ */
+ KASSERT(mutex_owned(softnet_lock));
rip_input(m, iphlen, proto);
return;
Index: src/sys/netinet6/in6_l2tp.c
diff -u src/sys/netinet6/in6_l2tp.c:1.5.8.5 src/sys/netinet6/in6_l2tp.c:1.5.8.6
--- src/sys/netinet6/in6_l2tp.c:1.5.8.5 Thu May 17 14:07:03 2018
+++ src/sys/netinet6/in6_l2tp.c Fri Jul 13 14:26:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_l2tp.c,v 1.5.8.5 2018/05/17 14:07:03 martin Exp $ */
+/* $NetBSD: in6_l2tp.c,v 1.5.8.6 2018/07/13 14:26:47 martin Exp $ */
/*
* Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.5.8.5 2018/05/17 14:07:03 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.5.8.6 2018/07/13 14:26:47 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_l2tp.h"
@@ -267,11 +267,15 @@ in6_l2tp_input(struct mbuf **mp, int *of
log(LOG_DEBUG, "%s: sess_id = %" PRIu32 "\n", __func__, sess_id);
#endif
if (sess_id == 0) {
+ int rv;
/*
* L2TPv3 control packet received.
* userland daemon(l2tpd?) should process.
*/
- return rip6_input(mp, offp, proto);
+ SOFTNET_LOCK_IF_NET_MPSAFE();
+ rv = rip6_input(mp, offp, proto);
+ SOFTNET_UNLOCK_IF_NET_MPSAFE();
+ return rv;
}
var = l2tp_lookup_session_ref(sess_id, &psref);
Index: src/sys/netinet6/ip6_mroute.c
diff -u src/sys/netinet6/ip6_mroute.c:1.119.6.2 src/sys/netinet6/ip6_mroute.c:1.119.6.3
--- src/sys/netinet6/ip6_mroute.c:1.119.6.2 Mon Apr 9 13:34:10 2018
+++ src/sys/netinet6/ip6_mroute.c Fri Jul 13 14:26:47 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_mroute.c,v 1.119.6.2 2018/04/09 13:34:10 bouyer Exp $ */
+/* $NetBSD: ip6_mroute.c,v 1.119.6.3 2018/07/13 14:26:47 martin Exp $ */
/* $KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $ */
/*
@@ -117,7 +117,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.119.6.2 2018/04/09 13:34:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.119.6.3 2018/07/13 14:26:47 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1951,6 +1951,11 @@ pim6_input(struct mbuf **mp, int *offp,
* encapsulated ip6 header.
*/
pim6_input_to_daemon:
+ /*
+ * Currently, rip6_input() is always called holding softnet_lock
+ * by ipintr()(!NET_MPSAFE) or PR_INPUT_WRAP()(NET_MPSAFE).
+ */
+ KASSERT(mutex_owned(softnet_lock));
rip6_input(&m, offp, proto);
return (IPPROTO_DONE);
}