summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2012-02-17 02:39:58 +0000
committerbz <bz@FreeBSD.org>2012-02-17 02:39:58 +0000
commitdcdb23291fec1365e927195511d5dfb273901a5d (patch)
treec7ee398c979933c1e0e6d10495989fe027210cec /usr.bin/netstat
parentf73705f023ce445780ef6da3c298f9aca1ef8acb (diff)
downloadFreeBSD-src-dcdb23291fec1365e927195511d5dfb273901a5d.zip
FreeBSD-src-dcdb23291fec1365e927195511d5dfb273901a5d.tar.gz
Merge multi-FIB IPv6 support from projects/multi-fibv6/head/:
Extend the so far IPv4-only support for multiple routing tables (FIBs) introduced in r178888 to IPv6 providing feature parity. This includes an extended rtalloc(9) KPI for IPv6, the necessary adjustments to the network stack, and user land support as in netstat. Sponsored by: Cisco Systems, Inc. Reviewed by: melifaro (basically) MFC after: 10 days
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/route.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 2b4ad2f..996b471 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -113,7 +113,6 @@ typedef union {
static sa_u pt_u;
-int fibnum;
int do_rtent = 0;
struct rtentry rtentry;
struct radix_node rnode;
@@ -148,8 +147,7 @@ routepr(u_long rtree)
{
struct radix_node_head **rnhp, *rnh, head;
size_t intsize;
- int i;
- int numfibs;
+ int fam, fibnum, numfibs;
intsize = sizeof(int);
if (sysctlbyname("net.my_fibnum", &fibnum, &intsize, NULL, 0) == -1)
@@ -181,15 +179,20 @@ routepr(u_long rtree)
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++) {
+ for (fam = 0; fam <= AF_MAX; fam++) {
int tmpfib;
- if (i != AF_INET)
- tmpfib = 0;
- else
+
+ switch (fam) {
+ case AF_INET6:
+ case AF_INET:
tmpfib = fibnum;
+ break;
+ default:
+ tmpfib = 0;
+ }
rnhp = (struct radix_node_head **)*rt_tables;
/* Calculate the in-kernel address. */
- rnhp += tmpfib * (AF_MAX+1) + i;
+ rnhp += tmpfib * (AF_MAX+1) + fam;
/* Read the in kernel rhn pointer. */
if (kget(rnhp, rnh) != 0)
continue;
@@ -198,16 +201,16 @@ routepr(u_long rtree)
/* Read the rnh data. */
if (kget(rnh, head) != 0)
continue;
- if (i == AF_UNSPEC) {
+ if (fam == AF_UNSPEC) {
if (Aflag && af == 0) {
printf("Netmasks:\n");
p_tree(head.rnh_treetop);
}
- } else if (af == AF_UNSPEC || af == i) {
- size_cols(i, head.rnh_treetop);
- pr_family(i);
+ } else if (af == AF_UNSPEC || af == fam) {
+ size_cols(fam, head.rnh_treetop);
+ pr_family(fam);
do_rtent = 1;
- pr_rthdr(i);
+ pr_rthdr(fam);
p_tree(head.rnh_treetop);
}
}
OpenPOWER on IntegriCloud