summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorozaki-r <ozaki-r@NetBSD.org>2017-01-19 06:58:55 +0000
committerozaki-r <ozaki-r@NetBSD.org>2017-01-19 06:58:55 +0000
commitf9da3398e9a9cdeea2bb1f29ca30c9c2c9e1e15e (patch)
tree40dc701674d195849c9584ddf0ff44ed37c2a785
parentb1bb0d4377d3f86dea232555f5acd1cdab99647a (diff)
Disable rt_update mechanism by default
This is a workaround for PR kern/51877. Enable again once the issue is fixed.
-rw-r--r--sys/net/route.c18
-rw-r--r--sys/net/rtsock.c9
2 files changed, 23 insertions, 4 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index 88b7177078e..1cf17b8b5cf 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $NetBSD: route.c,v 1.187 2017/01/17 07:53:06 ozaki-r Exp $ */
+/* $NetBSD: route.c,v 1.188 2017/01/19 06:58:55 ozaki-r Exp $ */
/*-
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.187 2017/01/17 07:53:06 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.188 2017/01/19 06:58:55 ozaki-r Exp $");
#include <sys/param.h>
#ifdef RTFLUSH_DEBUG
@@ -288,7 +288,9 @@ static int rtcache_setdst_locked(struct route *, const struct sockaddr *);
static void rtcache_ref(struct rtentry *, struct route *);
+#ifdef NET_MPSAFE
static void rt_update_wait(void);
+#endif
static bool rt_wait_ok(void);
static void rt_wait_refcnt(const char *, struct rtentry *, int);
@@ -561,7 +563,9 @@ rtalloc1_locked(const struct sockaddr *dst, int report, bool wait_ok)
struct rtentry *rt;
int s;
+#ifdef NET_MPSAFE
retry:
+#endif
s = splsoftnet();
rtbl = rt_gettable(dst->sa_family);
if (rtbl == NULL)
@@ -574,6 +578,7 @@ retry:
if (!ISSET(rt->rt_flags, RTF_UP))
goto miss;
+#ifdef NET_MPSAFE
if (ISSET(rt->rt_flags, RTF_UPDATING) &&
/* XXX updater should be always able to acquire */
curlwp != rt_update_global.lwp) {
@@ -596,6 +601,7 @@ retry:
RTCACHE_WLOCK();
goto retry;
}
+#endif /* NET_MPSAFE */
rt_ref(rt);
RT_REFCNT_TRACE(rt);
@@ -689,7 +695,9 @@ _rt_free(struct rtentry *rt)
* Need to avoid a deadlock on rt_wait_refcnt of update
* and a conflict on psref_target_destroy of update.
*/
+#ifdef NET_MPSAFE
rt_update_wait();
+#endif
RT_REFCNT_TRACE(rt);
KASSERTMSG(rt->rt_refcnt >= 0, "refcnt=%d", rt->rt_refcnt);
@@ -755,6 +763,7 @@ rt_free(struct rtentry *rt)
}
}
+#ifdef NET_MPSAFE
static void
rt_update_wait(void)
{
@@ -767,6 +776,7 @@ rt_update_wait(void)
}
mutex_exit(&rt_update_global.lock);
}
+#endif
int
rt_update_prepare(struct rtentry *rt)
@@ -1964,7 +1974,9 @@ rtcache_validate_locked(struct route *ro)
{
struct rtentry *rt = NULL;
+#ifdef NET_MPSAFE
retry:
+#endif
rt = ro->_ro_rt;
rtcache_invariants(ro);
@@ -1975,6 +1987,7 @@ retry:
RT_RLOCK();
if (rt != NULL && (rt->rt_flags & RTF_UP) != 0 && rt->rt_ifp != NULL) {
+#ifdef NET_MPSAFE
if (ISSET(rt->rt_flags, RTF_UPDATING)) {
if (rt_wait_ok()) {
RT_UNLOCK();
@@ -1987,6 +2000,7 @@ retry:
rt = NULL;
}
} else
+#endif
rtcache_ref(rt, ro);
} else
rt = NULL;
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index f867c714149..b3d9df98aa5 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock.c,v 1.199 2016/12/12 03:55:57 ozaki-r Exp $ */
+/* $NetBSD: rtsock.c,v 1.200 2017/01/19 06:58:55 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,13 +61,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.199 2016/12/12 03:55:57 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.200 2017/01/19 06:58:55 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
#include "opt_mpls.h"
#include "opt_compat_netbsd.h"
#include "opt_sctp.h"
+#include "opt_net_mpsafe.h"
#endif
#include <sys/param.h>
@@ -887,11 +888,15 @@ COMPATNAME(route_output)(struct mbuf *m, struct socket *so)
break;
case RTM_CHANGE:
+#ifdef NET_MPSAFE
error = rt_update_prepare(rt);
if (error == 0) {
error = route_output_change(rt, &info, rtm);
rt_update_finish(rt);
}
+#else
+ error = route_output_change(rt, &info, rtm);
+#endif
if (error != 0)
goto flush;
/*FALLTHROUGH*/