diff options
author | Peter Hessler <phessler@cvs.openbsd.org> | 2015-07-18 00:02:31 +0000 |
---|---|---|
committer | Peter Hessler <phessler@cvs.openbsd.org> | 2015-07-18 00:02:31 +0000 |
commit | 4cf2f948a975738f0b9a353e864b962be2d6506f (patch) | |
tree | 249da369165b50fb08b15220c42493e137da1391 | |
parent | 4b6ee675ec46af3634c1ae5afa961358b3a02fe5 (diff) |
On systems with a full routing table (550k+), we often want to be able to
look at the routes with a priority, or to display all routes that do not
have a specific priority (normally, don't show bgp).
OK mpi@ benno@
previous versions OK deraadt@ sthen@
-rw-r--r-- | lib/libc/gen/sysctl.3 | 15 | ||||
-rw-r--r-- | sys/net/rtsock.c | 15 |
2 files changed, 26 insertions, 4 deletions
diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3 index 50d7b5ee59a..39601acd79d 100644 --- a/lib/libc/gen/sysctl.3 +++ b/lib/libc/gen/sysctl.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sysctl.3,v 1.250 2015/06/02 16:02:44 sobrado Exp $ +.\" $OpenBSD: sysctl.3,v 1.251 2015/07/18 00:02:30 phessler Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: June 2 2015 $ +.Dd $Mdocdate: July 18 2015 $ .Dt SYSCTL 3 .Os .Sh NAME @@ -1121,12 +1121,21 @@ select all address families. The fifth and sixth level names are as follows: .Bl -column "Fifth level name" "Sixth level is:" -offset indent .It Sy "Fifth level name" Ta Sy "Sixth level is:" -.It Dv NET_RT_DUMP Ta "None" +.It Dv NET_RT_DUMP Ta "priority" .It Dv NET_RT_FLAGS Ta "rtflags" .It Dv NET_RT_IFLIST Ta "None" .It Dv NET_RT_STATS Ta "None" .El .Pp +.Bl -tag -width "123456" +.It Li NET_RT_DUMP +If set to 0, show all routes. +If set to any number, show all routes with that number priority. +If set to a negative number, show routes that do not have the positive +priority value. +.El +.\ XXX - document NET_RT_FLAGS +.Pp An optional seventh level name can be provided to select the routing table on which to run the operation. If not provided, the table with ID 0 is used. diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index fdfec18b13c..a8684186a94 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.163 2015/07/16 18:17:27 claudio Exp $ */ +/* $OpenBSD: rtsock.c,v 1.164 2015/07/18 00:02:30 phessler Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -1210,6 +1210,19 @@ sysctl_dumpentry(struct radix_node *rn, void *v, u_int id) if (w->w_op == NET_RT_FLAGS && !(rt->rt_flags & w->w_arg)) return 0; + if (w->w_op == NET_RT_DUMP && w->w_arg) { + u_int8_t prio = w->w_arg & RTP_MASK; + if (w->w_arg < 0) { + prio = (-w->w_arg) & RTP_MASK; + /* Show all routes that are not this priority */ + if (prio == (rt->rt_priority & RTP_MASK)) + return 0; + } else { + if (prio != (rt->rt_priority & RTP_MASK) && + prio != RTP_ANY) + return 0; + } + } bzero(&info, sizeof(info)); info.rti_info[RTAX_DST] = rt_key(rt); info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; |