Module Name: src Committed By: ozaki-r Date: Wed Apr 13 00:47:02 UTC 2016
Modified Files: src/doc: CHANGES src/share/man/man4: ddb.4 src/sys/ddb: db_command.c db_interface.h src/sys/net: route.c src/sys/netinet: if_arp.c Log Message: 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@ To generate a diff of this commit: cvs rdiff -u -r1.2151 -r1.2152 src/doc/CHANGES cvs rdiff -u -r1.160 -r1.161 src/share/man/man4/ddb.4 cvs rdiff -u -r1.146 -r1.147 src/sys/ddb/db_command.c cvs rdiff -u -r1.31 -r1.32 src/sys/ddb/db_interface.h cvs rdiff -u -r1.161 -r1.162 src/sys/net/route.c cvs rdiff -u -r1.205 -r1.206 src/sys/netinet/if_arp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2151 src/doc/CHANGES:1.2152 --- src/doc/CHANGES:1.2151 Mon Apr 11 10:44:30 2016 +++ src/doc/CHANGES Wed Apr 13 00:47:01 2016 @@ -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 @@ Changes from NetBSD 7.0 to NetBSD 8.0: 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] Index: src/share/man/man4/ddb.4 diff -u src/share/man/man4/ddb.4:1.160 src/share/man/man4/ddb.4:1.161 --- src/share/man/man4/ddb.4:1.160 Tue Apr 12 23:07:25 2016 +++ src/share/man/man4/ddb.4 Wed Apr 13 00:47:01 2016 @@ -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 @@ LWP name and wait channel message. 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 Index: src/sys/ddb/db_command.c diff -u src/sys/ddb/db_command.c:1.146 src/sys/ddb/db_command.c:1.147 --- src/sys/ddb/db_command.c:1.146 Wed Apr 6 21:56:24 2016 +++ src/sys/ddb/db_command.c Wed Apr 13 00:47:02 2016 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: db_command.c #include "opt_kernhist.h" #include "opt_ddbparam.h" #include "opt_multiprocessor.h" -#include "arp.h" #endif #include <sys/param.h> @@ -99,6 +98,8 @@ __KERNEL_RCSID(0, "$NetBSD: db_command.c #include <uvm/uvm_extern.h> #include <uvm/uvm_ddb.h> +#include <net/route.h> + /* * Results of command search. */ @@ -229,8 +230,8 @@ static const struct db_command db_show_c #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, Index: src/sys/ddb/db_interface.h diff -u src/sys/ddb/db_interface.h:1.31 src/sys/ddb/db_interface.h:1.32 --- src/sys/ddb/db_interface.h:1.31 Sun Jan 6 03:34:52 2013 +++ src/sys/ddb/db_interface.h Wed Apr 13 00:47:02 2016 @@ -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 @@ void db_show_callout(db_expr_t, bool, d /* 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 *); Index: src/sys/net/route.c diff -u src/sys/net/route.c:1.161 src/sys/net/route.c:1.162 --- src/sys/net/route.c:1.161 Mon Apr 11 08:26:33 2016 +++ src/sys/net/route.c Wed Apr 13 00:47:01 2016 @@ -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 rt_maskedcopy(const struct s 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 @@ rt_gettag(struct rtentry *rt) { 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 Index: src/sys/netinet/if_arp.c diff -u src/sys/netinet/if_arp.c:1.205 src/sys/netinet/if_arp.c:1.206 --- src/sys/netinet/if_arp.c:1.205 Thu Apr 7 03:22:15 2016 +++ src/sys/netinet/if_arp.c Wed Apr 13 00:47:01 2016 @@ -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 myip_initialized = 0; 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 @@ revarpwhoarewe(struct ifnet *ifp, struct 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(","); - } - 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); -} - -static void -db_print_llinfo(struct llentry *la) -{ - if (la == NULL) - return; - db_printf(" la_hold=%p, la_asked=%d\n", la->la_hold, la->la_asked); - db_printf(" la_flags=0x%x\n", la->la_flags); -} - -/* - * 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); - db_print_llinfo(rt->rt_llinfo); - - return 0; -} - -/* - * Function to print all the route trees. - * Use this from ddb: "show arptab" - */ -void -db_show_arptab(db_expr_t addr, bool have_addr, - db_expr_t count, const char *modif) -{ - rt_walktree(AF_INET, db_show_rtentry, NULL); -} -#endif - void arp_stat_add(int type, uint64_t count) {