summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2009-06-01 15:49:42 +0000
committerbz <bz@FreeBSD.org>2009-06-01 15:49:42 +0000
commitc62e99f85d6b43e872928cb1f83b13335b7b5d51 (patch)
tree743a83cdd0c6416f952293952e112bd315518157 /usr.bin/netstat
parentc731979fffc05b5f4ec31fd935fe3bed200a0b42 (diff)
downloadFreeBSD-src-c62e99f85d6b43e872928cb1f83b13335b7b5d51.zip
FreeBSD-src-c62e99f85d6b43e872928cb1f83b13335b7b5d51.tar.gz
Convert the two dimensional array to be malloced and introduce
an accessor function to get the correct rnh pointer back. Update netstat to get the correct pointer using kvm_read() as well. This not only fixes the ABI problem depending on the kernel option but also permits the tunable to overwrite the kernel option at boot time up to MAXFIBS, enlarging the number of FIBs without having to recompile. So people could just use GENERIC now. Reviewed by: julian, rwatson, zec X-MFC: not possible
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/route.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 596fcd5..735612b 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -122,12 +122,7 @@ int do_rtent = 0;
struct rtentry rtentry;
struct radix_node rnode;
struct radix_mask rmask;
-struct rtline {
- struct radix_node_head *tables[AF_MAX+1]; /*xxx*/
-};
-struct rtline *rt_tables;
-
-struct radix_node_head *rt_tables_line[1][AF_MAX+1]; /*xxx*/
+struct radix_node_head **rt_tables;
int NewTree = 0;
@@ -155,7 +150,7 @@ static void domask(char *, in_addr_t, u_long);
void
routepr(u_long rtree)
{
- struct radix_node_head *rnh, head;
+ struct radix_node_head **rnhp, *rnh, head;
size_t intsize;
int i;
int numfibs;
@@ -165,7 +160,8 @@ routepr(u_long rtree)
fibnum = 0;
if (sysctlbyname("net.fibs", &numfibs, &intsize, NULL, 0) == -1)
numfibs = 1;
- rt_tables = calloc(numfibs, sizeof(struct rtline));
+ rt_tables = calloc(numfibs * (AF_MAX+1),
+ sizeof(struct radix_node_head *));
if (rt_tables == NULL)
err(EX_OSERR, "memory allocation failed");
/*
@@ -186,8 +182,8 @@ routepr(u_long rtree)
return;
}
- if (kread((u_long)(rtree), (char *)(rt_tables),
- (numfibs * sizeof(struct rtline))) != 0)
+ if (kread((u_long)(rtree), (char *)(rt_tables), (numfibs *
+ (AF_MAX+1) * sizeof(struct radix_node_head *))) != 0)
return;
for (i = 0; i <= AF_MAX; i++) {
int tmpfib;
@@ -195,8 +191,15 @@ routepr(u_long rtree)
tmpfib = 0;
else
tmpfib = fibnum;
- if ((rnh = rt_tables[tmpfib].tables[i]) == 0)
+ rnhp = (struct radix_node_head **)*rt_tables;
+ /* Calculate the in-kernel address. */
+ rnhp += tmpfib * (AF_MAX+1) + i;
+ /* Read the in kernel rhn pointer. */
+ if (kget(rnhp, rnh) != 0)
+ continue;
+ if (rnh == NULL)
continue;
+ /* Read the rnh data. */
if (kget(rnh, head) != 0)
continue;
if (i == AF_UNSPEC) {
OpenPOWER on IntegriCloud