diff options
author | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-10-19 12:08:56 +0000 |
---|---|---|
committer | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-10-19 12:08:56 +0000 |
commit | 1919128b52ab85cdce80c42468da3dd2c2e24cc8 (patch) | |
tree | 5017385397d80aa13d325e26392cbc6715f386e8 | |
parent | 606ce456a609f715d65446676b7212d3d4a28715 (diff) |
Add the ability to schedule an immediate check through hoststatectl.
Especially useful when interval is rather long.
I was supposed to commit this before 4.2.
-rw-r--r-- | usr.sbin/hoststatectl/hoststatectl.c | 6 | ||||
-rw-r--r-- | usr.sbin/hoststatectl/parser.c | 3 | ||||
-rw-r--r-- | usr.sbin/hoststatectl/parser.h | 3 | ||||
-rw-r--r-- | usr.sbin/hoststated/control.c | 13 | ||||
-rw-r--r-- | usr.sbin/hoststated/hce.c | 6 | ||||
-rw-r--r-- | usr.sbin/hoststated/hoststated.h | 5 | ||||
-rw-r--r-- | usr.sbin/hoststated/pfe.c | 4 | ||||
-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.c | 6 | ||||
-rw-r--r-- | usr.sbin/relayd/control.c | 13 | ||||
-rw-r--r-- | usr.sbin/relayd/hce.c | 6 | ||||
-rw-r--r-- | usr.sbin/relayd/pfe.c | 4 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 5 |
14 files changed, 58 insertions, 22 deletions
diff --git a/usr.sbin/hoststatectl/hoststatectl.c b/usr.sbin/hoststatectl/hoststatectl.c index f65247d9d48..d616df38344 100644 --- a/usr.sbin/hoststatectl/hoststatectl.c +++ b/usr.sbin/hoststatectl/hoststatectl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hoststatectl.c,v 1.24 2007/09/29 16:23:06 pyr Exp $ */ +/* $OpenBSD: hoststatectl.c,v 1.25 2007/10/19 12:08:54 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -177,6 +177,9 @@ main(int argc, char *argv[]) case SHUTDOWN: imsg_compose(ibuf, IMSG_CTL_SHUTDOWN, 0, 0, -1, NULL, 0); break; + case POLL: + imsg_compose(ibuf, IMSG_CTL_POLL, 0, 0, -1, NULL, 0); + break; case RELOAD: imsg_compose(ibuf, IMSG_CTL_RELOAD, 0, 0, -1, NULL, 0); break; @@ -215,6 +218,7 @@ main(int argc, char *argv[]) case TABLE_ENABLE: case HOST_DISABLE: case HOST_ENABLE: + case POLL: case RELOAD: case SHUTDOWN: done = show_command_output(&imsg); diff --git a/usr.sbin/hoststatectl/parser.c b/usr.sbin/hoststatectl/parser.c index dea2cb5f443..ee5451c8982 100644 --- a/usr.sbin/hoststatectl/parser.c +++ b/usr.sbin/hoststatectl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.13 2007/09/28 13:29:56 pyr Exp $ */ +/* $OpenBSD: parser.c,v 1.14 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -66,6 +66,7 @@ static const struct token t_host_id[]; static const struct token t_main[] = { {KEYWORD, "monitor", MONITOR, NULL}, {KEYWORD, "show", NULL, t_show}, + {KEYWORD, "poll", POLL, NULL}, {KEYWORD, "reload", RELOAD, NULL}, {KEYWORD, "stop", SHUTDOWN, NULL}, {KEYWORD, "service", NONE, t_service}, diff --git a/usr.sbin/hoststatectl/parser.h b/usr.sbin/hoststatectl/parser.h index 9d359dfd411..c9c1e875fd2 100644 --- a/usr.sbin/hoststatectl/parser.h +++ b/usr.sbin/hoststatectl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.6 2007/09/28 13:29:56 pyr Exp $ */ +/* $OpenBSD: parser.h,v 1.7 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -29,6 +29,7 @@ enum actions { HOST_DISABLE, HOST_ENABLE, SHUTDOWN, + POLL, RELOAD, MONITOR }; diff --git a/usr.sbin/hoststated/control.c b/usr.sbin/hoststated/control.c index 08094fe9547..5ea9d46fb02 100644 --- a/usr.sbin/hoststated/control.c +++ b/usr.sbin/hoststated/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.18 2007/09/07 08:20:24 reyk Exp $ */ +/* $OpenBSD: control.c,v 1.19 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -43,6 +43,7 @@ struct ctl_conn *control_connbyfd(int); void control_close(int); struct imsgbuf *ibuf_main = NULL; +struct imsgbuf *ibuf_hce = NULL; int control_init(void) @@ -94,10 +95,12 @@ control_init(void) } int -control_listen(struct hoststated *env, struct imsgbuf *ibuf) +control_listen(struct hoststated *env, struct imsgbuf *i_main, + struct imsgbuf *i_hce) { - ibuf_main = ibuf; + ibuf_main = i_main; + ibuf_hce = i_hce; if (listen(control_state.fd, CONTROL_BACKLOG) == -1) { log_warn("control_listen: listen"); @@ -316,6 +319,10 @@ control_dispatch_imsg(int fd, short event, void *arg) imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, NULL, 0); break; + case IMSG_CTL_POLL: + imsg_compose(ibuf_hce, IMSG_CTL_POLL, 0, 0,-1, NULL, 0); + imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0); + break; case IMSG_CTL_RELOAD: if (env->prefork_relay > 0) { imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, diff --git a/usr.sbin/hoststated/hce.c b/usr.sbin/hoststated/hce.c index 2c01db611bf..62a34e8b6e4 100644 --- a/usr.sbin/hoststated/hce.c +++ b/usr.sbin/hoststated/hce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hce.c,v 1.31 2007/10/12 12:50:59 blambert Exp $ */ +/* $OpenBSD: hce.c,v 1.32 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -395,6 +395,10 @@ hce_dispatch_imsg(int fd, short event, void *ptr) TAILQ_FOREACH(host, &table->hosts, entry) host->up = HOST_UNKNOWN; break; + case IMSG_CTL_POLL: + evtimer_del(&env->ev); + hce_launch_checks(-1, EV_TIMEOUT, env); + break; default: log_debug("hce_dispatch_msg: unexpected imsg %d", imsg.hdr.type); diff --git a/usr.sbin/hoststated/hoststated.h b/usr.sbin/hoststated/hoststated.h index f6c77880298..cc20e904474 100644 --- a/usr.sbin/hoststated/hoststated.h +++ b/usr.sbin/hoststated/hoststated.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hoststated.h,v 1.68 2007/10/12 12:50:59 blambert Exp $ */ +/* $OpenBSD: hoststated.h,v 1.69 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -118,6 +118,7 @@ enum imsg_type { IMSG_CTL_HOST_DISABLE, IMSG_CTL_SHUTDOWN, IMSG_CTL_RELOAD, + IMSG_CTL_POLL, IMSG_CTL_NOTIFY, IMSG_CTL_STATISTICS, IMSG_SERVICE_ENABLE, /* notifies from pfe to hce */ @@ -628,7 +629,7 @@ TAILQ_HEAD(ctl_connlist, ctl_conn); /* control.c */ int control_init(void); -int control_listen(struct hoststated *, struct imsgbuf *); +int control_listen(struct hoststated *, struct imsgbuf *, struct imsgbuf *); void control_accept(int, short, void *); void control_dispatch_imsg(int, short, void *); void control_imsg_forward(struct imsg *); diff --git a/usr.sbin/hoststated/pfe.c b/usr.sbin/hoststated/pfe.c index 6b27a81df4f..29451e4cdfe 100644 --- a/usr.sbin/hoststated/pfe.c +++ b/usr.sbin/hoststated/pfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfe.c,v 1.36 2007/09/28 13:29:56 pyr Exp $ */ +/* $OpenBSD: pfe.c,v 1.37 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -156,7 +156,7 @@ pfe(struct hoststated *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2], TAILQ_INIT(&ctl_conns); - if (control_listen(env, ibuf_main) == -1) + if (control_listen(env, ibuf_main, ibuf_hce) == -1) fatalx("pfe: control socket listen failed"); /* Initial sync */ diff --git a/usr.sbin/relayctl/parser.c b/usr.sbin/relayctl/parser.c index dea2cb5f443..ee5451c8982 100644 --- a/usr.sbin/relayctl/parser.c +++ b/usr.sbin/relayctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.13 2007/09/28 13:29:56 pyr Exp $ */ +/* $OpenBSD: parser.c,v 1.14 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -66,6 +66,7 @@ static const struct token t_host_id[]; static const struct token t_main[] = { {KEYWORD, "monitor", MONITOR, NULL}, {KEYWORD, "show", NULL, t_show}, + {KEYWORD, "poll", POLL, NULL}, {KEYWORD, "reload", RELOAD, NULL}, {KEYWORD, "stop", SHUTDOWN, NULL}, {KEYWORD, "service", NONE, t_service}, diff --git a/usr.sbin/relayctl/parser.h b/usr.sbin/relayctl/parser.h index 9d359dfd411..c9c1e875fd2 100644 --- a/usr.sbin/relayctl/parser.h +++ b/usr.sbin/relayctl/parser.h @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.h,v 1.6 2007/09/28 13:29:56 pyr Exp $ */ +/* $OpenBSD: parser.h,v 1.7 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -29,6 +29,7 @@ enum actions { HOST_DISABLE, HOST_ENABLE, SHUTDOWN, + POLL, RELOAD, MONITOR }; diff --git a/usr.sbin/relayctl/relayctl.c b/usr.sbin/relayctl/relayctl.c index d66c82ce74e..0c67a694602 100644 --- a/usr.sbin/relayctl/relayctl.c +++ b/usr.sbin/relayctl/relayctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayctl.c,v 1.24 2007/09/29 16:23:06 pyr Exp $ */ +/* $OpenBSD: relayctl.c,v 1.25 2007/10/19 12:08:54 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -177,6 +177,9 @@ main(int argc, char *argv[]) case SHUTDOWN: imsg_compose(ibuf, IMSG_CTL_SHUTDOWN, 0, 0, -1, NULL, 0); break; + case POLL: + imsg_compose(ibuf, IMSG_CTL_POLL, 0, 0, -1, NULL, 0); + break; case RELOAD: imsg_compose(ibuf, IMSG_CTL_RELOAD, 0, 0, -1, NULL, 0); break; @@ -215,6 +218,7 @@ main(int argc, char *argv[]) case TABLE_ENABLE: case HOST_DISABLE: case HOST_ENABLE: + case POLL: case RELOAD: case SHUTDOWN: done = show_command_output(&imsg); diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c index 08094fe9547..5ea9d46fb02 100644 --- a/usr.sbin/relayd/control.c +++ b/usr.sbin/relayd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.18 2007/09/07 08:20:24 reyk Exp $ */ +/* $OpenBSD: control.c,v 1.19 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -43,6 +43,7 @@ struct ctl_conn *control_connbyfd(int); void control_close(int); struct imsgbuf *ibuf_main = NULL; +struct imsgbuf *ibuf_hce = NULL; int control_init(void) @@ -94,10 +95,12 @@ control_init(void) } int -control_listen(struct hoststated *env, struct imsgbuf *ibuf) +control_listen(struct hoststated *env, struct imsgbuf *i_main, + struct imsgbuf *i_hce) { - ibuf_main = ibuf; + ibuf_main = i_main; + ibuf_hce = i_hce; if (listen(control_state.fd, CONTROL_BACKLOG) == -1) { log_warn("control_listen: listen"); @@ -316,6 +319,10 @@ control_dispatch_imsg(int fd, short event, void *arg) imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, NULL, 0); break; + case IMSG_CTL_POLL: + imsg_compose(ibuf_hce, IMSG_CTL_POLL, 0, 0,-1, NULL, 0); + imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0); + break; case IMSG_CTL_RELOAD: if (env->prefork_relay > 0) { imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c index 2c01db611bf..62a34e8b6e4 100644 --- a/usr.sbin/relayd/hce.c +++ b/usr.sbin/relayd/hce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hce.c,v 1.31 2007/10/12 12:50:59 blambert Exp $ */ +/* $OpenBSD: hce.c,v 1.32 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -395,6 +395,10 @@ hce_dispatch_imsg(int fd, short event, void *ptr) TAILQ_FOREACH(host, &table->hosts, entry) host->up = HOST_UNKNOWN; break; + case IMSG_CTL_POLL: + evtimer_del(&env->ev); + hce_launch_checks(-1, EV_TIMEOUT, env); + break; default: log_debug("hce_dispatch_msg: unexpected imsg %d", imsg.hdr.type); diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c index 6b27a81df4f..29451e4cdfe 100644 --- a/usr.sbin/relayd/pfe.c +++ b/usr.sbin/relayd/pfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfe.c,v 1.36 2007/09/28 13:29:56 pyr Exp $ */ +/* $OpenBSD: pfe.c,v 1.37 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -156,7 +156,7 @@ pfe(struct hoststated *x_env, int pipe_parent2pfe[2], int pipe_parent2hce[2], TAILQ_INIT(&ctl_conns); - if (control_listen(env, ibuf_main) == -1) + if (control_listen(env, ibuf_main, ibuf_hce) == -1) fatalx("pfe: control socket listen failed"); /* Initial sync */ diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 35a8c9840ce..cdb4b501699 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.68 2007/10/12 12:50:59 blambert Exp $ */ +/* $OpenBSD: relayd.h,v 1.69 2007/10/19 12:08:55 pyr Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -118,6 +118,7 @@ enum imsg_type { IMSG_CTL_HOST_DISABLE, IMSG_CTL_SHUTDOWN, IMSG_CTL_RELOAD, + IMSG_CTL_POLL, IMSG_CTL_NOTIFY, IMSG_CTL_STATISTICS, IMSG_SERVICE_ENABLE, /* notifies from pfe to hce */ @@ -628,7 +629,7 @@ TAILQ_HEAD(ctl_connlist, ctl_conn); /* control.c */ int control_init(void); -int control_listen(struct hoststated *, struct imsgbuf *); +int control_listen(struct hoststated *, struct imsgbuf *, struct imsgbuf *); void control_accept(int, short, void *); void control_dispatch_imsg(int, short, void *); void control_imsg_forward(struct imsg *); |