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.
This commit is contained in:
parent
93d0a5567f
commit
a1b205bf0e
10
sys/net/if.h
10
sys/net/if.h
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: if.h,v 1.262 2018/06/12 07:12:35 ozaki-r Exp $ */
|
||||
/* $NetBSD: if.h,v 1.263 2018/06/21 10:37:49 knakahara Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
|
||||
@ -535,6 +535,11 @@ if_is_link_state_changeable(struct ifnet *ifp)
|
||||
#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() \
|
||||
@ -547,6 +552,9 @@ if_is_link_state_changeable(struct ifnet *ifp)
|
||||
#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() \
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: igmp.c,v 1.67 2018/04/10 08:22:35 maxv Exp $ */
|
||||
/* $NetBSD: igmp.c,v 1.68 2018/06/21 10:37:50 knakahara 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.67 2018/04/10 08:22:35 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.68 2018/06/21 10:37:50 knakahara 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;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in_l2tp.c,v 1.14 2018/05/01 07:21:39 maxv Exp $ */
|
||||
/* $NetBSD: in_l2tp.c,v 1.15 2018/06/21 10:37:50 knakahara 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.14 2018/05/01 07:21:39 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.15 2018/06/21 10:37:50 knakahara Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_l2tp.h"
|
||||
@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.14 2018/05/01 07:21:39 maxv Exp $");
|
||||
#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>
|
||||
@ -275,7 +276,9 @@ in_l2tp_input(struct mbuf *m, int off, int proto, void *eparg __unused)
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip_encap.c,v 1.68 2018/05/01 07:21:39 maxv Exp $ */
|
||||
/* $NetBSD: ip_encap.c,v 1.69 2018/06/21 10:37:50 knakahara 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.68 2018/05/01 07:21:39 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.69 2018/06/21 10:37:50 knakahara Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_mrouting.h"
|
||||
@ -372,7 +372,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
|
||||
|
||||
@ -494,6 +496,7 @@ encap6_input(struct mbuf **mp, int *offp, int proto)
|
||||
const struct encapsw *esw;
|
||||
struct encaptab *match;
|
||||
struct psref match_psref;
|
||||
int rv;
|
||||
|
||||
match = encap6_lookup(m, *offp, proto, INBOUND, &match_psref);
|
||||
|
||||
@ -516,7 +519,10 @@ encap6_input(struct mbuf **mp, int *offp, int proto)
|
||||
}
|
||||
|
||||
/* 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
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip_icmp.c,v 1.171 2018/06/01 07:13:35 ozaki-r Exp $ */
|
||||
/* $NetBSD: ip_icmp.c,v 1.172 2018/06/21 10:37:50 knakahara Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
|
||||
@ -94,7 +94,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.171 2018/06/01 07:13:35 ozaki-r Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.172 2018/06/21 10:37:50 knakahara Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_ipsec.h"
|
||||
@ -679,6 +679,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;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip_mroute.c,v 1.159 2018/05/14 17:26:16 maxv Exp $ */
|
||||
/* $NetBSD: ip_mroute.c,v 1.160 2018/06/21 10:37:50 knakahara Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -93,7 +93,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.159 2018/05/14 17:26:16 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.160 2018/06/21 10:37:50 knakahara Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
@ -3165,6 +3165,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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in6_l2tp.c,v 1.15 2018/04/27 09:55:28 knakahara Exp $ */
|
||||
/* $NetBSD: in6_l2tp.c,v 1.16 2018/06/21 10:37:50 knakahara 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.15 2018/04/27 09:55:28 knakahara Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.16 2018/06/21 10:37:50 knakahara Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_l2tp.h"
|
||||
@ -267,11 +267,15 @@ in6_l2tp_input(struct mbuf **mp, int *offp, int proto, void *eparg __unused)
|
||||
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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ip6_mroute.c,v 1.128 2018/05/20 06:29:43 maxv Exp $ */
|
||||
/* $NetBSD: ip6_mroute.c,v 1.129 2018/06/21 10:37:50 knakahara 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.128 2018/05/20 06:29:43 maxv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.129 2018/06/21 10:37:50 knakahara Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
@ -1931,6 +1931,11 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
|
||||
* 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user