summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/relayd/check_script.c4
-rw-r--r--usr.sbin/relayd/control.c42
-rw-r--r--usr.sbin/relayd/hce.c6
-rw-r--r--usr.sbin/relayd/imsg.c3
-rw-r--r--usr.sbin/relayd/imsg.h3
-rw-r--r--usr.sbin/relayd/pfe.c48
-rw-r--r--usr.sbin/relayd/relay.c14
-rw-r--r--usr.sbin/relayd/relay_udp.c4
-rw-r--r--usr.sbin/relayd/relayd.c46
-rw-r--r--usr.sbin/relayd/relayd.h5
-rw-r--r--usr.sbin/relayd/snmp.c15
11 files changed, 102 insertions, 88 deletions
diff --git a/usr.sbin/relayd/check_script.c b/usr.sbin/relayd/check_script.c
index 76c90ab4114..ce8956ba62c 100644
--- a/usr.sbin/relayd/check_script.c
+++ b/usr.sbin/relayd/check_script.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: check_script.c,v 1.8 2009/04/17 09:58:40 reyk Exp $ */
+/* $OpenBSD: check_script.c,v 1.9 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -51,7 +51,7 @@ check_script(struct host *host)
host->flags &= ~(F_CHECK_SENT|F_CHECK_DONE);
scr.host = host->conf.id;
- imsg_compose(ibuf_main, IMSG_SCRIPT, 0, 0, -1, &scr, sizeof(scr));
+ imsg_compose_event(ibuf_main, IMSG_SCRIPT, 0, 0, -1, &scr, sizeof(scr));
}
void
diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c
index 12811b36bed..33124defa88 100644
--- a/usr.sbin/relayd/control.c
+++ b/usr.sbin/relayd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.29 2009/06/03 19:59:48 eric Exp $ */
+/* $OpenBSD: control.c,v 1.30 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -237,12 +237,12 @@ control_dispatch_imsg(int fd, short event, void *arg)
fatalx("invalid imsg header len");
memcpy(&id, imsg.data, sizeof(id));
if (disable_rdr(c, &id))
- imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
NULL, 0);
else {
memcpy(imsg.data, &id, sizeof(id));
control_imsg_forward(&imsg);
- imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
NULL, 0);
}
break;
@@ -251,12 +251,12 @@ control_dispatch_imsg(int fd, short event, void *arg)
fatalx("invalid imsg header len");
memcpy(&id, imsg.data, sizeof(id));
if (enable_rdr(c, &id))
- imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
NULL, 0);
else {
memcpy(imsg.data, &id, sizeof(id));
control_imsg_forward(&imsg);
- imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
NULL, 0);
}
break;
@@ -265,12 +265,12 @@ control_dispatch_imsg(int fd, short event, void *arg)
fatalx("invalid imsg header len");
memcpy(&id, imsg.data, sizeof(id));
if (disable_table(c, &id))
- imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
NULL, 0);
else {
memcpy(imsg.data, &id, sizeof(id));
control_imsg_forward(&imsg);
- imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
NULL, 0);
}
break;
@@ -279,12 +279,12 @@ control_dispatch_imsg(int fd, short event, void *arg)
fatalx("invalid imsg header len");
memcpy(&id, imsg.data, sizeof(id));
if (enable_table(c, &id))
- imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
NULL, 0);
else {
memcpy(imsg.data, &id, sizeof(id));
control_imsg_forward(&imsg);
- imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
NULL, 0);
}
break;
@@ -293,12 +293,12 @@ control_dispatch_imsg(int fd, short event, void *arg)
fatalx("invalid imsg header len");
memcpy(&id, imsg.data, sizeof(id));
if (disable_host(c, &id, NULL))
- imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
NULL, 0);
else {
memcpy(imsg.data, &id, sizeof(id));
control_imsg_forward(&imsg);
- imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
NULL, 0);
}
break;
@@ -307,30 +307,30 @@ control_dispatch_imsg(int fd, short event, void *arg)
fatalx("invalid imsg header len");
memcpy(&id, imsg.data, sizeof(id));
if (enable_host(c, &id, NULL))
- imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
NULL, 0);
else {
memcpy(imsg.data, &id, sizeof(id));
control_imsg_forward(&imsg);
- imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_OK, 0, 0, -1,
NULL, 0);
}
break;
case IMSG_CTL_SHUTDOWN:
- imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, NULL,
+ imsg_compose_event(&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);
+ imsg_compose_event(ibuf_hce, IMSG_CTL_POLL, 0, 0,-1, NULL, 0);
+ imsg_compose_event(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
break;
case IMSG_CTL_RELOAD:
if (env->sc_prefork_relay > 0) {
- imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
NULL, 0);
break;
}
- imsg_compose(ibuf_main, IMSG_CTL_RELOAD, 0, 0, -1, NULL,
+ imsg_compose_event(ibuf_main, IMSG_CTL_RELOAD, 0, 0, -1, NULL,
0);
/*
* we unconditionnaly return a CTL_OK imsg because
@@ -340,13 +340,13 @@ control_dispatch_imsg(int fd, short event, void *arg)
* that the reload command has been set,
* it doesn't say wether the command succeeded or not.
*/
- imsg_compose(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&c->ibuf, IMSG_CTL_OK, 0, 0, -1, NULL, 0);
break;
case IMSG_CTL_NOTIFY:
if (c->flags & CTL_CONN_NOTIFY) {
log_debug("control_dispatch_imsg: "
"client requested notify more than once");
- imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1,
NULL, 0);
break;
}
@@ -370,7 +370,7 @@ control_imsg_forward(struct imsg *imsg)
TAILQ_FOREACH(c, &ctl_conns, entry)
if (c->flags & CTL_CONN_NOTIFY)
- imsg_compose(&c->ibuf, imsg->hdr.type, 0, imsg->hdr.pid,
+ imsg_compose_event(&c->ibuf, imsg->hdr.type, 0, imsg->hdr.pid,
-1, imsg->data, imsg->hdr.len - IMSG_HEADER_SIZE);
}
diff --git a/usr.sbin/relayd/hce.c b/usr.sbin/relayd/hce.c
index 60c448465ca..25013575e28 100644
--- a/usr.sbin/relayd/hce.c
+++ b/usr.sbin/relayd/hce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hce.c,v 1.50 2009/06/04 13:46:07 reyk Exp $ */
+/* $OpenBSD: hce.c,v 1.51 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -217,7 +217,7 @@ hce_launch_checks(int fd, short event, void *arg)
/*
* notify pfe checks are done and schedule next check
*/
- imsg_compose(ibuf_pfe, IMSG_SYNC, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf_pfe, IMSG_SYNC, 0, 0, -1, NULL, 0);
TAILQ_FOREACH(table, env->sc_tables, entry) {
TAILQ_FOREACH(host, &table->hosts, entry) {
if ((host->flags & F_CHECK_DONE) == 0)
@@ -307,7 +307,7 @@ hce_notify_done(struct host *host, enum host_error he)
if (msg)
log_debug("hce_notify_done: %s (%s)", host->conf.name, msg);
- imsg_compose(ibuf_pfe, IMSG_HOST_STATUS, 0, 0, -1, &st, sizeof(st));
+ imsg_compose_event(ibuf_pfe, IMSG_HOST_STATUS, 0, 0, -1, &st, sizeof(st));
if (host->up != host->last_up)
logopt = RELAYD_OPT_LOGUPDATE;
else
diff --git a/usr.sbin/relayd/imsg.c b/usr.sbin/relayd/imsg.c
index 79001f7fd96..8cfc017cab0 100644
--- a/usr.sbin/relayd/imsg.c
+++ b/usr.sbin/relayd/imsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imsg.c,v 1.21 2009/06/04 23:33:49 pyr Exp $ */
+/* $OpenBSD: imsg.c,v 1.22 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -216,7 +216,6 @@ imsg_close(struct imsgbuf *ibuf, struct buf *msg)
hdr = (struct imsg_hdr *)msg->buf;
hdr->len = (u_int16_t)msg->wpos;
buf_close(&ibuf->w, msg);
- imsg_event_add(ibuf);
}
void
diff --git a/usr.sbin/relayd/imsg.h b/usr.sbin/relayd/imsg.h
index d87e8a8020a..45ad65a2ca7 100644
--- a/usr.sbin/relayd/imsg.h
+++ b/usr.sbin/relayd/imsg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: imsg.h,v 1.4 2009/06/04 23:33:49 pyr Exp $ */
+/* $OpenBSD: imsg.h,v 1.5 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -103,7 +103,6 @@ struct buf *imsg_create(struct imsgbuf *, u_int16_t, u_int32_t, pid_t,
int imsg_add(struct buf *, void *, u_int16_t);
void imsg_close(struct imsgbuf *, struct buf *);
void imsg_free(struct imsg *);
-void imsg_event_add(struct imsgbuf *); /* needs to be provided externally */
int imsg_get_fd(struct imsgbuf *);
int imsg_flush(struct imsgbuf *);
void imsg_clear(struct imsgbuf *);
diff --git a/usr.sbin/relayd/pfe.c b/usr.sbin/relayd/pfe.c
index ba926dbb9f4..166e257a54a 100644
--- a/usr.sbin/relayd/pfe.c
+++ b/usr.sbin/relayd/pfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfe.c,v 1.57 2009/06/02 12:24:16 reyk Exp $ */
+/* $OpenBSD: pfe.c,v 1.58 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -280,7 +280,7 @@ pfe_dispatch_imsg(int fd, short event, void *ptr)
/* Forward to relay engine(s) */
for (n = 0; n < env->sc_prefork_relay; n++)
- imsg_compose(&ibuf_relay[n],
+ imsg_compose_event(&ibuf_relay[n],
IMSG_HOST_STATUS, 0, 0, -1, &st,
sizeof(st));
@@ -489,7 +489,7 @@ pfe_dispatch_relay(int fd, short event, void * ptr)
"invalid relay proc");
if (natlook(env, &cnl) != 0)
cnl.in = -1;
- imsg_compose(&ibuf_relay[cnl.proc], IMSG_NATLOOK, 0, 0,
+ imsg_compose_event(&ibuf_relay[cnl.proc], IMSG_NATLOOK, 0, 0,
-1, &cnl, sizeof(cnl));
break;
case IMSG_STATISTICS:
@@ -525,28 +525,28 @@ show(struct ctl_conn *c)
if (env->sc_rdrs == NULL)
goto relays;
TAILQ_FOREACH(rdr, env->sc_rdrs, entry) {
- imsg_compose(&c->ibuf, IMSG_CTL_RDR, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_RDR, 0, 0, -1,
rdr, sizeof(*rdr));
if (rdr->conf.flags & F_DISABLE)
continue;
- imsg_compose(&c->ibuf, IMSG_CTL_RDR_STATS, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_RDR_STATS, 0, 0, -1,
&rdr->stats, sizeof(rdr->stats));
- imsg_compose(&c->ibuf, IMSG_CTL_TABLE, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_TABLE, 0, 0, -1,
rdr->table, sizeof(*rdr->table));
if (!(rdr->table->conf.flags & F_DISABLE))
TAILQ_FOREACH(host, &rdr->table->hosts, entry)
- imsg_compose(&c->ibuf, IMSG_CTL_HOST, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_HOST, 0, 0, -1,
host, sizeof(*host));
if (rdr->backup->conf.id == EMPTY_TABLE)
continue;
- imsg_compose(&c->ibuf, IMSG_CTL_TABLE, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_TABLE, 0, 0, -1,
rdr->backup, sizeof(*rdr->backup));
if (!(rdr->backup->conf.flags & F_DISABLE))
TAILQ_FOREACH(host, &rdr->backup->hosts, entry)
- imsg_compose(&c->ibuf, IMSG_CTL_HOST, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_HOST, 0, 0, -1,
host, sizeof(*host));
}
relays:
@@ -554,22 +554,22 @@ relays:
goto end;
TAILQ_FOREACH(rlay, env->sc_relays, rl_entry) {
rlay->rl_stats[env->sc_prefork_relay].id = EMPTY_ID;
- imsg_compose(&c->ibuf, IMSG_CTL_RELAY, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_RELAY, 0, 0, -1,
rlay, sizeof(*rlay));
- imsg_compose(&c->ibuf, IMSG_CTL_RELAY_STATS, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_RELAY_STATS, 0, 0, -1,
&rlay->rl_stats, sizeof(rlay->rl_stats));
if (rlay->rl_dsttable == NULL)
continue;
- imsg_compose(&c->ibuf, IMSG_CTL_TABLE, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_TABLE, 0, 0, -1,
rlay->rl_dsttable, sizeof(*rlay->rl_dsttable));
if (!(rlay->rl_dsttable->conf.flags & F_DISABLE))
TAILQ_FOREACH(host, &rlay->rl_dsttable->hosts, entry)
- imsg_compose(&c->ibuf, IMSG_CTL_HOST, 0, 0, -1,
+ imsg_compose_event(&c->ibuf, IMSG_CTL_HOST, 0, 0, -1,
host, sizeof(*host));
}
end:
- imsg_compose(&c->ibuf, IMSG_CTL_END, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&c->ibuf, IMSG_CTL_END, 0, 0, -1, NULL, 0);
}
void
@@ -582,7 +582,7 @@ show_sessions(struct ctl_conn *c)
/*
* Request all the running sessions from the process
*/
- imsg_compose(&ibuf_relay[proc],
+ imsg_compose_event(&ibuf_relay[proc],
IMSG_CTL_SESSION, 0, 0, -1, NULL, 0);
while (ibuf_relay[proc].w.queued)
if (msgbuf_write(&ibuf_relay[proc].w) < 0)
@@ -606,7 +606,7 @@ show_sessions(struct ctl_conn *c)
break;
switch (imsg.hdr.type) {
case IMSG_CTL_SESSION:
- imsg_compose(&c->ibuf,
+ imsg_compose_event(&c->ibuf,
IMSG_CTL_SESSION, proc, 0, -1,
imsg.data, sizeof(struct session));
break;
@@ -622,7 +622,7 @@ show_sessions(struct ctl_conn *c)
}
}
- imsg_compose(&c->ibuf, IMSG_CTL_END, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&c->ibuf, IMSG_CTL_END, 0, 0, -1, NULL, 0);
}
int
@@ -709,7 +709,7 @@ disable_table(struct ctl_conn *c, struct ctl_id *id)
table->up = 0;
TAILQ_FOREACH(host, &table->hosts, entry)
host->up = HOST_UNKNOWN;
- imsg_compose(ibuf_hce, IMSG_TABLE_DISABLE, 0, 0, -1,
+ imsg_compose_event(ibuf_hce, IMSG_TABLE_DISABLE, 0, 0, -1,
&table->conf.id, sizeof(table->conf.id));
log_debug("disable_table: disabled table %d", table->conf.id);
pfe_sync();
@@ -741,7 +741,7 @@ enable_table(struct ctl_conn *c, struct ctl_id *id)
table->up = 0;
TAILQ_FOREACH(host, &table->hosts, entry)
host->up = HOST_UNKNOWN;
- imsg_compose(ibuf_hce, IMSG_TABLE_ENABLE, 0, 0, -1,
+ imsg_compose_event(ibuf_hce, IMSG_TABLE_ENABLE, 0, 0, -1,
&table->conf.id, sizeof(table->conf.id));
log_debug("enable_table: enabled table %d", table->conf.id);
pfe_sync();
@@ -782,11 +782,11 @@ disable_host(struct ctl_conn *c, struct ctl_id *id, struct host *host)
host->check_cnt = 0;
host->up_cnt = 0;
- imsg_compose(ibuf_hce, IMSG_HOST_DISABLE, 0, 0, -1,
+ imsg_compose_event(ibuf_hce, IMSG_HOST_DISABLE, 0, 0, -1,
&host->conf.id, sizeof(host->conf.id));
/* Forward to relay engine(s) */
for (n = 0; n < env->sc_prefork_relay; n++)
- imsg_compose(&ibuf_relay[n],
+ imsg_compose_event(&ibuf_relay[n],
IMSG_HOST_DISABLE, 0, 0, -1,
&host->conf.id, sizeof(host->conf.id));
log_debug("disable_host: disabled host %d", host->conf.id);
@@ -824,11 +824,11 @@ enable_host(struct ctl_conn *c, struct ctl_id *id, struct host *host)
host->flags &= ~(F_DEL);
host->flags &= ~(F_ADD);
- imsg_compose(ibuf_hce, IMSG_HOST_ENABLE, 0, 0, -1,
+ imsg_compose_event(ibuf_hce, IMSG_HOST_ENABLE, 0, 0, -1,
&host->conf.id, sizeof (host->conf.id));
/* Forward to relay engine(s) */
for (n = 0; n < env->sc_prefork_relay; n++)
- imsg_compose(&ibuf_relay[n],
+ imsg_compose_event(&ibuf_relay[n],
IMSG_HOST_ENABLE, 0, 0, -1,
&host->conf.id, sizeof(host->conf.id));
log_debug("enable_host: enabled host %d", host->conf.id);
@@ -931,7 +931,7 @@ pfe_sync(void)
demote.level, table->conf.name, table->conf.demote_group);
(void)strlcpy(demote.group, table->conf.demote_group,
sizeof(demote.group));
- imsg_compose(ibuf_main, IMSG_DEMOTE, 0, 0, -1,
+ imsg_compose_event(ibuf_main, IMSG_DEMOTE, 0, 0, -1,
&demote, sizeof(demote));
}
}
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index f1e4a29e1f2..769af1fc32b 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.112 2009/06/02 12:24:16 reyk Exp $ */
+/* $OpenBSD: relay.c,v 1.113 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -556,7 +556,7 @@ relay_statistics(int fd, short events, void *arg)
crs.id = rlay->rl_conf.id;
crs.proc = proc_id;
- imsg_compose(ibuf_pfe, IMSG_STATISTICS, 0, 0, -1,
+ imsg_compose_event(ibuf_pfe, IMSG_STATISTICS, 0, 0, -1,
&crs, sizeof(crs));
for (con = SPLAY_ROOT(&rlay->rl_sessions);
@@ -2042,7 +2042,7 @@ relay_accept(int fd, short sig, void *arg)
return;
}
- imsg_compose(ibuf_pfe, IMSG_NATLOOK, 0, 0, -1, cnl,
+ imsg_compose_event(ibuf_pfe, IMSG_NATLOOK, 0, 0, -1, cnl,
sizeof(*cnl));
/* Schedule timeout */
@@ -2220,7 +2220,7 @@ relay_bindanyreq(struct session *con, in_port_t port, int proto)
bnd.bnd_port = port;
bnd.bnd_proto = proto;
bcopy(&con->se_in.ss, &bnd.bnd_ss, sizeof(bnd.bnd_ss));
- imsg_compose(ibuf_main, IMSG_BINDANY, 0, 0, -1, &bnd, sizeof(bnd));
+ imsg_compose_event(ibuf_main, IMSG_BINDANY, 0, 0, -1, &bnd, sizeof(bnd));
/* Schedule timeout */
evtimer_set(&con->se_ev, relay_bindany, con);
@@ -2378,7 +2378,7 @@ relay_close(struct session *con, const char *msg)
if (con->se_cnl != NULL) {
#if 0
- imsg_compose(ibuf_pfe, IMSG_KILLSTATES, 0, 0, -1,
+ imsg_compose_event(ibuf_pfe, IMSG_KILLSTATES, 0, 0, -1,
cnl, sizeof(*cnl));
#endif
free(con->se_cnl);
@@ -2498,9 +2498,9 @@ relay_dispatch_pfe(int fd, short event, void *ptr)
TAILQ_FOREACH(rlay, env->sc_relays, rl_entry)
SPLAY_FOREACH(con, session_tree,
&rlay->rl_sessions)
- imsg_compose(ibuf, IMSG_CTL_SESSION,
+ imsg_compose_event(ibuf, IMSG_CTL_SESSION,
0, 0, -1, con, sizeof(*con));
- imsg_compose(ibuf, IMSG_CTL_END, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf, IMSG_CTL_END, 0, 0, -1, NULL, 0);
break;
default:
log_debug("relay_dispatch_msg: unexpected imsg %d",
diff --git a/usr.sbin/relayd/relay_udp.c b/usr.sbin/relayd/relay_udp.c
index 348707c4108..f323807268b 100644
--- a/usr.sbin/relayd/relay_udp.c
+++ b/usr.sbin/relayd/relay_udp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay_udp.c,v 1.18 2008/09/29 15:12:22 reyk Exp $ */
+/* $OpenBSD: relay_udp.c,v 1.19 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -321,7 +321,7 @@ relay_udp_server(int fd, short sig, void *arg)
cnl->proto = IPPROTO_UDP;
bcopy(&con->se_in.ss, &cnl->src, sizeof(cnl->src));
bcopy(&rlay->rl_conf.ss, &cnl->dst, sizeof(cnl->dst));
- imsg_compose(ibuf_pfe, IMSG_NATLOOK, 0, 0, -1, cnl,
+ imsg_compose_event(ibuf_pfe, IMSG_NATLOOK, 0, 0, -1, cnl,
sizeof(*cnl));
/* Schedule timeout */
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index c6eceda53ec..4c2b999bcb6 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.86 2009/06/04 13:46:07 reyk Exp $ */
+/* $OpenBSD: relayd.c,v 1.87 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -347,12 +347,12 @@ send_all(struct relayd *env, enum imsg_type type, void *buf, u_int16_t len)
{
int i;
- if (imsg_compose(ibuf_pfe, type, 0, 0, -1, buf, len) == -1)
+ if (imsg_compose_event(ibuf_pfe, type, 0, 0, -1, buf, len) == -1)
return (-1);
- if (imsg_compose(ibuf_hce, type, 0, 0, -1, buf, len) == -1)
+ if (imsg_compose_event(ibuf_hce, type, 0, 0, -1, buf, len) == -1)
return (-1);
for (i = 0; i < env->sc_prefork_relay; i++) {
- if (imsg_compose(&ibuf_relay[i], type, 0, 0, -1, buf, len)
+ if (imsg_compose_event(&ibuf_relay[i], type, 0, 0, -1, buf, len)
== -1)
return (-1);
}
@@ -422,40 +422,40 @@ reconfigure(void)
/*
* first reconfigure pfe
*/
- imsg_compose(ibuf_pfe, IMSG_RECONF, 0, 0, -1, env, sizeof(*env));
+ imsg_compose_event(ibuf_pfe, IMSG_RECONF, 0, 0, -1, env, sizeof(*env));
TAILQ_FOREACH(table, env->sc_tables, entry) {
- imsg_compose(ibuf_pfe, IMSG_RECONF_TABLE, 0, 0, -1,
+ imsg_compose_event(ibuf_pfe, IMSG_RECONF_TABLE, 0, 0, -1,
&table->conf, sizeof(table->conf));
TAILQ_FOREACH(host, &table->hosts, entry) {
- imsg_compose(ibuf_pfe, IMSG_RECONF_HOST, 0, 0, -1,
+ imsg_compose_event(ibuf_pfe, IMSG_RECONF_HOST, 0, 0, -1,
&host->conf, sizeof(host->conf));
}
}
TAILQ_FOREACH(rdr, env->sc_rdrs, entry) {
- imsg_compose(ibuf_pfe, IMSG_RECONF_RDR, 0, 0, -1,
+ imsg_compose_event(ibuf_pfe, IMSG_RECONF_RDR, 0, 0, -1,
&rdr->conf, sizeof(rdr->conf));
TAILQ_FOREACH(virt, &rdr->virts, entry)
- imsg_compose(ibuf_pfe, IMSG_RECONF_VIRT, 0, 0, -1,
+ imsg_compose_event(ibuf_pfe, IMSG_RECONF_VIRT, 0, 0, -1,
virt, sizeof(*virt));
}
- imsg_compose(ibuf_pfe, IMSG_RECONF_END, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf_pfe, IMSG_RECONF_END, 0, 0, -1, NULL, 0);
/*
* then reconfigure hce
*/
- imsg_compose(ibuf_hce, IMSG_RECONF, 0, 0, -1, env, sizeof(*env));
+ imsg_compose_event(ibuf_hce, IMSG_RECONF, 0, 0, -1, env, sizeof(*env));
TAILQ_FOREACH(table, env->sc_tables, entry) {
- imsg_compose(ibuf_hce, IMSG_RECONF_TABLE, 0, 0, -1,
+ imsg_compose_event(ibuf_hce, IMSG_RECONF_TABLE, 0, 0, -1,
&table->conf, sizeof(table->conf));
if (table->sendbuf != NULL)
- imsg_compose(ibuf_hce, IMSG_RECONF_SENDBUF, 0, 0, -1,
+ imsg_compose_event(ibuf_hce, IMSG_RECONF_SENDBUF, 0, 0, -1,
table->sendbuf, strlen(table->sendbuf) + 1);
TAILQ_FOREACH(host, &table->hosts, entry) {
- imsg_compose(ibuf_hce, IMSG_RECONF_HOST, 0, 0, -1,
+ imsg_compose_event(ibuf_hce, IMSG_RECONF_HOST, 0, 0, -1,
&host->conf, sizeof(host->conf));
}
}
- imsg_compose(ibuf_hce, IMSG_RECONF_END, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf_hce, IMSG_RECONF_END, 0, 0, -1, NULL, 0);
}
void
@@ -586,6 +586,18 @@ imsg_event_add(struct imsgbuf *ibuf)
event_add(&ibuf->ev, NULL);
}
+int
+imsg_compose_event(struct imsgbuf *ibuf, u_int16_t type, u_int32_t peerid,
+ pid_t pid, int fd, void *data, u_int16_t datalen)
+{
+ int ret;
+
+ if ((ret = imsg_compose(ibuf, type, peerid,
+ pid, fd, data, datalen)) != -1)
+ imsg_event_add(ibuf);
+ return (ret);
+}
+
void
main_dispatch_pfe(int fd, short event, void *ptr)
{
@@ -685,7 +697,7 @@ main_dispatch_hce(int fd, short event, void * ptr)
"invalid size of script request");
bcopy(imsg.data, &scr, sizeof(scr));
scr.retval = script_exec(env, &scr);
- imsg_compose(ibuf_hce, IMSG_SCRIPT,
+ imsg_compose_event(ibuf_hce, IMSG_SCRIPT,
0, 0, -1, &scr, sizeof(scr));
break;
case IMSG_SNMPSOCK:
@@ -753,7 +765,7 @@ main_dispatch_relay(int fd, short event, void * ptr)
/* NOTREACHED */
}
s = bindany(&bnd);
- imsg_compose(&ibuf_relay[bnd.bnd_proc], IMSG_BINDANY,
+ imsg_compose_event(&ibuf_relay[bnd.bnd_proc], IMSG_BINDANY,
0, 0, s, &bnd.bnd_id, sizeof(bnd.bnd_id));
break;
default:
diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h
index a78e13d37ac..5e2ee27b327 100644
--- a/usr.sbin/relayd/relayd.h
+++ b/usr.sbin/relayd/relayd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.h,v 1.123 2009/06/04 23:33:49 pyr Exp $ */
+/* $OpenBSD: relayd.h,v 1.124 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -830,6 +830,9 @@ int protonode_load(enum direction, struct protocol *,
struct protonode *, const char *);
int map6to4(struct sockaddr_storage *);
int map4to6(struct sockaddr_storage *, struct sockaddr_storage *);
+void imsg_event_add(struct imsgbuf *);
+int imsg_compose_event(struct imsgbuf *, u_int16_t, u_int32_t,
+ pid_t, int, void *, u_int16_t);
/* carp.c */
int carp_demote_init(char *, int);
diff --git a/usr.sbin/relayd/snmp.c b/usr.sbin/relayd/snmp.c
index 2e92955a7f9..983dd1ac10b 100644
--- a/usr.sbin/relayd/snmp.c
+++ b/usr.sbin/relayd/snmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snmp.c,v 1.3 2009/06/03 20:20:09 eric Exp $ */
+/* $OpenBSD: snmp.c,v 1.4 2009/06/05 00:04:01 pyr Exp $ */
/*
* Copyright (c) 2008 Reyk Floeter <reyk@openbsd.org>
@@ -94,9 +94,9 @@ snmp_sendsock(struct imsgbuf *ibuf)
/* enable restricted snmp socket mode */
bzero(&tmpibuf, sizeof(tmpibuf));
imsg_init(&tmpibuf, s, NULL);
- imsg_compose(&tmpibuf, IMSG_SNMP_LOCK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(&tmpibuf, IMSG_SNMP_LOCK, 0, 0, -1, NULL, 0);
- imsg_compose(ibuf, IMSG_SNMPSOCK, 0, 0, s, NULL, 0);
+ imsg_compose_event(ibuf, IMSG_SNMPSOCK, 0, 0, s, NULL, 0);
imsg_flush(ibuf); /* need to send the socket now */
close(s);
return (0);
@@ -104,7 +104,7 @@ snmp_sendsock(struct imsgbuf *ibuf)
fail:
if (s != -1)
close(s);
- imsg_compose(ibuf, IMSG_NONE, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf, IMSG_NONE, 0, 0, -1, NULL, 0);
return (-1);
}
@@ -114,7 +114,7 @@ snmp_getsock(struct imsgbuf *ibuf)
struct imsg imsg;
int n, s = -1, done = 0;
- imsg_compose(ibuf, IMSG_SNMPSOCK, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf, IMSG_SNMPSOCK, 0, 0, -1, NULL, 0);
imsg_flush(ibuf);
while (!done) {
@@ -237,6 +237,7 @@ snmp_element(const char *oid, enum snmp_type type, void *buf, int64_t val)
if (imsg_composev(ibuf_snmp, IMSG_SNMP_ELEMENT, 0, 0, -1,
iov, iovcnt) == -1)
return (-1);
+ imsg_event_add(ibuf_snmp);
return (0);
}
@@ -256,7 +257,7 @@ snmp_hosttrap(struct table *table, struct host *host)
* XXX The trap format needs some tweaks and other OIDs
*/
- imsg_compose(ibuf_snmp, IMSG_SNMP_TRAP, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf_snmp, IMSG_SNMP_TRAP, 0, 0, -1, NULL, 0);
SNMP_ELEMENT(".1", SNMP_NULL, NULL, 0);
SNMP_ELEMENT(".1.1", SNMP_OCTETSTRING, host->conf.name, 0);
@@ -272,5 +273,5 @@ snmp_hosttrap(struct table *table, struct host *host)
SNMP_ELEMENT(".1.9", SNMP_INTEGER32, NULL, host->retry_cnt);
done:
- imsg_compose(ibuf_snmp, IMSG_SNMP_END, 0, 0, -1, NULL, 0);
+ imsg_compose_event(ibuf_snmp, IMSG_SNMP_END, 0, 0, -1, NULL, 0);
}