summaryrefslogtreecommitdiff
path: root/sys/net/route.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2022-07-28 22:19:10 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2022-07-28 22:19:10 +0000
commit62d5ae51fde32499c14a5864e0651e952b2c2de9 (patch)
tree8ce98d359b863881e6de42a60581983446ccf662 /sys/net/route.c
parent3effa157978aeb21ff28720a9e4dabc7c600c07e (diff)
In the kernel exist functions to print routes, but they were not
accessible from ddb. Implement "show all routes" to print routing tables, and "show route 0xfffffd807e9b0000" for a single route entry. Note that the rtable id is not part of a route entry, so it makes no sense to print it there. OK deraadt@
Diffstat (limited to 'sys/net/route.c')
-rw-r--r--sys/net/route.c25
1 files changed, 11 insertions, 14 deletions
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 */