summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/relayd/hce.c4
-rw-r--r--usr.sbin/relayd/parse.y5
-rw-r--r--usr.sbin/relayd/pfe.c4
-rw-r--r--usr.sbin/relayd/relay.c4
-rw-r--r--usr.sbin/relayd/relayd.c38
-rw-r--r--usr.sbin/relayd/relayd.h3
6 files changed, 42 insertions, 16 deletions
diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c
index bb0596e8a1f..ead5530a053 100644
--- a/usr.sbin/relayd/hce.c
+++ b/usr.sbin/relayd/hce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hce.c,v 1.61 2011/11/12 19:36:17 camield Exp $ */
+/* $OpenBSD: hce.c,v 1.62 2012/01/21 13:40:48 camield Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -355,6 +355,8 @@ hce_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
break;
case IMSG_CFG_DONE:
config_getcfg(env, imsg);
+ break;
+ case IMSG_CTL_START:
hce_setup_events();
break;
case IMSG_CTL_RESET:
diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y
index 37fa0da61e1..a6427c58b3f 100644
--- a/usr.sbin/relayd/parse.y
+++ b/usr.sbin/relayd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.160 2012/01/20 12:16:41 camield Exp $ */
+/* $OpenBSD: parse.y,v 1.161 2012/01/21 13:40:48 camield Exp $ */
/*
* Copyright (c) 2007-2011 Reyk Floeter <reyk@openbsd.org>
@@ -2262,9 +2262,6 @@ load_config(const char *filename, struct relayd *x_conf)
errors++;
}
- if (TAILQ_EMPTY(conf->sc_relays))
- conf->sc_prefork_relay = 0;
-
/* Cleanup relay list to inherit */
while ((rlay = TAILQ_FIRST(&relays)) != NULL) {
TAILQ_REMOVE(&relays, rlay, rl_entry);
diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c
index 3830d332b1a..c69bdf24894 100644
--- a/usr.sbin/relayd/pfe.c
+++ b/usr.sbin/relayd/pfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe.c,v 1.71 2011/11/12 19:36:17 camield Exp $ */
+/* $OpenBSD: pfe.c,v 1.72 2012/01/21 13:40:48 camield Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -203,6 +203,8 @@ pfe_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
config_getcfg(env, imsg);
init_filter(env, imsg->fd);
init_tables(env);
+ break;
+ case IMSG_CTL_START:
pfe_setup_events();
pfe_sync();
break;
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index 62ab44ea3fd..4962a0551b7 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.143 2011/09/21 18:45:40 bluhm Exp $ */
+/* $OpenBSD: relay.c,v 1.144 2012/01/21 13:40:48 camield Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -2577,6 +2577,8 @@ relay_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
break;
case IMSG_CFG_DONE:
config_getcfg(env, imsg);
+ break;
+ case IMSG_CTL_START:
relay_launch();
break;
case IMSG_CTL_RESET:
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index a3f8fea6397..141692c22e0 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.105 2012/01/20 12:16:41 camield Exp $ */
+/* $OpenBSD: relayd.c,v 1.106 2012/01/21 13:40:48 camield Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -49,6 +49,7 @@
__dead void usage(void);
int parent_configure(struct relayd *);
+void parent_configure_done(struct relayd *);
void parent_reload(struct relayd *, u_int, const char *);
void parent_sig_handler(int, short, void *);
void parent_shutdown(struct relayd *);
@@ -292,6 +293,9 @@ parent_configure(struct relayd *env)
TAILQ_FOREACH(rlay, env->sc_relays, rl_entry)
config_setrelay(env, rlay);
+ /* HCE, PFE and the preforked relays need to reload their config. */
+ env->sc_reload = 2 + env->sc_prefork_relay;
+
for (id = 0; id < PROC_MAX; id++) {
if (id == privsep_process)
continue;
@@ -308,7 +312,6 @@ parent_configure(struct relayd *env)
} else
s = -1;
- env->sc_reload++;
proc_compose_imsg(env->sc_ps, id, -1, IMSG_CFG_DONE, s,
&cf, sizeof(cf));
}
@@ -354,6 +357,28 @@ parent_reload(struct relayd *env, u_int reset, const char *filename)
}
void
+parent_configure_done(struct relayd *env)
+{
+ int id;
+
+ if (env->sc_reload == 0) {
+ log_warnx("%s: configuration already finished", __func__);
+ return;
+ }
+
+ env->sc_reload--;
+ if (env->sc_reload == 0) {
+ for (id = 0; id < PROC_MAX; id++) {
+ if (id == privsep_process)
+ continue;
+
+ proc_compose_imsg(env->sc_ps, id, -1, IMSG_CTL_START,
+ -1, NULL, 0);
+ }
+ }
+}
+
+void
parent_shutdown(struct relayd *env)
{
config_purge(env, CONFIG_ALL);
@@ -406,8 +431,7 @@ parent_dispatch_pfe(int fd, struct privsep_proc *p, struct imsg *imsg)
parent_shutdown(env);
break;
case IMSG_CFG_DONE:
- if (env->sc_reload)
- env->sc_reload--;
+ parent_configure_done(env);
break;
default:
return (-1);
@@ -435,8 +459,7 @@ parent_dispatch_hce(int fd, struct privsep_proc *p, struct imsg *imsg)
(void)snmp_setsock(env, p->p_id);
break;
case IMSG_CFG_DONE:
- if (env->sc_reload)
- env->sc_reload--;
+ parent_configure_done(env);
break;
default:
return (-1);
@@ -474,8 +497,7 @@ parent_dispatch_relay(int fd, struct privsep_proc *p, struct imsg *imsg)
IMSG_BINDANY, s, &bnd.bnd_id, sizeof(bnd.bnd_id));
break;
case IMSG_CFG_DONE:
- if (env->sc_reload)
- env->sc_reload--;
+ parent_configure_done(env);
break;
default:
return (-1);
diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h
index 3d540450486..35db7e1dad1 100644
--- a/usr.sbin/relayd/relayd.h
+++ b/usr.sbin/relayd/relayd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.h,v 1.151 2011/09/04 20:26:58 bluhm Exp $ */
+/* $OpenBSD: relayd.h,v 1.152 2012/01/21 13:40:48 camield Exp $ */
/*
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -742,6 +742,7 @@ enum imsg_type {
IMSG_CTL_HOST_ENABLE,
IMSG_CTL_HOST_DISABLE,
IMSG_CTL_SHUTDOWN,
+ IMSG_CTL_START,
IMSG_CTL_RELOAD,
IMSG_CTL_RESET,
IMSG_CTL_POLL,