Add -F fibnum option to specify an FIB number for -r flag.
This commit is contained in:
parent
585f796613
commit
3fddef95af
@ -363,10 +363,12 @@ main(int argc, char *argv[])
|
||||
{
|
||||
struct protox *tp = NULL; /* for printing cblocks & stats */
|
||||
int ch;
|
||||
int fib = -1;
|
||||
char *endptr;
|
||||
|
||||
af = AF_UNSPEC;
|
||||
|
||||
while ((ch = getopt(argc, argv, "AaBbdf:ghI:iLlM:mN:np:Qq:rSTsuWw:xz"))
|
||||
while ((ch = getopt(argc, argv, "AaBbdF:f:ghI:iLlM:mN:np:Qq:rSTsuWw:xz"))
|
||||
!= -1)
|
||||
switch(ch) {
|
||||
case 'A':
|
||||
@ -384,6 +386,12 @@ main(int argc, char *argv[])
|
||||
case 'd':
|
||||
dflag = 1;
|
||||
break;
|
||||
case 'F':
|
||||
fib = strtol(optarg, &endptr, 0);
|
||||
if (*endptr != '\0' ||
|
||||
(fib == 0 && (errno == EINVAL || errno == ERANGE)))
|
||||
errx(1, "%s: invalid fib", optarg);
|
||||
break;
|
||||
case 'f':
|
||||
if (strcmp(optarg, "ipx") == 0)
|
||||
af = AF_IPX;
|
||||
@ -571,7 +579,7 @@ main(int argc, char *argv[])
|
||||
if (sflag)
|
||||
rt_stats(nl[N_RTSTAT].n_value, nl[N_RTTRASH].n_value);
|
||||
else
|
||||
routepr(nl[N_RTREE].n_value);
|
||||
routepr(nl[N_RTREE].n_value, fib);
|
||||
exit(0);
|
||||
}
|
||||
if (gflag) {
|
||||
|
@ -28,7 +28,7 @@
|
||||
.\" @(#)netstat.1 8.8 (Berkeley) 4/18/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 10, 2013
|
||||
.Dd May 17, 2013
|
||||
.Dt NETSTAT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -217,14 +217,29 @@ states.
|
||||
.Nm
|
||||
.Fl r
|
||||
.Op Fl AanW
|
||||
.Op Fl F Ar fibnum
|
||||
.Op Fl f Ar address_family
|
||||
.Op Fl M Ar core
|
||||
.Op Fl N Ar system
|
||||
.Ek
|
||||
.Xc
|
||||
Display the contents of all routing tables,
|
||||
or a routing table for a particular
|
||||
.Ar address_family .
|
||||
Display the contents of routing tables.
|
||||
When
|
||||
.Fl f
|
||||
is specified, a routing table for a particular
|
||||
.Ar address_family
|
||||
is displayed.
|
||||
When
|
||||
.Fl F
|
||||
is specified, a routing table with the number
|
||||
.Ar fibnum
|
||||
is displayed.
|
||||
If the specified
|
||||
.Ar fibnum
|
||||
is -1 or
|
||||
.Fl F
|
||||
is not specified,
|
||||
the default routing table is displayed.
|
||||
If
|
||||
.Fl A
|
||||
is also present,
|
||||
|
@ -135,7 +135,7 @@ char *atalk_print(struct sockaddr *, int);
|
||||
char *atalk_print2(struct sockaddr *, struct sockaddr *, int);
|
||||
char *ipx_print(struct sockaddr *);
|
||||
char *ns_print(struct sockaddr *);
|
||||
void routepr(u_long);
|
||||
void routepr(u_long, int);
|
||||
|
||||
void ipxprotopr(u_long, const char *, int, int);
|
||||
void spx_stats(u_long, const char *, int, int);
|
||||
|
@ -143,17 +143,20 @@ static void domask(char *, in_addr_t, u_long);
|
||||
* Print routing tables.
|
||||
*/
|
||||
void
|
||||
routepr(u_long rtree)
|
||||
routepr(u_long rtree, int fibnum)
|
||||
{
|
||||
struct radix_node_head **rnhp, *rnh, head;
|
||||
size_t intsize;
|
||||
int fam, fibnum, numfibs;
|
||||
int fam, numfibs;
|
||||
|
||||
intsize = sizeof(int);
|
||||
if (sysctlbyname("net.my_fibnum", &fibnum, &intsize, NULL, 0) == -1)
|
||||
if (fibnum == -1 &&
|
||||
sysctlbyname("net.my_fibnum", &fibnum, &intsize, NULL, 0) == -1)
|
||||
fibnum = 0;
|
||||
if (sysctlbyname("net.fibs", &numfibs, &intsize, NULL, 0) == -1)
|
||||
numfibs = 1;
|
||||
if (fibnum < 0 || fibnum > numfibs - 1)
|
||||
errx(EX_USAGE, "%d: invalid fib", fibnum);
|
||||
rt_tables = calloc(numfibs * (AF_MAX+1),
|
||||
sizeof(struct radix_node_head *));
|
||||
if (rt_tables == NULL)
|
||||
@ -166,7 +169,10 @@ routepr(u_long rtree)
|
||||
if (clock_gettime(CLOCK_UPTIME, &uptime) < 0)
|
||||
err(EX_OSERR, "clock_gettime() failed");
|
||||
|
||||
printf("Routing tables\n");
|
||||
printf("Routing tables");
|
||||
if (fibnum)
|
||||
printf(" (fib: %d)", fibnum);
|
||||
printf("\n");
|
||||
|
||||
if (Aflag == 0 && NewTree)
|
||||
ntreestuff();
|
||||
|
Loading…
Reference in New Issue
Block a user