summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2018-04-30 10:32:03 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2018-04-30 10:32:03 +0000
commit59f2a922478cbc38ecd9dfe4e81ffed3138393cc (patch)
treea84da073d18d025899bdb752d8a939bbd9599f06
parent4e63c1e84baf23f564b51faa9da68724ace9791e (diff)
tableid is either initialized to the current routing table or to the
one specified by the T flag. No need to pass a flag around if the tableid is valid. It always is. This code is now in sync between flushroutes() and p_rttables(). OK benno, no objection claudio
-rw-r--r--sbin/route/route.c4
-rw-r--r--sbin/route/show.c16
-rw-r--r--sbin/route/show.h4
3 files changed, 10 insertions, 14 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index cc91006691f..f9494144ee9 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.210 2018/04/30 10:29:28 florian Exp $ */
+/* $OpenBSD: route.c,v 1.211 2018/04/30 10:32:02 florian Exp $ */
/* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */
/*
@@ -750,7 +750,7 @@ show(int argc, char *argv[])
usage(*argv);
}
- p_rttables(af, tableid, Tflag, prio);
+ p_rttables(af, tableid, prio);
return (0);
}
diff --git a/sbin/route/show.c b/sbin/route/show.c
index bfd726e6a20..f2d8972e68a 100644
--- a/sbin/route/show.c
+++ b/sbin/route/show.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: show.c,v 1.109 2018/04/28 18:53:12 florian Exp $ */
+/* $OpenBSD: show.c,v 1.110 2018/04/30 10:32:02 florian Exp $ */
/* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */
/*
@@ -111,12 +111,12 @@ char *netname6(struct sockaddr_in6 *, struct sockaddr_in6 *);
* Print routing tables.
*/
void
-p_rttables(int af, u_int tableid, int hastable, char prio)
+p_rttables(int af, u_int tableid, char prio)
{
struct rt_msghdr *rtm;
char *buf = NULL, *next, *lim = NULL;
size_t needed;
- int mib[7], mcnt;
+ int mib[7];
struct sockaddr *sa;
mib[0] = CTL_NET;
@@ -125,20 +125,16 @@ p_rttables(int af, u_int tableid, int hastable, char prio)
mib[3] = af;
mib[4] = NET_RT_DUMP;
mib[5] = prio;
- if (hastable) {
- mib[6] = tableid;
- mcnt = 7;
- } else
- mcnt = 6;
+ mib[6] = tableid;
while (1) {
- if (sysctl(mib, mcnt, NULL, &needed, NULL, 0) == -1)
+ if (sysctl(mib, 7, NULL, &needed, NULL, 0) == -1)
err(1, "route-sysctl-estimate");
if (needed == 0)
break;
if ((buf = realloc(buf, needed)) == NULL)
err(1, NULL);
- if (sysctl(mib, mcnt, buf, &needed, NULL, 0) == -1) {
+ if (sysctl(mib, 7, buf, &needed, NULL, 0) == -1) {
if (errno == ENOMEM)
continue;
err(1, "sysctl of routing table");
diff --git a/sbin/route/show.h b/sbin/route/show.h
index 14c8b0e9c11..03999b7fdd7 100644
--- a/sbin/route/show.h
+++ b/sbin/route/show.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: show.h,v 1.12 2016/12/13 08:40:54 mpi Exp $ */
+/* $OpenBSD: show.h,v 1.13 2018/04/30 10:32:02 florian Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -29,7 +29,7 @@ union sockunion {
};
void get_rtaddrs(int, struct sockaddr *, struct sockaddr **);
-void p_rttables(int, u_int, int, char);
+void p_rttables(int, u_int, char);
void p_sockaddr(struct sockaddr *, struct sockaddr *, int, int);
char *routename(struct sockaddr *);
char *netname(struct sockaddr *, struct sockaddr *);