summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2009-05-07 15:51:53 +0000
committerclaudio <claudio@openbsd.org>2009-05-07 15:51:53 +0000
commit715d0b9d04557cb17ff8c85dae00366f2d57438b (patch)
tree40e50121021a81cf696e4fd2fa18510b1546fa43
parentMove amas device from arch/amd64 to dev/pci and enable it in i386 as well. (diff)
downloadwireguard-openbsd-715d0b9d04557cb17ff8c85dae00366f2d57438b.tar.xz
wireguard-openbsd-715d0b9d04557cb17ff8c85dae00366f2d57438b.zip
Make the kvm routing table code grok multiple routing tables and do not
default to table 0 by default. Makes debugging alternate tables possible. OK jsg@
-rw-r--r--usr.bin/netstat/main.c5
-rw-r--r--usr.bin/netstat/netstat.h4
-rw-r--r--usr.bin/netstat/route.c11
3 files changed, 13 insertions, 7 deletions
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index 936ded799ec..8662a82be53 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.78 2009/02/21 20:07:49 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.79 2009/05/07 15:51:53 claudio Exp $ */
/* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */
/*
@@ -377,7 +377,8 @@ main(int argc, char *argv[])
rt_stats();
else if (Aflag || nlistf != NULL || memf != NULL)
routepr(nl[N_RTREE].n_value, nl[N_RTMASK].n_value,
- nl[N_AF2RTAFIDX].n_value, nl[N_RTBLIDMAX].n_value);
+ nl[N_AF2RTAFIDX].n_value, nl[N_RTBLIDMAX].n_value,
+ tableid);
else
p_rttables(af, tableid);
exit(0);
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
index 4fafb167e26..251721ccbf6 100644
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: netstat.h,v 1.49 2009/01/27 13:49:21 claudio Exp $ */
+/* $OpenBSD: netstat.h,v 1.50 2009/05/07 15:51:53 claudio Exp $ */
/* $NetBSD: netstat.h,v 1.6 1996/05/07 02:55:05 thorpej Exp $ */
/*
@@ -125,7 +125,7 @@ char *routename(struct sockaddr *);
char *routename4(in_addr_t);
char *netname(struct sockaddr *, struct sockaddr *);
char *netname4(in_addr_t, in_addr_t);
-void routepr(u_long, u_long, u_long, u_long);
+void routepr(u_long, u_long, u_long, u_long, u_int);
void nsprotopr(u_long, char *);
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index dc6184099f1..971e25eaffc 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.84 2009/01/28 17:19:47 claudio Exp $ */
+/* $OpenBSD: route.c,v 1.85 2009/05/07 15:51:53 claudio Exp $ */
/* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */
/*
@@ -93,7 +93,8 @@ static void encap_print(struct rtentry *);
* Print routing tables.
*/
void
-routepr(u_long rtree, u_long mtree, u_long af2idx, u_long rtbl_id_max)
+routepr(u_long rtree, u_long mtree, u_long af2idx, u_long rtbl_id_max,
+ u_int tableid)
{
struct radix_node_head *rnh, head;
int i, idxmax = 0;
@@ -121,7 +122,11 @@ routepr(u_long rtree, u_long mtree, u_long af2idx, u_long rtbl_id_max)
kread((u_long)rt_head, rnt, (rtidxmax + 1) *
sizeof(struct radix_node_head **));
- kread((u_long)rnt[0], rt_tables, (idxmax + 1) * sizeof(rnh));
+ if (tableid > rtidxmax || rnt[tableid] == NULL) {
+ printf("Bad table %u\n", tableid);
+ return;
+ }
+ kread((u_long)rnt[tableid], rt_tables, (idxmax + 1) * sizeof(rnh));
for (i = 0; i <= AF_MAX; i++) {
if (i == AF_UNSPEC) {