Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Don't take RT_LOCK in DDB



details:   https://anonhg.NetBSD.org/src/rev/d4c29ae68bbc
branches:  trunk
changeset: 321568:d4c29ae68bbc
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Fri Mar 23 04:09:41 2018 +0000

description:
Don't take RT_LOCK in DDB

It definitely causes a diagnostic failure if LOCKDEBUG is enabled.

diffstat:

 sys/net/route.c |  18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diffs (51 lines):

diff -r faaf82a60b21 -r d4c29ae68bbc sys/net/route.c
--- a/sys/net/route.c   Thu Mar 22 21:30:34 2018 +0000
+++ b/sys/net/route.c   Fri Mar 23 04:09:41 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.c,v 1.206 2018/01/30 11:01:04 ozaki-r Exp $      */
+/*     $NetBSD: route.c,v 1.207 2018/03/23 04:09:41 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.206 2018/01/30 11:01:04 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.207 2018/03/23 04:09:41 ozaki-r Exp $");
 
 #include <sys/param.h>
 #ifdef RTFLUSH_DEBUG
@@ -2147,13 +2147,21 @@
        }
 }
 
+static int
+rt_walktree_locked(sa_family_t family, int (*f)(struct rtentry *, void *),
+    void *v)
+{
+
+       return rtbl_walktree(family, f, v);
+}
+
 int
 rt_walktree(sa_family_t family, int (*f)(struct rtentry *, void *), void *v)
 {
        int error;
 
        RT_RLOCK();
-       error = rtbl_walktree(family, f, v);
+       error = rt_walktree_locked(family, f, v);
        RT_UNLOCK();
 
        return error;
@@ -2246,6 +2254,8 @@
 db_show_routes(db_expr_t addr, bool have_addr,
     db_expr_t count, const char *modif)
 {
-       rt_walktree(AF_INET, db_show_rtentry, NULL);
+
+       /* Taking RT_LOCK will fail if LOCKDEBUG is enabled. */
+       rt_walktree_locked(AF_INET, db_show_rtentry, NULL);
 }
 #endif



Home | Main Index | Thread Index | Old Index