Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys Pull up following revision(s) (requested by ozaki-r i...
details: https://anonhg.NetBSD.org/src/rev/84f7b577b2a1
branches: netbsd-9
changeset: 1000929:84f7b577b2a1
user: martin <martin%NetBSD.org@localhost>
date: Mon Sep 30 15:55:40 2019 +0000
description:
Pull up following revision(s) (requested by ozaki-r in ticket #269):
sys/netinet6/nd6.h: revision 1.88
sys/net/rtsock_shared.c: revision 1.10
sys/netinet6/nd6_nbr.c: revision 1.174
sys/netinet6/nd6.c: revision 1.264
sys/netinet/if_arp.c: revision 1.283
sys/netinet/if_arp.c: revision 1.288
Initialize DAD components properly
The original code initialized each component in non-init functions such as
arp_dad_start and nd6_dad_find, conditionally based on a global flag for each.
However, it was racy because the flag and the code around it were not
protected by a lock and could cause a kernel panic at worst.
Fix the issue by initializing the components in bootup as usual.
-
Initialize dom_mowner for MBUFTRACE
diffstat:
sys/net/rtsock_shared.c | 11 +++++++++--
sys/netinet/if_arp.c | 32 ++++++++++++++++++++------------
sys/netinet6/nd6.c | 6 ++++--
sys/netinet6/nd6.h | 3 ++-
sys/netinet6/nd6_nbr.c | 22 ++++++++++------------
5 files changed, 45 insertions(+), 29 deletions(-)
diffs (231 lines):
diff -r f987a758e37f -r 84f7b577b2a1 sys/net/rtsock_shared.c
--- a/sys/net/rtsock_shared.c Mon Sep 30 15:42:03 2019 +0000
+++ b/sys/net/rtsock_shared.c Mon Sep 30 15:55:40 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock_shared.c,v 1.9 2019/05/03 02:10:58 pgoyette Exp $ */
+/* $NetBSD: rtsock_shared.c,v 1.9.4.1 2019/09/30 15:55:40 martin Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.9 2019/05/03 02:10:58 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock_shared.c,v 1.9.4.1 2019/09/30 15:55:40 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1646,6 +1646,10 @@
ri->ri_sih = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE,
COMPATNAME(route_intr), NULL);
IFQ_LOCK_INIT(&ri->ri_intrq);
+
+#ifdef MBUFTRACE
+ MOWNER_ATTACH(&COMPATNAME(routedomain).dom_mowner);
+#endif
}
/*
@@ -1698,4 +1702,7 @@
.dom_protosw = COMPATNAME(route_protosw),
.dom_protoswNPROTOSW =
&COMPATNAME(route_protosw)[__arraycount(COMPATNAME(route_protosw))],
+#ifdef MBUFTRACE
+ .dom_mowner = MOWNER_INIT("route", "rtm"),
+#endif
};
diff -r f987a758e37f -r 84f7b577b2a1 sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c Mon Sep 30 15:42:03 2019 +0000
+++ b/sys/netinet/if_arp.c Mon Sep 30 15:55:40 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_arp.c,v 1.282.2.3 2019/09/05 08:34:11 martin Exp $ */
+/* $NetBSD: if_arp.c,v 1.282.2.4 2019/09/30 15:55:40 martin Exp $ */
/*
* Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.282.2.3 2019/09/05 08:34:11 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.282.2.4 2019/09/30 15:55:40 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -153,6 +153,7 @@
#endif
static void arp_init(void);
+static void arp_dad_init(void);
static void arprequest(struct ifnet *,
const struct in_addr *, const struct in_addr *,
@@ -246,6 +247,9 @@
.dom_name = "arp",
.dom_protosw = arpsw,
.dom_protoswNPROTOSW = &arpsw[__arraycount(arpsw)],
+#ifdef MBUFTRACE
+ .dom_mowner = MOWNER_INIT("internet", "arp"),
+#endif
};
static void sysctl_net_inet_arp_setup(struct sysctllog **);
@@ -257,6 +261,12 @@
sysctl_net_inet_arp_setup(NULL);
arpstat_percpu = percpu_alloc(sizeof(uint64_t) * ARP_NSTATS);
IFQ_LOCK_INIT(&arpintrq);
+
+#ifdef MBUFTRACE
+ MOWNER_ATTACH(&arpdomain.dom_mowner);
+#endif
+
+ arp_dad_init();
}
static void
@@ -1503,10 +1513,17 @@
};
static struct dadq_head dadq;
-static int dad_init = 0;
static int dad_maxtry = 15; /* max # of *tries* to transmit DAD packet */
static kmutex_t arp_dad_lock;
+static void
+arp_dad_init(void)
+{
+
+ TAILQ_INIT(&dadq);
+ mutex_init(&arp_dad_lock, MUTEX_DEFAULT, IPL_NONE);
+}
+
static struct dadq *
arp_dad_find(struct ifaddr *ifa)
{
@@ -1581,12 +1598,6 @@
struct dadq *dp;
char ipbuf[INET_ADDRSTRLEN];
- if (!dad_init) {
- TAILQ_INIT(&dadq);
- mutex_init(&arp_dad_lock, MUTEX_DEFAULT, IPL_NONE);
- dad_init++;
- }
-
/*
* If we don't need DAD, don't do it.
* - DAD is disabled
@@ -1655,9 +1666,6 @@
{
struct dadq *dp;
- if (!dad_init)
- return;
-
mutex_enter(&arp_dad_lock);
dp = arp_dad_find(ifa);
if (dp == NULL) {
diff -r f987a758e37f -r 84f7b577b2a1 sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c Mon Sep 30 15:42:03 2019 +0000
+++ b/sys/netinet6/nd6.c Mon Sep 30 15:55:40 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6.c,v 1.256.2.6 2019/09/05 08:32:34 martin Exp $ */
+/* $NetBSD: nd6.c,v 1.256.2.7 2019/09/30 15:55:40 martin Exp $ */
/* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.256.2.6 2019/09/05 08:32:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.256.2.7 2019/09/30 15:55:40 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@@ -137,6 +137,8 @@
{
int error;
+ nd6_nbr_init();
+
rw_init(&nd6_lock);
/* initialization of the default router list */
diff -r f987a758e37f -r 84f7b577b2a1 sys/netinet6/nd6.h
--- a/sys/netinet6/nd6.h Mon Sep 30 15:42:03 2019 +0000
+++ b/sys/netinet6/nd6.h Mon Sep 30 15:55:40 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6.h,v 1.86.6.1 2019/09/05 08:32:34 martin Exp $ */
+/* $NetBSD: nd6.h,v 1.86.6.2 2019/09/30 15:55:40 martin Exp $ */
/* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */
/*
@@ -430,6 +430,7 @@
/* XXX: need nd6_var.h?? */
/* nd6.c */
void nd6_init(void);
+void nd6_nbr_init(void);
struct nd_ifinfo *nd6_ifattach(struct ifnet *);
void nd6_ifdetach(struct ifnet *, struct in6_ifextra *);
int nd6_is_addr_neighbor(const struct sockaddr_in6 *, struct ifnet *);
diff -r f987a758e37f -r 84f7b577b2a1 sys/netinet6/nd6_nbr.c
--- a/sys/netinet6/nd6_nbr.c Mon Sep 30 15:42:03 2019 +0000
+++ b/sys/netinet6/nd6_nbr.c Mon Sep 30 15:55:40 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nd6_nbr.c,v 1.166.2.3 2019/09/22 10:24:09 martin Exp $ */
+/* $NetBSD: nd6_nbr.c,v 1.166.2.4 2019/09/30 15:55:40 martin Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.166.2.3 2019/09/22 10:24:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_nbr.c,v 1.166.2.4 2019/09/30 15:55:40 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1124,9 +1124,16 @@
};
static struct dadq_head dadq;
-static int dad_init = 0;
static kmutex_t nd6_dad_lock;
+void
+nd6_nbr_init(void)
+{
+
+ TAILQ_INIT(&dadq);
+ mutex_init(&nd6_dad_lock, MUTEX_DEFAULT, IPL_NONE);
+}
+
static struct dadq *
nd6_dad_find(struct ifaddr *ifa, struct nd_opt_nonce *nonce, bool *found_nonce)
{
@@ -1238,12 +1245,6 @@
struct dadq *dp;
char ip6buf[INET6_ADDRSTRLEN];
- if (!dad_init) {
- TAILQ_INIT(&dadq);
- mutex_init(&nd6_dad_lock, MUTEX_DEFAULT, IPL_NONE);
- dad_init++;
- }
-
/*
* If we don't need DAD, don't do it.
* There are several cases:
@@ -1321,9 +1322,6 @@
{
struct dadq *dp;
- if (!dad_init)
- return;
-
mutex_enter(&nd6_dad_lock);
dp = nd6_dad_find(ifa, NULL, NULL);
if (dp == NULL) {
Home |
Main Index |
Thread Index |
Old Index