Blame


1 6b5c4000 2026-03-02 rsadowski /* $OpenBSD: hce.c,v 1.83 2026/03/02 19:28:01 rsadowski Exp $ */
2 41042ecc 2006-12-16 reyk
3 41042ecc 2006-12-16 reyk /*
4 8c736326 2007-09-28 pyr * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
5 41042ecc 2006-12-16 reyk *
6 41042ecc 2006-12-16 reyk * Permission to use, copy, modify, and distribute this software for any
7 41042ecc 2006-12-16 reyk * purpose with or without fee is hereby granted, provided that the above
8 41042ecc 2006-12-16 reyk * copyright notice and this permission notice appear in all copies.
9 41042ecc 2006-12-16 reyk *
10 41042ecc 2006-12-16 reyk * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 41042ecc 2006-12-16 reyk * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 41042ecc 2006-12-16 reyk * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 41042ecc 2006-12-16 reyk * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 41042ecc 2006-12-16 reyk * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 41042ecc 2006-12-16 reyk * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 41042ecc 2006-12-16 reyk * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 41042ecc 2006-12-16 reyk */
18 41042ecc 2006-12-16 reyk
19 d93c36af 2015-01-22 reyk #include <sys/types.h>
20 e1f9d231 2007-11-24 reyk #include <sys/queue.h>
21 41042ecc 2006-12-16 reyk #include <sys/time.h>
22 d93c36af 2015-01-22 reyk #include <sys/uio.h>
23 e1f9d231 2007-11-24 reyk
24 41042ecc 2006-12-16 reyk #include <event.h>
25 41042ecc 2006-12-16 reyk #include <stdlib.h>
26 41042ecc 2006-12-16 reyk #include <string.h>
27 41042ecc 2006-12-16 reyk #include <unistd.h>
28 d93c36af 2015-01-22 reyk #include <imsg.h>
29 41042ecc 2006-12-16 reyk
30 6d0767ae 2007-12-07 reyk #include "relayd.h"
31 6b5c4000 2026-03-02 rsadowski #include "log.h"
32 41042ecc 2006-12-16 reyk
33 dbef7d4f 2011-05-09 reyk void hce_init(struct privsep *, struct privsep_proc *p, void *);
34 dbef7d4f 2011-05-09 reyk void hce_launch_checks(int, short, void *);
35 dbef7d4f 2011-05-09 reyk void hce_setup_events(void);
36 dbef7d4f 2011-05-09 reyk void hce_disable_events(void);
37 41042ecc 2006-12-16 reyk
38 dbef7d4f 2011-05-09 reyk int hce_dispatch_parent(int, struct privsep_proc *, struct imsg *);
39 dbef7d4f 2011-05-09 reyk int hce_dispatch_pfe(int, struct privsep_proc *, struct imsg *);
40 28bd28ce 2014-11-19 blambert int hce_dispatch_relay(int, struct privsep_proc *, struct imsg *);
41 dbef7d4f 2011-05-09 reyk
42 6d0767ae 2007-12-07 reyk static struct relayd *env = NULL;
43 c9f38bc1 2007-05-31 pyr int running = 0;
44 41042ecc 2006-12-16 reyk
45 dbef7d4f 2011-05-09 reyk static struct privsep_proc procs[] = {
46 dbef7d4f 2011-05-09 reyk { "parent", PROC_PARENT, hce_dispatch_parent },
47 dbef7d4f 2011-05-09 reyk { "pfe", PROC_PFE, hce_dispatch_pfe },
48 28bd28ce 2014-11-19 blambert { "relay", PROC_RELAY, hce_dispatch_relay },
49 dbef7d4f 2011-05-09 reyk };
50 41042ecc 2006-12-16 reyk
51 94404df8 2016-09-02 reyk void
52 dbef7d4f 2011-05-09 reyk hce(struct privsep *ps, struct privsep_proc *p)
53 41042ecc 2006-12-16 reyk {
54 dbef7d4f 2011-05-09 reyk env = ps->ps_env;
55 41042ecc 2006-12-16 reyk
56 816ddb53 2007-01-11 reyk /* this is needed for icmp tests */
57 816ddb53 2007-01-11 reyk icmp_init(env);
58 816ddb53 2007-01-11 reyk
59 94404df8 2016-09-02 reyk proc_run(ps, p, procs, nitems(procs), hce_init, NULL);
60 dbef7d4f 2011-05-09 reyk }
61 41042ecc 2006-12-16 reyk
62 dbef7d4f 2011-05-09 reyk void
63 dbef7d4f 2011-05-09 reyk hce_init(struct privsep *ps, struct privsep_proc *p, void *arg)
64 dbef7d4f 2011-05-09 reyk {
65 591e6ab5 2011-05-19 reyk if (config_init(ps->ps_env) == -1)
66 591e6ab5 2011-05-19 reyk fatal("failed to initialize configuration");
67 c9f38bc1 2007-05-31 pyr
68 dbef7d4f 2011-05-09 reyk env->sc_id = getpid() & 0xffff;
69 dbef7d4f 2011-05-09 reyk
70 ea47f1c4 2010-11-30 reyk /* Allow maximum available sockets for TCP checks */
71 ea47f1c4 2010-11-30 reyk socket_rlimit(-1);
72 d36fa7d2 2015-11-28 benno
73 41ddf20a 2016-09-03 reyk if (pledge("stdio recvfd inet", NULL) == -1)
74 09e53fee 2017-05-28 benno fatal("%s: pledge", __func__);
75 c9f38bc1 2007-05-31 pyr }
76 4ab45c57 2006-12-16 reyk
77 c9f38bc1 2007-05-31 pyr void
78 0b3f2e39 2007-05-31 pyr hce_setup_events(void)
79 c9f38bc1 2007-05-31 pyr {
80 c9f38bc1 2007-05-31 pyr struct timeval tv;
81 c9f38bc1 2007-05-31 pyr struct table *table;
82 c9f38bc1 2007-05-31 pyr
83 ebb0dc76 2017-12-18 benno if (!event_initialized(&env->sc_ev)) {
84 23fba4ad 2008-01-31 reyk evtimer_set(&env->sc_ev, hce_launch_checks, env);
85 30640247 2007-02-22 reyk bzero(&tv, sizeof(tv));
86 23fba4ad 2008-01-31 reyk evtimer_add(&env->sc_ev, &tv);
87 30640247 2007-02-22 reyk }
88 4ab45c57 2006-12-16 reyk
89 58fc320c 2016-09-02 reyk if (env->sc_conf.flags & F_TLS) {
90 23fba4ad 2008-01-31 reyk TAILQ_FOREACH(table, env->sc_tables, entry) {
91 096ff28b 2014-12-12 reyk if (!(table->conf.flags & F_TLS) ||
92 f4a6eef3 2017-05-27 claudio table->tls_cfg != NULL)
93 05982e1a 2007-01-29 pyr continue;
94 f4a6eef3 2017-05-27 claudio table->tls_cfg = tls_config_new();
95 277590d4 2022-06-03 tb if (table->tls_cfg == NULL)
96 277590d4 2022-06-03 tb fatalx("%s: tls_config_new", __func__);
97 f4a6eef3 2017-05-27 claudio tls_config_insecure_noverifycert(table->tls_cfg);
98 f4a6eef3 2017-05-27 claudio tls_config_insecure_noverifyname(table->tls_cfg);
99 05982e1a 2007-01-29 pyr }
100 05982e1a 2007-01-29 pyr }
101 41042ecc 2006-12-16 reyk }
102 41042ecc 2006-12-16 reyk
103 41042ecc 2006-12-16 reyk void
104 0b3f2e39 2007-05-31 pyr hce_disable_events(void)
105 0b3f2e39 2007-05-31 pyr {
106 0b3f2e39 2007-05-31 pyr struct table *table;
107 0b3f2e39 2007-05-31 pyr struct host *host;
108 0b3f2e39 2007-05-31 pyr
109 23fba4ad 2008-01-31 reyk evtimer_del(&env->sc_ev);
110 23fba4ad 2008-01-31 reyk TAILQ_FOREACH(table, env->sc_tables, entry) {
111 0b3f2e39 2007-05-31 pyr TAILQ_FOREACH(host, &table->hosts, entry) {
112 b2665266 2008-12-05 reyk host->he = HCE_ABORT;
113 591e6ab5 2011-05-19 reyk if (event_initialized(&host->cte.ev)) {
114 591e6ab5 2011-05-19 reyk event_del(&host->cte.ev);
115 591e6ab5 2011-05-19 reyk close(host->cte.s);
116 591e6ab5 2011-05-19 reyk }
117 0b3f2e39 2007-05-31 pyr }
118 0b3f2e39 2007-05-31 pyr }
119 23fba4ad 2008-01-31 reyk if (env->sc_has_icmp) {
120 23fba4ad 2008-01-31 reyk event_del(&env->sc_icmp_send.ev);
121 23fba4ad 2008-01-31 reyk event_del(&env->sc_icmp_recv.ev);
122 0b3f2e39 2007-05-31 pyr }
123 23fba4ad 2008-01-31 reyk if (env->sc_has_icmp6) {
124 23fba4ad 2008-01-31 reyk event_del(&env->sc_icmp6_send.ev);
125 23fba4ad 2008-01-31 reyk event_del(&env->sc_icmp6_recv.ev);
126 0b3f2e39 2007-05-31 pyr }
127 0b3f2e39 2007-05-31 pyr }
128 0b3f2e39 2007-05-31 pyr
129 0b3f2e39 2007-05-31 pyr void
130 41042ecc 2006-12-16 reyk hce_launch_checks(int fd, short event, void *arg)
131 41042ecc 2006-12-16 reyk {
132 4ab45c57 2006-12-16 reyk struct host *host;
133 4ab45c57 2006-12-16 reyk struct table *table;
134 816ddb53 2007-01-11 reyk struct timeval tv;
135 ae98db81 2006-12-25 reyk
136 816ddb53 2007-01-11 reyk /*
137 816ddb53 2007-01-11 reyk * notify pfe checks are done and schedule next check
138 816ddb53 2007-01-11 reyk */
139 141b9058 2015-12-02 reyk proc_compose(env->sc_ps, PROC_PFE, IMSG_SYNC, NULL, 0);
140 23fba4ad 2008-01-31 reyk TAILQ_FOREACH(table, env->sc_tables, entry) {
141 816ddb53 2007-01-11 reyk TAILQ_FOREACH(host, &table->hosts, entry) {
142 b2665266 2008-12-05 reyk if ((host->flags & F_CHECK_DONE) == 0)
143 b2665266 2008-12-05 reyk host->he = HCE_INTERVAL_TIMEOUT;
144 591e6ab5 2011-05-19 reyk if (event_initialized(&host->cte.ev)) {
145 591e6ab5 2011-05-19 reyk event_del(&host->cte.ev);
146 591e6ab5 2011-05-19 reyk close(host->cte.s);
147 591e6ab5 2011-05-19 reyk }
148 591e6ab5 2011-05-19 reyk host->cte.s = -1;
149 816ddb53 2007-01-11 reyk }
150 816ddb53 2007-01-11 reyk }
151 816ddb53 2007-01-11 reyk
152 b7f7a948 2013-03-10 reyk getmonotime(&tv);
153 816ddb53 2007-01-11 reyk
154 23fba4ad 2008-01-31 reyk TAILQ_FOREACH(table, env->sc_tables, entry) {
155 87178699 2007-05-27 pyr if (table->conf.flags & F_DISABLE)
156 ae98db81 2006-12-25 reyk continue;
157 182ad205 2007-11-20 pyr if (table->conf.skip_cnt) {
158 182ad205 2007-11-20 pyr if (table->skipped++ > table->conf.skip_cnt)
159 182ad205 2007-11-20 pyr table->skipped = 0;
160 182ad205 2007-11-20 pyr if (table->skipped != 1)
161 182ad205 2007-11-20 pyr continue;
162 182ad205 2007-11-20 pyr }
163 87178699 2007-05-27 pyr if (table->conf.check == CHECK_NOCHECK)
164 09e53fee 2017-05-28 benno fatalx("%s: unknown check type", __func__);
165 816ddb53 2007-01-11 reyk
166 ae98db81 2006-12-25 reyk TAILQ_FOREACH(host, &table->hosts, entry) {
167 17acabee 2008-07-19 reyk if (host->flags & F_DISABLE || host->conf.parentid)
168 ae98db81 2006-12-25 reyk continue;
169 27026d2a 2011-02-08 sthen bcopy(&tv, &host->cte.tv_start,
170 27026d2a 2011-02-08 sthen sizeof(host->cte.tv_start));
171 292100ef 2007-05-29 reyk switch (table->conf.check) {
172 292100ef 2007-05-29 reyk case CHECK_ICMP:
173 816ddb53 2007-01-11 reyk schedule_icmp(env, host);
174 292100ef 2007-05-29 reyk break;
175 292100ef 2007-05-29 reyk case CHECK_SCRIPT:
176 dbef7d4f 2011-05-09 reyk check_script(env, host);
177 292100ef 2007-05-29 reyk break;
178 292100ef 2007-05-29 reyk default:
179 292100ef 2007-05-29 reyk /* Any other TCP-style checks */
180 292100ef 2007-05-29 reyk host->last_up = host->up;
181 292100ef 2007-05-29 reyk host->cte.host = host;
182 292100ef 2007-05-29 reyk host->cte.table = table;
183 292100ef 2007-05-29 reyk check_tcp(&host->cte);
184 292100ef 2007-05-29 reyk break;
185 816ddb53 2007-01-11 reyk }
186 ae98db81 2006-12-25 reyk }
187 ae98db81 2006-12-25 reyk }
188 816ddb53 2007-01-11 reyk check_icmp(env, &tv);
189 816ddb53 2007-01-11 reyk
190 58fc320c 2016-09-02 reyk bcopy(&env->sc_conf.interval, &tv, sizeof(tv));
191 23fba4ad 2008-01-31 reyk evtimer_add(&env->sc_ev, &tv);
192 ae98db81 2006-12-25 reyk }
193 ae98db81 2006-12-25 reyk
194 ae98db81 2006-12-25 reyk void
195 b2665266 2008-12-05 reyk hce_notify_done(struct host *host, enum host_error he)
196 ae98db81 2006-12-25 reyk {
197 f802d393 2007-02-07 reyk struct table *table;
198 41042ecc 2006-12-16 reyk struct ctl_status st;
199 f802d393 2007-02-07 reyk struct timeval tv_now, tv_dur;
200 f802d393 2007-02-07 reyk u_long duration;
201 37ed6014 2018-08-06 benno u_int logopt = RELAYD_OPT_LOGHOSTCHECK;
202 8680b599 2012-05-09 giovanni struct host *h, *hostnst;
203 17acabee 2008-07-19 reyk int hostup;
204 b2665266 2008-12-05 reyk const char *msg;
205 e7687e91 2016-01-11 benno char *codemsg = NULL;
206 41042ecc 2006-12-16 reyk
207 8680b599 2012-05-09 giovanni if ((hostnst = host_find(env, host->conf.id)) == NULL)
208 09e53fee 2017-05-28 benno fatalx("%s: desynchronized", __func__);
209 8680b599 2012-05-09 giovanni
210 8680b599 2012-05-09 giovanni if ((table = table_find(env, host->conf.tableid)) == NULL)
211 09e53fee 2017-05-28 benno fatalx("%s: invalid table id", __func__);
212 8680b599 2012-05-09 giovanni
213 8680b599 2012-05-09 giovanni if (hostnst->flags & F_DISABLE) {
214 58fc320c 2016-09-02 reyk if (env->sc_conf.opts & RELAYD_OPT_LOGUPDATE) {
215 8680b599 2012-05-09 giovanni log_info("host %s, check %s%s (ignoring result, "
216 8680b599 2012-05-09 giovanni "host disabled)",
217 8680b599 2012-05-09 giovanni host->conf.name, table_check(table->conf.check),
218 096ff28b 2014-12-12 reyk (table->conf.flags & F_TLS) ? " use tls" : "");
219 8680b599 2012-05-09 giovanni }
220 8680b599 2012-05-09 giovanni host->flags |= (F_CHECK_SENT|F_CHECK_DONE);
221 8680b599 2012-05-09 giovanni return;
222 8680b599 2012-05-09 giovanni }
223 8680b599 2012-05-09 giovanni
224 17acabee 2008-07-19 reyk hostup = host->up;
225 b2665266 2008-12-05 reyk host->he = he;
226 17acabee 2008-07-19 reyk
227 30640247 2007-02-22 reyk if (host->up == HOST_DOWN && host->retry_cnt) {
228 666bd316 2011-05-05 reyk log_debug("%s: host %s retry %d", __func__,
229 87178699 2007-05-27 pyr host->conf.name, host->retry_cnt);
230 fc15ca4a 2007-03-06 reyk host->up = host->last_up;
231 30640247 2007-02-22 reyk host->retry_cnt--;
232 30640247 2007-02-22 reyk } else
233 87178699 2007-05-27 pyr host->retry_cnt = host->conf.retry;
234 30640247 2007-02-22 reyk if (host->up != HOST_UNKNOWN) {
235 30640247 2007-02-22 reyk host->check_cnt++;
236 30640247 2007-02-22 reyk if (host->up == HOST_UP)
237 30640247 2007-02-22 reyk host->up_cnt++;
238 30640247 2007-02-22 reyk }
239 87178699 2007-05-27 pyr st.id = host->conf.id;
240 ae98db81 2006-12-25 reyk st.up = host->up;
241 30640247 2007-02-22 reyk st.check_cnt = host->check_cnt;
242 30640247 2007-02-22 reyk st.retry_cnt = host->retry_cnt;
243 b2665266 2008-12-05 reyk st.he = he;
244 816ddb53 2007-01-11 reyk host->flags |= (F_CHECK_SENT|F_CHECK_DONE);
245 b2665266 2008-12-05 reyk msg = host_error(he);
246 ae98db81 2006-12-25 reyk if (msg)
247 666bd316 2011-05-05 reyk log_debug("%s: %s (%s)", __func__, host->conf.name, msg);
248 f802d393 2007-02-07 reyk
249 141b9058 2015-12-02 reyk proc_compose(env->sc_ps, PROC_PFE, IMSG_HOST_STATUS, &st, sizeof(st));
250 30640247 2007-02-22 reyk if (host->up != host->last_up)
251 6d0767ae 2007-12-07 reyk logopt = RELAYD_OPT_LOGUPDATE;
252 f802d393 2007-02-07 reyk
253 b7f7a948 2013-03-10 reyk getmonotime(&tv_now);
254 f802d393 2007-02-07 reyk timersub(&tv_now, &host->cte.tv_start, &tv_dur);
255 f802d393 2007-02-07 reyk if (timercmp(&host->cte.tv_start, &tv_dur, >))
256 f802d393 2007-02-07 reyk duration = (tv_dur.tv_sec * 1000) + (tv_dur.tv_usec / 1000.0);
257 f802d393 2007-02-07 reyk else
258 f802d393 2007-02-07 reyk duration = 0;
259 f802d393 2007-02-07 reyk
260 58fc320c 2016-09-02 reyk if (env->sc_conf.opts & logopt) {
261 e7687e91 2016-01-11 benno if (host->code > 0)
262 e7687e91 2016-01-11 benno asprintf(&codemsg, ",%d", host->code);
263 e7687e91 2016-01-11 benno log_info("host %s, check %s%s (%lums,%s%s), state %s -> %s, "
264 30640247 2007-02-22 reyk "availability %s",
265 87178699 2007-05-27 pyr host->conf.name, table_check(table->conf.check),
266 096ff28b 2014-12-12 reyk (table->conf.flags & F_TLS) ? " use tls" : "", duration,
267 e7687e91 2016-01-11 benno msg, (codemsg != NULL) ? codemsg : "",
268 30640247 2007-02-22 reyk host_status(host->last_up), host_status(host->up),
269 30640247 2007-02-22 reyk print_availability(host->check_cnt, host->up_cnt));
270 e7687e91 2016-01-11 benno free(codemsg);
271 ae98db81 2006-12-25 reyk }
272 21499093 2008-02-11 reyk
273 f802d393 2007-02-07 reyk host->last_up = host->up;
274 17acabee 2008-07-19 reyk
275 aebf7fd4 2008-07-19 reyk if (SLIST_EMPTY(&host->children))
276 17acabee 2008-07-19 reyk return;
277 17acabee 2008-07-19 reyk
278 17acabee 2008-07-19 reyk /* Notify for all other hosts that inherit the state from this one */
279 aebf7fd4 2008-07-19 reyk SLIST_FOREACH(h, &host->children, child) {
280 e8962295 2008-09-29 reyk h->up = hostup;
281 b2665266 2008-12-05 reyk hce_notify_done(h, he);
282 17acabee 2008-07-19 reyk }
283 41042ecc 2006-12-16 reyk }
284 41042ecc 2006-12-16 reyk
285 dbef7d4f 2011-05-09 reyk int
286 dbef7d4f 2011-05-09 reyk hce_dispatch_pfe(int fd, struct privsep_proc *p, struct imsg *imsg)
287 41042ecc 2006-12-16 reyk {
288 41042ecc 2006-12-16 reyk objid_t id;
289 41042ecc 2006-12-16 reyk struct host *host;
290 41042ecc 2006-12-16 reyk struct table *table;
291 41042ecc 2006-12-16 reyk
292 dbef7d4f 2011-05-09 reyk switch (imsg->hdr.type) {
293 dbef7d4f 2011-05-09 reyk case IMSG_HOST_DISABLE:
294 dbef7d4f 2011-05-09 reyk memcpy(&id, imsg->data, sizeof(id));
295 dbef7d4f 2011-05-09 reyk if ((host = host_find(env, id)) == NULL)
296 09e53fee 2017-05-28 benno fatalx("%s: desynchronized", __func__);
297 dbef7d4f 2011-05-09 reyk host->flags |= F_DISABLE;
298 dbef7d4f 2011-05-09 reyk host->up = HOST_UNKNOWN;
299 dbef7d4f 2011-05-09 reyk host->check_cnt = 0;
300 dbef7d4f 2011-05-09 reyk host->up_cnt = 0;
301 dbef7d4f 2011-05-09 reyk host->he = HCE_NONE;
302 dbef7d4f 2011-05-09 reyk break;
303 dbef7d4f 2011-05-09 reyk case IMSG_HOST_ENABLE:
304 dbef7d4f 2011-05-09 reyk memcpy(&id, imsg->data, sizeof(id));
305 dbef7d4f 2011-05-09 reyk if ((host = host_find(env, id)) == NULL)
306 09e53fee 2017-05-28 benno fatalx("%s: desynchronized", __func__);
307 dbef7d4f 2011-05-09 reyk host->flags &= ~(F_DISABLE);
308 dbef7d4f 2011-05-09 reyk host->up = HOST_UNKNOWN;
309 dbef7d4f 2011-05-09 reyk host->he = HCE_NONE;
310 dbef7d4f 2011-05-09 reyk break;
311 dbef7d4f 2011-05-09 reyk case IMSG_TABLE_DISABLE:
312 dbef7d4f 2011-05-09 reyk memcpy(&id, imsg->data, sizeof(id));
313 dbef7d4f 2011-05-09 reyk if ((table = table_find(env, id)) == NULL)
314 09e53fee 2017-05-28 benno fatalx("%s: desynchronized", __func__);
315 dbef7d4f 2011-05-09 reyk table->conf.flags |= F_DISABLE;
316 dbef7d4f 2011-05-09 reyk TAILQ_FOREACH(host, &table->hosts, entry)
317 41042ecc 2006-12-16 reyk host->up = HOST_UNKNOWN;
318 dbef7d4f 2011-05-09 reyk break;
319 dbef7d4f 2011-05-09 reyk case IMSG_TABLE_ENABLE:
320 dbef7d4f 2011-05-09 reyk memcpy(&id, imsg->data, sizeof(id));
321 dbef7d4f 2011-05-09 reyk if ((table = table_find(env, id)) == NULL)
322 09e53fee 2017-05-28 benno fatalx("%s: desynchronized", __func__);
323 dbef7d4f 2011-05-09 reyk table->conf.flags &= ~(F_DISABLE);
324 dbef7d4f 2011-05-09 reyk TAILQ_FOREACH(host, &table->hosts, entry)
325 41042ecc 2006-12-16 reyk host->up = HOST_UNKNOWN;
326 dbef7d4f 2011-05-09 reyk break;
327 dbef7d4f 2011-05-09 reyk case IMSG_CTL_POLL:
328 dbef7d4f 2011-05-09 reyk evtimer_del(&env->sc_ev);
329 dbef7d4f 2011-05-09 reyk TAILQ_FOREACH(table, env->sc_tables, entry)
330 dbef7d4f 2011-05-09 reyk table->skipped = 0;
331 dbef7d4f 2011-05-09 reyk hce_launch_checks(-1, EV_TIMEOUT, env);
332 dbef7d4f 2011-05-09 reyk break;
333 dbef7d4f 2011-05-09 reyk default:
334 dbef7d4f 2011-05-09 reyk return (-1);
335 41042ecc 2006-12-16 reyk }
336 dbef7d4f 2011-05-09 reyk
337 dbef7d4f 2011-05-09 reyk return (0);
338 41042ecc 2006-12-16 reyk }
339 41042ecc 2006-12-16 reyk
340 dbef7d4f 2011-05-09 reyk int
341 dbef7d4f 2011-05-09 reyk hce_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
342 41042ecc 2006-12-16 reyk {
343 292100ef 2007-05-29 reyk struct ctl_script scr;
344 6898e872 2007-06-07 pyr
345 dbef7d4f 2011-05-09 reyk switch (imsg->hdr.type) {
346 dbef7d4f 2011-05-09 reyk case IMSG_SCRIPT:
347 dbef7d4f 2011-05-09 reyk IMSG_SIZE_CHECK(imsg, &scr);
348 dbef7d4f 2011-05-09 reyk bcopy(imsg->data, &scr, sizeof(scr));
349 dbef7d4f 2011-05-09 reyk script_done(env, &scr);
350 dbef7d4f 2011-05-09 reyk break;
351 591e6ab5 2011-05-19 reyk case IMSG_CFG_TABLE:
352 591e6ab5 2011-05-19 reyk config_gettable(env, imsg);
353 dbef7d4f 2011-05-09 reyk break;
354 591e6ab5 2011-05-19 reyk case IMSG_CFG_HOST:
355 591e6ab5 2011-05-19 reyk config_gethost(env, imsg);
356 dbef7d4f 2011-05-09 reyk break;
357 591e6ab5 2011-05-19 reyk case IMSG_CFG_DONE:
358 591e6ab5 2011-05-19 reyk config_getcfg(env, imsg);
359 996c1f22 2012-01-21 camield break;
360 996c1f22 2012-01-21 camield case IMSG_CTL_START:
361 dbef7d4f 2011-05-09 reyk hce_setup_events();
362 dbef7d4f 2011-05-09 reyk break;
363 591e6ab5 2011-05-19 reyk case IMSG_CTL_RESET:
364 591e6ab5 2011-05-19 reyk config_getreset(env, imsg);
365 591e6ab5 2011-05-19 reyk break;
366 dbef7d4f 2011-05-09 reyk default:
367 dbef7d4f 2011-05-09 reyk return (-1);
368 4ab45c57 2006-12-16 reyk }
369 dbef7d4f 2011-05-09 reyk
370 dbef7d4f 2011-05-09 reyk return (0);
371 41042ecc 2006-12-16 reyk }
372 28bd28ce 2014-11-19 blambert
373 28bd28ce 2014-11-19 blambert int
374 28bd28ce 2014-11-19 blambert hce_dispatch_relay(int fd, struct privsep_proc *p, struct imsg *imsg)
375 28bd28ce 2014-11-19 blambert {
376 28bd28ce 2014-11-19 blambert switch (imsg->hdr.type) {
377 28bd28ce 2014-11-19 blambert default:
378 28bd28ce 2014-11-19 blambert break;
379 28bd28ce 2014-11-19 blambert }
380 28bd28ce 2014-11-19 blambert
381 28bd28ce 2014-11-19 blambert return (-1);
382 28bd28ce 2014-11-19 blambert }