diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ddb/db_command.c | 29 | ||||
-rw-r--r-- | sys/ddb/db_interface.h | 6 | ||||
-rw-r--r-- | sys/net/route.c | 25 |
3 files changed, 44 insertions, 16 deletions
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index d6e5a20fc16..8f560afbd7d 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.c,v 1.94 2022/04/14 19:47:12 naddy Exp $ */ +/* $OpenBSD: db_command.c,v 1.95 2022/07/28 22:19:09 bluhm Exp $ */ /* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */ /* @@ -418,6 +418,31 @@ db_show_all_tdbs(db_expr_t addr, int have_addr, db_expr_t count, char *modif) } #endif +void +db_show_all_routes(db_expr_t addr, int have_addr, db_expr_t count, char *modif) +{ + u_int rtableid = 0; + + if (have_addr) + rtableid = addr; + if (count == -1) + count = 1; + + while (count--) { + if (modif[0] != 'I') + db_show_rtable(AF_INET, rtableid); + if (modif[0] != 'i') + db_show_rtable(AF_INET6, rtableid); + rtableid++; + } +} + +void +db_show_route(db_expr_t addr, int have_addr, db_expr_t count, char *modif) +{ + db_show_rtentry((void *)addr, NULL, -1); +} + /*ARGSUSED*/ void db_object_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) @@ -568,6 +593,7 @@ const struct db_command db_show_all_cmds[] = { { "mounts", db_show_all_mounts, 0, NULL }, { "vnodes", db_show_all_vnodes, 0, NULL }, { "bufs", db_show_all_bufs, 0, NULL }, + { "routes", db_show_all_routes, 0, NULL }, #ifdef NFSCLIENT { "nfsreqs", db_show_all_nfsreqs, 0, NULL }, { "nfsnodes", db_show_all_nfsnodes, 0, NULL }, @@ -604,6 +630,7 @@ const struct db_command db_show_cmds[] = { { "pool", db_pool_print_cmd, 0, NULL }, { "proc", db_proc_print_cmd, 0, NULL }, { "registers", db_show_regs, 0, NULL }, + { "route", db_show_route, 0, NULL }, { "socket", db_socket_print_cmd, 0, NULL }, { "struct", db_ctf_show_struct, CS_OWN, NULL }, #ifdef IPSEC diff --git a/sys/ddb/db_interface.h b/sys/ddb/db_interface.h index d290d35d813..e66dc8c9eda 100644 --- a/sys/ddb/db_interface.h +++ b/sys/ddb/db_interface.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.h,v 1.22 2019/11/07 13:16:25 mpi Exp $ */ +/* $OpenBSD: db_interface.h,v 1.23 2022/07/28 22:19:09 bluhm Exp $ */ /* $NetBSD: db_interface.h,v 1.1 1996/02/05 01:57:03 christos Exp $ */ /* @@ -62,6 +62,10 @@ void m_print(void *, int (*)(const char *, ...)); /* kern/uipc_socket.c */ void so_print(void *, int (*)(const char *, ...)); +struct rtentry; +int db_show_rtentry(struct rtentry *, void *, unsigned int); +int db_show_rtable(int, unsigned int); + /* nfs/nfs_debug.c */ void db_show_all_nfsreqs(db_expr_t, int, db_expr_t, char *); void nfs_request_print(void *, int, int (*)(const char *, ...)); diff --git a/sys/net/route.c b/sys/net/route.c index bafadfd9e7c..7d1aeeca26a 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.412 2022/06/28 10:01:13 bluhm Exp $ */ +/* $OpenBSD: route.c,v 1.413 2022/07/28 22:19:09 bluhm Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -161,12 +161,6 @@ int rt_clone(struct rtentry **, struct sockaddr *, unsigned int); struct sockaddr *rt_plentosa(sa_family_t, int, struct sockaddr_in6 *); static int rt_copysa(struct sockaddr *, struct sockaddr *, struct sockaddr **); -#ifdef DDB -void db_print_sa(struct sockaddr *); -void db_print_ifa(struct ifaddr *); -int db_show_rtentry(struct rtentry *, void *, unsigned int); -#endif - #define LABELID_MAX 50000 struct rt_label { @@ -1825,6 +1819,9 @@ rt_plen2mask(struct rtentry *rt, struct sockaddr_in6 *sa_mask) #include <machine/db_machdep.h> #include <ddb/db_output.h> +void db_print_sa(struct sockaddr *); +void db_print_ifa(struct ifaddr *); + void db_print_sa(struct sockaddr *sa) { @@ -1873,8 +1870,8 @@ db_show_rtentry(struct rtentry *rt, void *w, unsigned int id) { db_printf("rtentry=%p", rt); - db_printf(" flags=0x%x refcnt=%u use=%llu expire=%lld rtableid=%u\n", - rt->rt_flags, rt->rt_refcnt.r_refs, rt->rt_use, rt->rt_expire, id); + db_printf(" flags=0x%x refcnt=%u use=%llu expire=%lld\n", + rt->rt_flags, rt->rt_refcnt.r_refs, rt->rt_use, rt->rt_expire); db_printf(" key="); db_print_sa(rt_key(rt)); db_printf(" plen=%d", rt_plen(rt)); @@ -1883,19 +1880,19 @@ db_show_rtentry(struct rtentry *rt, void *w, unsigned int id) 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_printf(" gwroute=%p llinfo=%p priority=%d\n", + rt->rt_gwroute, rt->rt_llinfo, rt->rt_priority); return (0); } /* * Function to print all the route trees. - * Use this from ddb: "call db_show_arptab" */ int -db_show_arptab(void) +db_show_rtable(int af, unsigned int rtableid) { - db_printf("Route tree for AF_INET\n"); - rtable_walk(0, AF_INET, NULL, db_show_rtentry, NULL); + db_printf("Route tree for af %d, rtableid %u\n", af, rtableid); + rtable_walk(rtableid, af, NULL, db_show_rtentry, NULL); return (0); } #endif /* DDB */ |