diff options
author | 2009-08-17 11:36:01 +0000 | |
---|---|---|
committer | 2009-08-17 11:36:01 +0000 | |
commit | 417c432fe120d1d83d3ab6abbf095070175b55d0 (patch) | |
tree | 2727e51064854006b10fd8967956440484068e9a | |
parent | remove prototype of non-existent midi_get_hwif() (diff) | |
download | wireguard-openbsd-417c432fe120d1d83d3ab6abbf095070175b55d0.tar.xz wireguard-openbsd-417c432fe120d1d83d3ab6abbf095070175b55d0.zip |
also report routers and their host states in relayctl
ok pyr@, jmc@ for man bits
-rw-r--r-- | usr.sbin/relayctl/parser.c | 3 | ||||
-rw-r--r-- | usr.sbin/relayctl/parser.h | 3 | ||||
-rw-r--r-- | usr.sbin/relayctl/relayctl.8 | 9 | ||||
-rw-r--r-- | usr.sbin/relayctl/relayctl.c | 36 | ||||
-rw-r--r-- | usr.sbin/relayd/pfe.c | 27 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 4 |
6 files changed, 69 insertions, 13 deletions
diff --git a/usr.sbin/relayctl/parser.c b/usr.sbin/relayctl/parser.c index 303713537f9..25c51285b68 100644 --- a/usr.sbin/relayctl/parser.c +++ b/usr.sbin/relayctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.20 2007/12/20 20:15:43 reyk Exp $ */ +/* $OpenBSD: parser.c,v 1.21 2009/08/17 11:36:01 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -82,6 +82,7 @@ static const struct token t_show[] = { {KEYWORD, "hosts", SHOW_HOSTS, NULL}, {KEYWORD, "redirects", SHOW_RDRS, NULL}, {KEYWORD, "relays", SHOW_RELAYS, NULL}, + {KEYWORD, "routers", SHOW_ROUTERS, NULL}, {KEYWORD, "sessions", SHOW_SESSIONS, NULL}, {ENDTOKEN, "", NONE, NULL} }; diff --git a/usr.sbin/relayctl/parser.h b/usr.sbin/relayctl/parser.h index 91e3e949671..0a30ae4584c 100644 --- a/usr.sbin/relayctl/parser.h +++ b/usr.sbin/relayctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.9 2007/12/20 20:15:43 reyk Exp $ */ +/* $OpenBSD: parser.h,v 1.10 2009/08/17 11:36:01 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -23,6 +23,7 @@ enum actions { SHOW_RDRS, SHOW_RELAYS, SHOW_SESSIONS, + SHOW_ROUTERS, RDR_DISABLE, RDR_ENABLE, TABLE_DISABLE, diff --git a/usr.sbin/relayctl/relayctl.8 b/usr.sbin/relayctl/relayctl.8 index 8bf8478fd8d..b5a16209201 100644 --- a/usr.sbin/relayctl/relayctl.8 +++ b/usr.sbin/relayctl/relayctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: relayctl.8,v 1.23 2008/12/31 15:22:27 sobrado Exp $ +.\" $OpenBSD: relayctl.8,v 1.24 2009/08/17 11:36:01 reyk Exp $ .\" .\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 31 2008 $ +.Dd $Mdocdate: August 17 2009 $ .Dt RELAYCTL 8 .Os .Sh NAME @@ -76,10 +76,13 @@ not the total number of redirected connections. Show detailed status of relays including the current and average access statistics. The statistics will be updated every minute. +.It Cm show routers +Show detailed status of routers including the configured network +routes. .It Cm show sessions Dump the complete list of running relay sessions. .It Cm show summary -Display a list of all relays, redirections, tables, and hosts. +Display a list of all relays, redirections, routers, tables, and hosts. .It Cm table disable Op Ar name | id Disable a table. Consider all hosts disabled. diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c index 0ce43e44114..81eae4e7bf9 100644 --- a/usr.sbin/relayctl/relayctl.c +++ b/usr.sbin/relayctl/relayctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayctl.c,v 1.38 2009/08/07 11:21:53 reyk Exp $ */ +/* $OpenBSD: relayctl.c,v 1.39 2009/08/17 11:36:01 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -139,6 +139,7 @@ main(int argc, char *argv[]) case SHOW_HOSTS: case SHOW_RDRS: case SHOW_RELAYS: + case SHOW_ROUTERS: imsg_compose(ibuf, IMSG_CTL_SHOW_SUM, 0, 0, -1, NULL, 0); printf("%-4s\t%-8s\t%-24s\t%-7s\tStatus\n", "Id", "Type", "Name", "Avlblty"); @@ -204,6 +205,7 @@ main(int argc, char *argv[]) case SHOW_HOSTS: case SHOW_RDRS: case SHOW_RELAYS: + case SHOW_ROUTERS: done = show_summary_msg(&imsg, res->action); break; case SHOW_SESSIONS: @@ -306,12 +308,14 @@ show_summary_msg(struct imsg *imsg, int type) struct table *table; struct host *host; struct relay *rlay; + struct router *rt; + struct netroute *nr; struct ctl_stats stats[RELAY_MAXPROC]; char name[MAXHOSTNAMELEN]; switch (imsg->hdr.type) { case IMSG_CTL_RDR: - if (type == SHOW_HOSTS || type == SHOW_RELAYS) + if (!(type == SHOW_SUM || type == SHOW_RDRS)) break; rdr = imsg->data; printf("%-4u\t%-8s\t%-24s\t%-7s\t%s\n", @@ -319,7 +323,7 @@ show_summary_msg(struct imsg *imsg, int type) print_rdr_status(rdr->conf.flags)); break; case IMSG_CTL_TABLE: - if (type == SHOW_RELAYS || type == SHOW_RDRS) + if (!(type == SHOW_SUM || type == SHOW_HOSTS)) break; table = imsg->data; printf("%-4u\t%-8s\t%-24s\t%-7s\t%s\n", @@ -327,7 +331,7 @@ show_summary_msg(struct imsg *imsg, int type) print_table_status(table->up, table->conf.flags)); break; case IMSG_CTL_HOST: - if (type == SHOW_RELAYS || type == SHOW_RDRS) + if (!(type == SHOW_SUM || type == SHOW_HOSTS)) break; host = imsg->data; if (host->conf.parentid) @@ -350,7 +354,7 @@ show_summary_msg(struct imsg *imsg, int type) } break; case IMSG_CTL_RELAY: - if (type == SHOW_HOSTS || type == SHOW_RDRS) + if (!(type == SHOW_SUM || type == SHOW_RELAYS)) break; rlay = imsg->data; printf("%-4u\t%-8s\t%-24s\t%-7s\t%s\n", @@ -370,6 +374,28 @@ show_summary_msg(struct imsg *imsg, int type) bcopy(imsg->data, &stats, sizeof(stats)); print_statistics(stats); break; + case IMSG_CTL_ROUTER: + if (!(type == SHOW_SUM || type == SHOW_ROUTERS)) + break; + rt = imsg->data; + printf("%-4u\t%-8s\t%-24s\t%-7s\t%s\n", + rt->rt_conf.id, "router", rt->rt_conf.name, "", + print_relay_status(rt->rt_conf.flags)); + if (type != SHOW_ROUTERS) + break; + if (rt->rt_conf.rtable) + printf("\t%8s\trtable: %d\n", "", rt->rt_conf.rtable); + if (strlen(rt->rt_conf.label)) + printf("\t%8s\trtlabel: %s\n", "", rt->rt_conf.label); + break; + case IMSG_CTL_NETROUTE: + if (type != SHOW_ROUTERS) + break; + nr = imsg->data; + (void)print_host(&nr->nr_conf.ss, name, sizeof(name)); + printf("\t%8s\troute: %s/%d\n", + "", name, nr->nr_conf.prefixlen); + break; case IMSG_CTL_END: return (1); default: diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c index d5db13f5b03..0abd31918be 100644 --- a/usr.sbin/relayd/pfe.c +++ b/usr.sbin/relayd/pfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfe.c,v 1.62 2009/08/13 13:51:21 reyk Exp $ */ +/* $OpenBSD: pfe.c,v 1.63 2009/08/17 11:36:01 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -530,6 +530,8 @@ show(struct ctl_conn *c) struct rdr *rdr; struct host *host; struct relay *rlay; + struct router *rt; + struct netroute *nr; if (env->sc_rdrs == NULL) goto relays; @@ -560,7 +562,7 @@ show(struct ctl_conn *c) } relays: if (env->sc_relays == NULL) - goto end; + goto routers; TAILQ_FOREACH(rlay, env->sc_relays, rl_entry) { rlay->rl_stats[env->sc_prefork_relay].id = EMPTY_ID; imsg_compose_event(&c->iev, IMSG_CTL_RELAY, 0, 0, -1, @@ -577,6 +579,27 @@ relays: imsg_compose_event(&c->iev, IMSG_CTL_HOST, 0, 0, -1, host, sizeof(*host)); } + +routers: + if (env->sc_rts == NULL) + goto end; + TAILQ_FOREACH(rt, env->sc_rts, rt_entry) { + imsg_compose_event(&c->iev, IMSG_CTL_ROUTER, 0, 0, -1, + rt, sizeof(*rt)); + if (rt->rt_conf.flags & F_DISABLE) + continue; + + TAILQ_FOREACH(nr, &rt->rt_netroutes, nr_entry) + imsg_compose_event(&c->iev, IMSG_CTL_NETROUTE, + 0, 0, -1, nr, sizeof(*nr)); + imsg_compose_event(&c->iev, IMSG_CTL_TABLE, 0, 0, -1, + rt->rt_gwtable, sizeof(*rt->rt_gwtable)); + if (!(rt->rt_gwtable->conf.flags & F_DISABLE)) + TAILQ_FOREACH(host, &rt->rt_gwtable->hosts, entry) + imsg_compose_event(&c->iev, IMSG_CTL_HOST, + 0, 0, -1, host, sizeof(*host)); + } + end: imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0); } diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 39513f95f7f..240f3dcd77b 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.130 2009/08/13 13:51:21 reyk Exp $ */ +/* $OpenBSD: relayd.h,v 1.131 2009/08/17 11:36:01 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -717,6 +717,8 @@ enum imsg_type { IMSG_CTL_HOST, IMSG_CTL_RELAY, IMSG_CTL_SESSION, + IMSG_CTL_ROUTER, + IMSG_CTL_NETROUTE, IMSG_CTL_TABLE_CHANGED, IMSG_CTL_PULL_RULESET, IMSG_CTL_PUSH_RULESET, |