diff options
author | 2009-05-30 21:06:34 +0000 | |
---|---|---|
committer | 2009-05-30 21:06:34 +0000 | |
commit | ce9a50d7cd9fa0fcc99929766d73e270aaacb342 (patch) | |
tree | 1ad5a5c25a6cd7eacb71630f5277e38ef5e78d81 | |
parent | Allow 8 byte writes from ddb (w/q) on 64 bit platforms, just like we allow (diff) | |
download | wireguard-openbsd-ce9a50d7cd9fa0fcc99929766d73e270aaacb342.tar.xz wireguard-openbsd-ce9a50d7cd9fa0fcc99929766d73e270aaacb342.zip |
Make it possible to filter monitor output on AF or show only interface
specific changes. OK henning@
-rw-r--r-- | sbin/route/route.8 | 15 | ||||
-rw-r--r-- | sbin/route/route.c | 46 |
2 files changed, 52 insertions, 9 deletions
diff --git a/sbin/route/route.8 b/sbin/route/route.8 index 8849c509cb2..4817b76f0df 100644 --- a/sbin/route/route.8 +++ b/sbin/route/route.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: route.8,v 1.57 2009/05/30 19:50:28 claudio Exp $ +.\" $OpenBSD: route.8,v 1.58 2009/05/30 21:06:34 claudio Exp $ .\" $NetBSD: route.8,v 1.6 1995/03/18 15:00:13 cgd Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 @@ -147,8 +147,7 @@ the routing tables of all gateway entries. When the address family is specified by any one of the .Ar family modifiers (listed below), only routes having destinations with addresses -in the -delineated family will be deleted. +in the delineated family will be deleted. Also, only routes matching a specific interface or priority can be flushed by using the .Fl iface @@ -162,8 +161,18 @@ command has the syntax: .Bd -filled -offset indent .Nm route Op Fl \&dn .Cm monitor +.Op Ar modifiers .Ed .Pp +When the address family is specified by any one of the +.Ar family +modifiers (listed below), only routes having destinations with addresses +in the delineated family will be shown. +If the +.Fl iface +modifier is used only interface specific messages (link state changes) +are shown. +.Pp The .Cm show command has the syntax: diff --git a/sbin/route/route.c b/sbin/route/route.c index 77378486a79..be74d34b4c1 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.130 2009/05/30 20:03:31 claudio Exp $ */ +/* $OpenBSD: route.c,v 1.131 2009/05/30 21:06:34 claudio Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -90,7 +90,7 @@ void flushroutes(int, char **); int newroute(int, char **); void show(int, char *[]); int keyword(char *); -void monitor(void); +void monitor(int, char *[]); int prefixlen(char *); void sockaddr(char *, struct sockaddr *); void sodump(sup, char *); @@ -169,14 +169,17 @@ main(int argc, char **argv) pid = getpid(); uid = geteuid(); + if (*argv == NULL) + usage(NULL); + if (keyword(*argv) == K_MONITOR) + monitor(argc, argv); + if (tflag) s = open(_PATH_DEVNULL, O_WRONLY); else s = socket(PF_ROUTE, SOCK_RAW, 0); if (s == -1) err(1, "socket"); - if (*argv == NULL) - usage(NULL); switch (keyword(*argv)) { case K_GET: uid = 0; @@ -191,7 +194,7 @@ main(int argc, char **argv) show(argc, argv); break; case K_MONITOR: - monitor(); + /* handled above */ break; case K_FLUSH: flushroutes(argc, argv); @@ -1010,12 +1013,43 @@ interfaces(void) } void -monitor(void) +monitor(int argc, char *argv[]) { + int af = 0; + unsigned int filter = 0; int n; char msg[2048]; time_t now; + while (--argc > 0) { + if (**(++argv)== '-') + switch (keyword(*argv + 1)) { + case K_INET: + af = AF_INET; + break; + case K_INET6: + af = AF_INET6; + break; + case K_IFACE: + filter = ROUTE_FILTER(RTM_IFINFO) | + ROUTE_FILTER(RTM_IFANNOUNCE); + break; + default: + usage(*argv); + /* NOTREACHED */ + } + else + usage(*argv); + } + + s = socket(PF_ROUTE, SOCK_RAW, af); + if (s == -1) + err(1, "socket"); + + if (setsockopt(s, AF_ROUTE, ROUTE_MSGFILTER, &filter, + sizeof(filter)) == -1) + err(1, "setsockopt"); + verbose = 1; if (debugonly) { interfaces(); |