Source-Changes-HG archive

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

[src/trunk]: src ddb: rename show arptab to show routes



details:   https://anonhg.NetBSD.org/src/rev/d9877960d144
branches:  trunk
changeset: 814864:d9877960d144
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Apr 13 00:47:01 2016 +0000

description:
ddb: rename show arptab to show routes

show arptab command of ddb is now inappropriate because it actually dumps
routes but arp entries aren't routes anymore. So rename it to show routes
and move the code from if_arp.c to route.c.

ok christos@

diffstat:

 doc/CHANGES            |    3 +-
 share/man/man4/ddb.4   |    8 +-
 sys/ddb/db_command.c   |   11 ++--
 sys/ddb/db_interface.h |    6 +-
 sys/net/route.c        |  101 +++++++++++++++++++++++++++++++++++++++++++-
 sys/netinet/if_arp.c   |  112 +------------------------------------------------
 6 files changed, 116 insertions(+), 125 deletions(-)

diffs (truncated from 378 to 300 lines):

diff -r 326f3a24a2c0 -r d9877960d144 doc/CHANGES
--- a/doc/CHANGES       Wed Apr 13 00:09:26 2016 +0000
+++ b/doc/CHANGES       Wed Apr 13 00:47:01 2016 +0000
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:                   <$Revision: 1.2151 $>
+# LIST OF CHANGES FROM LAST RELEASE:                   <$Revision: 1.2152 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -280,3 +280,4 @@
        libutil: added pidfile_lock, pidfile_read, pidfile_read [roy 20160410]
        dhcpcd(8): Import dhcpcd-6.10.2 [roy 20160410]
        openresolv(8): Import openresolv-3.8.0 [roy20160411]
+       ddb(4): rename show arptab to show routes [ozaki-r 20160413]
diff -r 326f3a24a2c0 -r d9877960d144 share/man/man4/ddb.4
--- a/share/man/man4/ddb.4      Wed Apr 13 00:09:26 2016 +0000
+++ b/share/man/man4/ddb.4      Wed Apr 13 00:47:01 2016 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ddb.4,v 1.160 2016/04/12 23:07:25 wiz Exp $
+.\"    $NetBSD: ddb.4,v 1.161 2016/04/13 00:47:01 ozaki-r Exp $
 .\"
 .\" Copyright (c) 1997 - 2009 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -56,7 +56,7 @@
 .\" any improvements or extensions that they make and grant Carnegie Mellon
 .\" the rights to redistribute these changes.
 .\"
-.Dd April 12, 2016
+.Dd April 13, 2016
 .Dt DDB 4
 .Os
 .Sh NAME
@@ -602,11 +602,11 @@
 LWPs currently running on a CPU are marked with the '\&>' sign.
 This is the default.
 .El
-.It Ic show arptab
+.It Ic show routes
 Dump the entire
 .Dv AF_INET
 routing table.
-This command is available only on systems which support inet and ARP.
+This command is available only on systems which support inet.
 .It Ic show breaks
 Display all breakpoints.
 .It Ic show buf Ns Oo Cm /f Oc Ar address
diff -r 326f3a24a2c0 -r d9877960d144 sys/ddb/db_command.c
--- a/sys/ddb/db_command.c      Wed Apr 13 00:09:26 2016 +0000
+++ b/sys/ddb/db_command.c      Wed Apr 13 00:47:01 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_command.c,v 1.146 2016/04/06 21:56:24 skrll Exp $   */
+/*     $NetBSD: db_command.c,v 1.147 2016/04/13 00:47:02 ozaki-r Exp $ */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.146 2016/04/06 21:56:24 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.147 2016/04/13 00:47:02 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -71,7 +71,6 @@
 #include "opt_kernhist.h"
 #include "opt_ddbparam.h"
 #include "opt_multiprocessor.h"
-#include "arp.h"
 #endif
 
 #include <sys/param.h>
@@ -99,6 +98,8 @@
 #include <uvm/uvm_extern.h>
 #include <uvm/uvm_ddb.h>
 
+#include <net/route.h>
+
 /*
  * Results of command search.
  */
@@ -229,8 +230,8 @@
 #endif
        { DDB_ADD_CMD("all",    NULL,
            CS_COMPAT, NULL,NULL,NULL) },
-#if defined(INET) && (NARP > 0)
-       { DDB_ADD_CMD("arptab", db_show_arptab,         0,NULL,NULL,NULL) },
+#if defined(INET)
+       { DDB_ADD_CMD("routes", db_show_routes,         0,NULL,NULL,NULL) },
 #endif
 #ifdef _KERNEL
        { DDB_ADD_CMD("breaks", db_listbreak_cmd,       0,
diff -r 326f3a24a2c0 -r d9877960d144 sys/ddb/db_interface.h
--- a/sys/ddb/db_interface.h    Wed Apr 13 00:09:26 2016 +0000
+++ b/sys/ddb/db_interface.h    Wed Apr 13 00:47:01 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_interface.h,v 1.31 2013/01/06 03:34:52 christos Exp $       */
+/*     $NetBSD: db_interface.h,v 1.32 2016/04/13 00:47:02 ozaki-r Exp $        */
 
 /*-
  * Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -58,8 +58,8 @@
 /* kern/subr_log.c */
 void           db_dmesg(db_expr_t, bool, db_expr_t, const char *);
 
-/* netinet/if_arp.c */
-void           db_show_arptab(db_expr_t, bool, db_expr_t, const char *);
+/* net/route.c */
+void           db_show_routes(db_expr_t, bool, db_expr_t, const char *);
 
 /* kern/vfs_aio.c */
 void           db_show_aio_jobs(db_expr_t, bool, db_expr_t, const char *);
diff -r 326f3a24a2c0 -r d9877960d144 sys/net/route.c
--- a/sys/net/route.c   Wed Apr 13 00:09:26 2016 +0000
+++ b/sys/net/route.c   Wed Apr 13 00:47:01 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: route.c,v 1.161 2016/04/11 08:26:33 ozaki-r Exp $      */
+/*     $NetBSD: route.c,v 1.162 2016/04/13 00:47:01 ozaki-r Exp $      */
 
 /*-
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.161 2016/04/11 08:26:33 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.162 2016/04/13 00:47:01 ozaki-r Exp $");
 
 #include <sys/param.h>
 #ifdef RTFLUSH_DEBUG
@@ -152,6 +152,12 @@
 static void rtcache_clear(struct route *);
 static void rtcache_invalidate(struct dom_rtlist *);
 
+#ifdef DDB
+static void db_print_sa(const struct sockaddr *);
+static void db_print_ifa(struct ifaddr *);
+static int db_show_rtentry(struct rtentry *, void *);
+#endif
+
 #ifdef RTFLUSH_DEBUG
 static void sysctl_net_rtcache_setup(struct sysctllog **);
 static void
@@ -1493,3 +1499,94 @@
 {
        return rt->rt_tag;
 }
+
+#ifdef DDB
+
+#include <machine/db_machdep.h>
+#include <ddb/db_interface.h>
+#include <ddb/db_output.h>
+
+#define        rt_expire rt_rmx.rmx_expire
+
+static void
+db_print_sa(const struct sockaddr *sa)
+{
+       int len;
+       const u_char *p;
+
+       if (sa == NULL) {
+               db_printf("[NULL]");
+               return;
+       }
+
+       p = (const u_char *)sa;
+       len = sa->sa_len;
+       db_printf("[");
+       while (len > 0) {
+               db_printf("%d", *p);
+               p++; len--;
+               if (len) db_printf(",");
+       }
+       db_printf("]\n");
+}
+
+static void
+db_print_ifa(struct ifaddr *ifa)
+{
+       if (ifa == NULL)
+               return;
+       db_printf("  ifa_addr=");
+       db_print_sa(ifa->ifa_addr);
+       db_printf("  ifa_dsta=");
+       db_print_sa(ifa->ifa_dstaddr);
+       db_printf("  ifa_mask=");
+       db_print_sa(ifa->ifa_netmask);
+       db_printf("  flags=0x%x,refcnt=%d,metric=%d\n",
+                         ifa->ifa_flags,
+                         ifa->ifa_refcnt,
+                         ifa->ifa_metric);
+}
+
+/*
+ * Function to pass to rt_walktree().
+ * Return non-zero error to abort walk.
+ */
+static int
+db_show_rtentry(struct rtentry *rt, void *w)
+{
+       db_printf("rtentry=%p", rt);
+
+       db_printf(" flags=0x%x refcnt=%d use=%"PRId64" expire=%"PRId64"\n",
+                         rt->rt_flags, rt->rt_refcnt,
+                         rt->rt_use, (uint64_t)rt->rt_expire);
+
+       db_printf(" key="); db_print_sa(rt_getkey(rt));
+       db_printf(" mask="); db_print_sa(rt_mask(rt));
+       db_printf(" gw="); db_print_sa(rt->rt_gateway);
+
+       db_printf(" ifp=%p ", rt->rt_ifp);
+       if (rt->rt_ifp)
+               db_printf("(%s)", rt->rt_ifp->if_xname);
+       else
+               db_printf("(NULL)");
+
+       db_printf(" ifa=%p\n", rt->rt_ifa);
+       db_print_ifa(rt->rt_ifa);
+
+       db_printf(" gwroute=%p llinfo=%p\n",
+                         rt->rt_gwroute, rt->rt_llinfo);
+
+       return 0;
+}
+
+/*
+ * Function to print all the route trees.
+ * Use this from ddb:  "show routes"
+ */
+void
+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);
+}
+#endif
diff -r 326f3a24a2c0 -r d9877960d144 sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Wed Apr 13 00:09:26 2016 +0000
+++ b/sys/netinet/if_arp.c      Wed Apr 13 00:47:01 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.205 2016/04/07 03:22:15 christos Exp $    */
+/*     $NetBSD: if_arp.c,v 1.206 2016/04/13 00:47:01 ozaki-r 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.205 2016/04/07 03:22:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.206 2016/04/13 00:47:01 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -205,13 +205,6 @@
 static int     revarp_in_progress = 0;
 static struct  ifnet *myip_ifp = NULL;
 
-#ifdef DDB
-static void db_print_sa(const struct sockaddr *);
-static void db_print_ifa(struct ifaddr *);
-static void db_print_llinfo(struct llentry *);
-static int db_show_rtentry(struct rtentry *, void *);
-#endif
-
 static int arp_drainwanted;
 
 static int log_movements = 1;
@@ -1920,107 +1913,6 @@
        return 0;
 }
 
-
-
-#ifdef DDB
-
-#include <machine/db_machdep.h>
-#include <ddb/db_interface.h>
-#include <ddb/db_output.h>
-
-static void
-db_print_sa(const struct sockaddr *sa)
-{
-       int len;
-       const u_char *p;
-
-       if (sa == NULL) {
-               db_printf("[NULL]");
-               return;
-       }
-
-       p = (const u_char *)sa;
-       len = sa->sa_len;
-       db_printf("[");
-       while (len > 0) {
-               db_printf("%d", *p);
-               p++; len--;
-               if (len) db_printf(",");



Home | Main Index | Thread Index | Old Index