-/* $OpenBSD: parse.y,v 1.143 2010/02/24 15:44:18 jsg Exp $ */
+/* $OpenBSD: parse.y,v 1.144 2010/08/01 22:18:35 sthen Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
"or table", rlay->rl_conf.name);
YYERROR;
}
+ if (rlay->rl_backuptable == NULL) {
+ rlay->rl_conf.backuptable =
+ conf->sc_empty_table.conf.id;
+ rlay->rl_backuptable = &conf->sc_empty_table;
+ }
if (rlay->rl_conf.proto == EMPTY_ID) {
rlay->rl_proto = &conf->sc_proto_default;
rlay->rl_conf.proto = conf->sc_proto_default.id;
rlay->rl_conf.dstretry = $3;
}
| tablespec {
- if (rlay->rl_dsttable) {
- yyerror("table already specified");
+ if (rlay->rl_backuptable) {
+ yyerror("only one backup table is allowed");
purge_table(conf->sc_tables, $1);
YYERROR;
}
-
- rlay->rl_dsttable = $1;
- rlay->rl_dsttable->conf.flags |= F_USED;
- rlay->rl_conf.dsttable = $1->conf.id;
- rlay->rl_conf.dstport = $1->conf.port;
+ if (rlay->rl_dsttable) {
+ rlay->rl_backuptable = $1;
+ rlay->rl_backuptable->conf.flags |= F_USED;
+ rlay->rl_conf.backuptable = $1->conf.id;
+ } else {
+ rlay->rl_dsttable = $1;
+ rlay->rl_dsttable->conf.flags |= F_USED;
+ rlay->rl_conf.dsttable = $1->conf.id;
+ rlay->rl_conf.dstport = $1->conf.port;
+ }
}
;
-/* $OpenBSD: pfe.c,v 1.64 2010/05/14 11:13:36 reyk Exp $ */
+/* $OpenBSD: pfe.c,v 1.65 2010/08/01 22:18:35 sthen Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
TAILQ_FOREACH(host, &rlay->rl_dsttable->hosts, entry)
imsg_compose_event(&c->iev, IMSG_CTL_HOST,
0, 0, -1, host, sizeof(*host));
+
+ if (rlay->rl_conf.backuptable == EMPTY_TABLE)
+ continue;
+ imsg_compose_event(&c->iev, IMSG_CTL_TABLE, 0, 0, -1,
+ rlay->rl_backuptable, sizeof(*rlay->rl_backuptable));
+ if (!(rlay->rl_backuptable->conf.flags & F_DISABLE))
+ TAILQ_FOREACH(host, &rlay->rl_backuptable->hosts, entry)
+ imsg_compose_event(&c->iev, IMSG_CTL_HOST,
+ 0, 0, -1, host, sizeof(*host));
}
routers:
-/* $OpenBSD: relay.c,v 1.121 2010/05/26 13:56:08 nicm Exp $ */
+/* $OpenBSD: relay.c,v 1.122 2010/08/01 22:18:35 sthen Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
u_int32_t p = con->se_hashkey;
int idx = 0;
- if (table->conf.check && !table->up) {
+ if (table->conf.check && !table->up && !rlay->rl_backuptable->up) {
log_debug("relay_from_table: no active hosts");
return (-1);
+ } else if (!table->up && rlay->rl_backuptable->up) {
+ table = rlay->rl_backuptable;
}
switch (rlay->rl_conf.dstmode) {
-.\" $OpenBSD: relayd.conf.5,v 1.113 2010/05/18 15:09:34 sobrado Exp $
+.\" $OpenBSD: relayd.conf.5,v 1.114 2010/08/01 22:18:35 sthen Exp $
.\"
.\" Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org>
.\" Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 18 2010 $
+.Dd $Mdocdate: August 1 2010 $
.Dt RELAYD.CONF 5
.Os
.Sh NAME
table; see the
.Sx TABLES
section above for information about table options.
+This directive can be specified twice \(en the second entry will be used
+as the backup table if all hosts in the main table are down.
+At least one entry for the main table is mandatory.
.It Xo
.Ic forward to
.Ic nat lookup
-/* $OpenBSD: relayd.h,v 1.136 2010/05/26 13:56:08 nicm Exp $ */
+/* $OpenBSD: relayd.h,v 1.137 2010/08/01 22:18:35 sthen Exp $ */
/*
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
int dstmode;
int dstretry;
objid_t dsttable;
+ objid_t backuptable;
struct sockaddr_storage ss;
struct sockaddr_storage dstss;
struct sockaddr_storage dstaf;
struct bufferevent *rl_dstbev;
struct table *rl_dsttable;
+ struct table *rl_backuptable;
u_int32_t rl_dstkey;
struct host *rl_dsthost[RELAY_MAXHOSTS];
int rl_dstnhosts;