diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-22 16:07:04 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-11-22 16:07:04 +0000 |
commit | 9571ef3180105a43f5f823ff867d5657771a282b (patch) | |
tree | d5be8e5be2faee9ae5c902b0d919b42783e9468e /usr.sbin/relayd | |
parent | 7abafbe7948887da7ef709612930fdb77ee8eed9 (diff) |
Fix relay roundrobin mode to work correctly when multiple hosts in a
table are down.
Thanks to Preston Norvell at serialssolutions dot com for reporting
the problem.
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r-- | usr.sbin/relayd/relay.c | 7 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 466e17323f6..dd3776b7f26 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.65 2007/11/22 10:09:53 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.66 2007/11/22 16:07:03 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -463,6 +463,7 @@ relay_init(void) if (rlay->dstnhosts >= RELAY_MAXHOSTS) fatal("relay_init: " "too many hosts in table"); + host->idx = rlay->dstnhosts; rlay->dsthost[rlay->dstnhosts++] = host; } log_info("adding %d hosts from table %s%s", @@ -1903,7 +1904,7 @@ relay_from_table(struct session *con) case RELAY_DSTMODE_ROUNDROBIN: if ((int)rlay->dstkey >= rlay->dstnhosts) rlay->dstkey = 0; - idx = (int)rlay->dstkey++; + idx = (int)rlay->dstkey; break; case RELAY_DSTMODE_LOADBALANCE: p = relay_hash_addr(&con->in.ss, p); @@ -1933,6 +1934,8 @@ relay_from_table(struct session *con) fatalx("relay_from_table: no active hosts, desynchronized"); found: + if (rlay->conf.dstmode == RELAY_DSTMODE_ROUNDROBIN) + rlay->dstkey = host->idx + 1; con->retry = host->conf.retry; con->out.port = table->conf.port; bcopy(&host->conf.ss, &con->out.ss, sizeof(con->out.ss)); diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index b016a3a5283..83562c3a213 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.81 2007/11/22 10:09:53 reyk Exp $ */ +/* $OpenBSD: relayd.h,v 1.82 2007/11/22 16:07:03 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -327,6 +327,7 @@ struct host { u_long up_cnt; int retry_cnt; struct ctl_tcp_event cte; + int idx; }; TAILQ_HEAD(hostlist, host); |