-.\" $OpenBSD: ddb.4,v 1.101 2022/03/31 17:27:20 naddy Exp $
+.\" $OpenBSD: ddb.4,v 1.102 2022/07/28 22:19:09 bluhm Exp $
.\" $NetBSD: ddb.4,v 1.5 1994/11/30 16:22:09 jtc Exp $
.\"
.\" Mach Operating System
.\" any improvements or extensions that they make and grant Carnegie Mellon
.\" the rights to redistribute these changes.
.\"
-.Dd $Mdocdate: March 31 2022 $
+.Dd $Mdocdate: July 28 2022 $
.Dt DDB 4
.Os
.Sh NAME
modifier is not supported on every machine, in which case
incorrect information may be displayed.
.\" --------------------
+.It Ic show route Ar addr
+Prints the
+.Li struct rtentry
+at
+.Ar addr .
+.\" --------------------
.It Ic show socket Ar addr
Prints the
.Li struct socket
command for more information.
.El
.\" --------------------
+.It Xo
+.Ic show all routes
+.Op Cm /iI
+.Op Ar rtableid
+.Op Ic \&, Ns Ar count
+.Xc
+Show internet routing tables.
+Default for
+.Ar rtableid
+is 0 and
+.Ar count
+is 1.
+.Pp
+.Bl -tag -width foo -compact
+.It Cm /i
+Restrict to AF_INET.
+.It Cm /I
+Restrict to AF_INET6.
+.El
+.\" --------------------
.It Ic show all tdbs Op Cm /f
Display information about all IPsec SAs in the system.
.Pp
-/* $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 $ */
/*
}
#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)
{ "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 },
{ "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
-/* $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 $ */
/*
/* 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 *, ...));
-/* $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 $ */
/*
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 {
#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)
{
{
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));
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 */