summaryrefslogtreecommitdiff
path: root/sbin/route/show.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2010-10-11 11:45:01 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2010-10-11 11:45:01 +0000
commitf85887c1b6d42fa8b68c78dc07cbae461a7bb81b (patch)
tree927ea6392918f77c36ea482c1b44cf5a5750816b /sbin/route/show.c
parentfa7d763dca81101fef4d9041f72d9cb4c3d4e120 (diff)
Make route(8) use the ROUTE_TABLEFILTER and change the code so that
route(8) will default to the process rtableid. route -T 1 exec route add default 192.168.1.1 route -T 1 exec route -n show These commands will now operate outmatically on rtable 1 and not on rtable 0 as it was done before. OK henning@
Diffstat (limited to 'sbin/route/show.c')
-rw-r--r--sbin/route/show.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/sbin/route/show.c b/sbin/route/show.c
index 68e788cedba..3cd8c1eb039 100644
--- a/sbin/route/show.c
+++ b/sbin/route/show.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: show.c,v 1.88 2010/09/21 10:58:23 krw Exp $ */
+/* $OpenBSD: show.c,v 1.89 2010/10/11 11:45:00 claudio Exp $ */
/* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */
/*
@@ -123,13 +123,13 @@ void index_pfk(struct sadb_msg *, void **);
* Print routing tables.
*/
void
-p_rttables(int af, u_int tableid)
+p_rttables(int af, u_int tableid, int hastable)
{
struct rt_msghdr *rtm;
struct sadb_msg *msg;
char *buf = NULL, *next, *lim = NULL;
size_t needed;
- int mib[7];
+ int mib[7], mcnt;
struct sockaddr *sa;
mib[0] = CTL_NET;
@@ -138,14 +138,18 @@ p_rttables(int af, u_int tableid)
mib[3] = af;
mib[4] = NET_RT_DUMP;
mib[5] = 0;
- mib[6] = tableid;
+ if (hastable) {
+ mib[6] = tableid;
+ mcnt = 7;
+ } else
+ mcnt = 6;
- if (sysctl(mib, 7, NULL, &needed, NULL, 0) < 0)
+ if (sysctl(mib, mcnt, NULL, &needed, NULL, 0) < 0)
err(1, "route-sysctl-estimate");
if (needed > 0) {
if ((buf = malloc(needed)) == 0)
err(1, NULL);
- if (sysctl(mib, 7, buf, &needed, NULL, 0) < 0)
+ if (sysctl(mib, mcnt, buf, &needed, NULL, 0) < 0)
err(1, "sysctl of routing table");
lim = buf + needed;
}