From owner-svn-src-projects@FreeBSD.ORG Fri Feb 3 15:26:56 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 409741065672; Fri, 3 Feb 2012 15:26:56 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 11BD38FC0A; Fri, 3 Feb 2012 15:26:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q13FQtom092986; Fri, 3 Feb 2012 15:26:55 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q13FQt4w092984; Fri, 3 Feb 2012 15:26:55 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201202031526.q13FQt4w092984@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Fri, 3 Feb 2012 15:26:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r230947 - projects/multi-fibv6/head/usr.bin/netstat X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Feb 2012 15:26:56 -0000 Author: bz Date: Fri Feb 3 15:26:55 2012 New Revision: 230947 URL: http://svn.freebsd.org/changeset/base/230947 Log: Teach netstat -r (display contents of routing tables) about multi-FIB for IPv6 in addition to IPv4. While here harmonize naming of variables a bit with what we use in kernel. Sponsored by: Cisco Systems, Inc. Modified: projects/multi-fibv6/head/usr.bin/netstat/route.c Modified: projects/multi-fibv6/head/usr.bin/netstat/route.c ============================================================================== --- projects/multi-fibv6/head/usr.bin/netstat/route.c Fri Feb 3 13:54:25 2012 (r230946) +++ projects/multi-fibv6/head/usr.bin/netstat/route.c Fri Feb 3 15:26:55 2012 (r230947) @@ -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); } }