summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2018-04-30 10:29:29 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2018-04-30 10:29:29 +0000
commit4e63c1e84baf23f564b51faa9da68724ace9791e (patch)
tree45c684a9ad9bb5c73d2f2a1dad44e417db8e953d /sbin
parent25eb3d9d17e4e03f23f00053abaa998a7641c887 (diff)
No need to get the whole routing table from the kernel if we are
filtering by address family and / or priority; similar to what p_rttables() is doing. (At the time of writing we need to copy about 150MB for the whole table on a router that is in the default free zone). OK benno
Diffstat (limited to 'sbin')
-rw-r--r--sbin/route/route.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index c3bb06dcd2b..cc91006691f 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.209 2018/04/30 10:18:00 florian Exp $ */
+/* $OpenBSD: route.c,v 1.210 2018/04/30 10:29:28 florian Exp $ */
/* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */
/*
@@ -329,9 +329,9 @@ flushroutes(int argc, char **argv)
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
mib[2] = 0; /* protocol */
- mib[3] = 0; /* wildcard address family */
+ mib[3] = af;
mib[4] = NET_RT_DUMP;
- mib[5] = 0; /* no flags */
+ mib[5] = prio;
mib[6] = tableid;
while (1) {
if (sysctl(mib, 7, NULL, &needed, NULL, 0) == -1)
@@ -372,12 +372,8 @@ flushroutes(int argc, char **argv)
if ((rtm->rtm_flags & (RTF_LOCAL|RTF_BROADCAST)) != 0)
continue;
sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
- if (af && sa->sa_family != af)
- continue;
if (ifindex && rtm->rtm_index != ifindex)
continue;
- if (prio && rtm->rtm_priority != prio)
- continue;
if (sa->sa_family == AF_KEY)
continue; /* Don't flush SPD */
if (debugonly)