diff options
author | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-03-23 16:02:27 +0000 |
---|---|---|
committer | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-03-23 16:02:27 +0000 |
commit | ad6cc85d0717ab6ae01145be2199dd5a490d46ad (patch) | |
tree | 3e9949e1c0ad3216bb94f3dc17052a0b71d00473 /sbin | |
parent | 39e29b364f8f5d3d1176e2428e832eb3e3c10a63 (diff) |
Add a new flag -F to netstat restricting route display in conjuction
with -r to routes in the same address family as the destination.
ok henning@, claudio@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/route/route.8 | 5 | ||||
-rw-r--r-- | sbin/route/route.c | 9 | ||||
-rw-r--r-- | sbin/route/show.c | 8 |
3 files changed, 16 insertions, 6 deletions
diff --git a/sbin/route/route.8 b/sbin/route/route.8 index 269c94dfaf9..fa6495f416d 100644 --- a/sbin/route/route.8 +++ b/sbin/route/route.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: route.8,v 1.50 2007/01/19 20:49:30 jmc Exp $ +.\" $OpenBSD: route.8,v 1.51 2007/03/23 16:02:26 pyr Exp $ .\" $NetBSD: route.8,v 1.6 1995/03/18 15:00:13 cgd Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 @@ -75,6 +75,9 @@ The options are as follows: .Bl -tag -width Ds .It Fl d Run in debug-only mode, i.e., don't actually modify the routing table. +.It Fl F +When showing routes, only show routes whose gateway are in the +same address family as the destination. .It Fl n Bypass attempts to print host and network names symbolically when reporting actions. diff --git a/sbin/route/route.c b/sbin/route/route.c index bd9922efcd8..0f098effba7 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.105 2007/03/23 13:43:32 claudio Exp $ */ +/* $OpenBSD: route.c,v 1.106 2007/03/23 16:02:26 pyr Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -76,7 +76,7 @@ union sockunion { typedef union sockunion *sup; pid_t pid; int rtm_addrs, s; -int forcehost, forcenet, nflag, af, qflag, tflag; +int forcehost, forcenet, Fflag, nflag, af, qflag, tflag; int iflag, verbose, aflen = sizeof(struct sockaddr_in); int locking, lockrest, debugonly; u_long rtm_inits; @@ -137,8 +137,11 @@ main(int argc, char **argv) if (argc < 2) usage(NULL); - while ((ch = getopt(argc, argv, "dnqtT:v")) != -1) + while ((ch = getopt(argc, argv, "dFnqtT:v")) != -1) switch (ch) { + case 'F': + Fflag = 1; + break; case 'n': nflag = 1; break; diff --git a/sbin/route/show.c b/sbin/route/show.c index f81e603ac6a..25cb2edf034 100644 --- a/sbin/route/show.c +++ b/sbin/route/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.56 2006/12/29 10:04:36 claudio Exp $ */ +/* $OpenBSD: show.c,v 1.57 2007/03/23 16:02:26 pyr Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -63,6 +63,7 @@ char *ipx_print(struct sockaddr *); char *link_print(struct sockaddr *); extern int nflag; +extern int Fflag; #define PLEN (LONG_BIT / 4 + 2) /* XXX this is also defined in netstat.h */ @@ -250,12 +251,15 @@ p_rtentry(struct rt_msghdr *rtm) if (sa->sa_family == AF_KEY) return; + get_rtaddrs(rtm->rtm_addrs, sa, rti_info); + if (Fflag && rti_info[RTAX_GATEWAY]->sa_family != sa->sa_family) { + return; + } if (old_af != sa->sa_family) { old_af = sa->sa_family; pr_family(sa->sa_family); pr_rthdr(sa->sa_family); } - get_rtaddrs(rtm->rtm_addrs, sa, rti_info); mask = rti_info[RTAX_NETMASK]; if ((sa = rti_info[RTAX_DST]) == NULL) |