diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-03-21 00:08:09 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-03-21 00:08:09 +0000 |
commit | 3c602e356507de335bf00c35a74e1b5922048c8b (patch) | |
tree | bfe94f57e2318c0d5a9ac37943f2fd04bd31d31c /usr.sbin | |
parent | 4af2d44e3aa02114b9e5bcd56ea422e29bd6ed73 (diff) |
in addition to the host retry option in tables, add support for the
optional connection "retry" to the forward to, service, and nat lookup
options. for example, "nat lookup retry 3" is useful when running
hoststated as a transparent proxy when connecting to unreliable
frontend/backend servers.
ok pyr@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/hoststated/hoststated.conf.5 | 17 | ||||
-rw-r--r-- | usr.sbin/hoststated/hoststated.h | 3 | ||||
-rw-r--r-- | usr.sbin/hoststated/parse.y | 14 | ||||
-rw-r--r-- | usr.sbin/hoststated/relay.c | 3 | ||||
-rw-r--r-- | usr.sbin/relayd/parse.y | 14 | ||||
-rw-r--r-- | usr.sbin/relayd/relay.c | 3 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.conf.5 | 17 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 3 |
8 files changed, 54 insertions, 20 deletions
diff --git a/usr.sbin/hoststated/hoststated.conf.5 b/usr.sbin/hoststated/hoststated.conf.5 index b26624b25f7..b6b22a2eaf4 100644 --- a/usr.sbin/hoststated/hoststated.conf.5 +++ b/usr.sbin/hoststated/hoststated.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: hoststated.conf.5,v 1.39 2007/03/13 12:04:52 reyk Exp $ +.\" $OpenBSD: hoststated.conf.5,v 1.40 2007/03/21 00:08:08 reyk Exp $ .\" .\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> .\" @@ -325,9 +325,15 @@ is the specified IP address of the relay to listen on. See .Xr ssl 8 for details about SSL server certificates. -.It Ic forward to Ar address Ic port Ar port +.It Xo +.Ic forward to Ar address Ic port Ar port +.Op Ic retry Ar number +.Xc Specify the address and port of the target host to connect to. -.It Ic service Ar name +.It Xo +.Ic service Ar name +.Op Ic retry Ar number +.Xc Use the first virtual IP address and port from the specified service as the target host to connect to. This is exclusive to the @@ -369,7 +375,10 @@ more times. See the .Sx TABLES section for details about host entries. -.It Ic nat lookup +.It Xo +.Ic nat lookup +.Op Ic retry Ar number +.Xc When redirecting connections with an .Ar rdr rule in diff --git a/usr.sbin/hoststated/hoststated.h b/usr.sbin/hoststated/hoststated.h index f97f315af39..dd68b4b260b 100644 --- a/usr.sbin/hoststated/hoststated.h +++ b/usr.sbin/hoststated/hoststated.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hoststated.h,v 1.38 2007/03/17 22:28:42 reyk Exp $ */ +/* $OpenBSD: hoststated.h,v 1.39 2007/03/21 00:08:08 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -463,6 +463,7 @@ struct relay { int dstnhosts; int dstmode; int dstcheck; + int dstretry; struct event ev; struct timeval timeout; diff --git a/usr.sbin/hoststated/parse.y b/usr.sbin/hoststated/parse.y index 0815ea82f0e..6a5070e9997 100644 --- a/usr.sbin/hoststated/parse.y +++ b/usr.sbin/hoststated/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.36 2007/03/13 12:04:52 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.37 2007/03/21 00:08:08 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -831,6 +831,7 @@ relay : RELAY STRING { r->timeout.tv_sec = RELAY_TIMEOUT; r->proto = NULL; r->dsttable = NULL; + r->dstretry = 0; if (last_relay_id == INT_MAX) { yyerror("too many relays defined"); YYERROR; @@ -886,7 +887,7 @@ relayoptsl : LISTEN ON STRING port optssl { conf->flags |= F_SSL; } } - | FORWARD TO STRING port { + | FORWARD TO STRING port retry { struct addresslist al; struct address *h; @@ -907,8 +908,9 @@ relayoptsl : LISTEN ON STRING port optssl { h = TAILQ_FIRST(&al); bcopy(&h->ss, &rlay->dstss, sizeof(rlay->dstss)); rlay->dstport = h->port; + rlay->dstretry = $5; } - | SERVICE STRING { + | SERVICE STRING retry { struct service *svc; struct address *h; @@ -929,6 +931,7 @@ relayoptsl : LISTEN ON STRING port optssl { h = TAILQ_FIRST(&svc->virts); bcopy(&h->ss, &rlay->dstss, sizeof(rlay->dstss)); rlay->dstport = h->port; + rlay->dstretry = $3; } | TABLE STRING dstmode docheck { struct table *dsttable; @@ -960,7 +963,10 @@ relayoptsl : LISTEN ON STRING port optssl { rlay->proto = p; free($2); } - | NAT LOOKUP { rlay->flags |= F_NATLOOK; } + | NAT LOOKUP retry { + rlay->flags |= F_NATLOOK; + rlay->dstretry = $3; + } | TIMEOUT number { rlay->timeout.tv_sec = $2; } | DISABLE { rlay->flags |= F_DISABLE; } ; diff --git a/usr.sbin/hoststated/relay.c b/usr.sbin/hoststated/relay.c index 2a55985022d..71925f42995 100644 --- a/usr.sbin/hoststated/relay.c +++ b/usr.sbin/hoststated/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.21 2007/03/17 22:25:08 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.22 2007/03/21 00:08:08 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -1440,6 +1440,7 @@ relay_accept(int fd, short sig, void *arg) con->out.tree = &proto->response_tree; con->in.dir = RELAY_DIR_REQUEST; con->out.dir = RELAY_DIR_RESPONSE; + con->retry = rlay->dstretry; if (gettimeofday(&con->tv_start, NULL)) goto err; bcopy(&con->tv_start, &con->tv_last, sizeof(con->tv_last)); diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y index 0815ea82f0e..6a5070e9997 100644 --- a/usr.sbin/relayd/parse.y +++ b/usr.sbin/relayd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.36 2007/03/13 12:04:52 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.37 2007/03/21 00:08:08 reyk Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -831,6 +831,7 @@ relay : RELAY STRING { r->timeout.tv_sec = RELAY_TIMEOUT; r->proto = NULL; r->dsttable = NULL; + r->dstretry = 0; if (last_relay_id == INT_MAX) { yyerror("too many relays defined"); YYERROR; @@ -886,7 +887,7 @@ relayoptsl : LISTEN ON STRING port optssl { conf->flags |= F_SSL; } } - | FORWARD TO STRING port { + | FORWARD TO STRING port retry { struct addresslist al; struct address *h; @@ -907,8 +908,9 @@ relayoptsl : LISTEN ON STRING port optssl { h = TAILQ_FIRST(&al); bcopy(&h->ss, &rlay->dstss, sizeof(rlay->dstss)); rlay->dstport = h->port; + rlay->dstretry = $5; } - | SERVICE STRING { + | SERVICE STRING retry { struct service *svc; struct address *h; @@ -929,6 +931,7 @@ relayoptsl : LISTEN ON STRING port optssl { h = TAILQ_FIRST(&svc->virts); bcopy(&h->ss, &rlay->dstss, sizeof(rlay->dstss)); rlay->dstport = h->port; + rlay->dstretry = $3; } | TABLE STRING dstmode docheck { struct table *dsttable; @@ -960,7 +963,10 @@ relayoptsl : LISTEN ON STRING port optssl { rlay->proto = p; free($2); } - | NAT LOOKUP { rlay->flags |= F_NATLOOK; } + | NAT LOOKUP retry { + rlay->flags |= F_NATLOOK; + rlay->dstretry = $3; + } | TIMEOUT number { rlay->timeout.tv_sec = $2; } | DISABLE { rlay->flags |= F_DISABLE; } ; diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 2a55985022d..71925f42995 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.21 2007/03/17 22:25:08 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.22 2007/03/21 00:08:08 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -1440,6 +1440,7 @@ relay_accept(int fd, short sig, void *arg) con->out.tree = &proto->response_tree; con->in.dir = RELAY_DIR_REQUEST; con->out.dir = RELAY_DIR_RESPONSE; + con->retry = rlay->dstretry; if (gettimeofday(&con->tv_start, NULL)) goto err; bcopy(&con->tv_start, &con->tv_last, sizeof(con->tv_last)); diff --git a/usr.sbin/relayd/relayd.conf.5 b/usr.sbin/relayd/relayd.conf.5 index b28fcac2f22..854f1aaa202 100644 --- a/usr.sbin/relayd/relayd.conf.5 +++ b/usr.sbin/relayd/relayd.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: relayd.conf.5,v 1.39 2007/03/13 12:04:52 reyk Exp $ +.\" $OpenBSD: relayd.conf.5,v 1.40 2007/03/21 00:08:08 reyk Exp $ .\" .\" Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> .\" @@ -325,9 +325,15 @@ is the specified IP address of the relay to listen on. See .Xr ssl 8 for details about SSL server certificates. -.It Ic forward to Ar address Ic port Ar port +.It Xo +.Ic forward to Ar address Ic port Ar port +.Op Ic retry Ar number +.Xc Specify the address and port of the target host to connect to. -.It Ic service Ar name +.It Xo +.Ic service Ar name +.Op Ic retry Ar number +.Xc Use the first virtual IP address and port from the specified service as the target host to connect to. This is exclusive to the @@ -369,7 +375,10 @@ more times. See the .Sx TABLES section for details about host entries. -.It Ic nat lookup +.It Xo +.Ic nat lookup +.Op Ic retry Ar number +.Xc When redirecting connections with an .Ar rdr rule in diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index b18426d604b..babb288554b 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.38 2007/03/17 22:28:42 reyk Exp $ */ +/* $OpenBSD: relayd.h,v 1.39 2007/03/21 00:08:08 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -463,6 +463,7 @@ struct relay { int dstnhosts; int dstmode; int dstcheck; + int dstretry; struct event ev; struct timeval timeout; |