From 786d1915b0b6363f83b8ff7d3c123841edf85420 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 13 Jan 2008 18:10:06 +0100 Subject: [PATCH] [BUG] use backend's source and not server's source with tproxy copy-paste typo. --- src/backend.c | 59 +++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/src/backend.c b/src/backend.c index aadc65057d..beba14d3c7 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1274,23 +1274,20 @@ int connect_server(struct session *s) struct sockaddr_in *remote = NULL; int ret, flags = 0; - if (s->srv->state & SRV_TPROXY_MASK) { - switch (s->srv->state & SRV_TPROXY_MASK) { - case SRV_TPROXY_ADDR: - remote = (struct sockaddr_in *)&s->srv->tproxy_addr; - flags = 3; - break; - case SRV_TPROXY_CLI: - flags |= 2; - /* fall through */ - case SRV_TPROXY_CIP: - /* FIXME: what can we do if the client connects in IPv6 ? */ - flags |= 1; - remote = (struct sockaddr_in *)&s->cli_addr; - break; - } + switch (s->srv->state & SRV_TPROXY_MASK) { + case SRV_TPROXY_ADDR: + remote = (struct sockaddr_in *)&s->srv->tproxy_addr; + flags = 3; + break; + case SRV_TPROXY_CLI: + flags |= 2; + /* fall through */ + case SRV_TPROXY_CIP: + /* FIXME: what can we do if the client connects in IPv6 ? */ + flags |= 1; + remote = (struct sockaddr_in *)&s->cli_addr; + break; } - ret = bind_ipv4(fd, flags, &s->srv->source_addr, remote); if (ret) { close(fd); @@ -1314,24 +1311,22 @@ int connect_server(struct session *s) struct sockaddr_in *remote = NULL; int ret, flags = 0; - if (s->be->options & PR_O_TPXY_MASK) { - switch (s->be->options & PR_O_TPXY_MASK) { - case PR_O_TPXY_ADDR: - remote = (struct sockaddr_in *)&s->be->tproxy_addr; - flags = 3; - break; - case PR_O_TPXY_CLI: - flags |= 2; - /* fall through */ - case PR_O_TPXY_CIP: - /* FIXME: what can we do if the client connects in IPv6 ? */ - flags |= 1; - remote = (struct sockaddr_in *)&s->cli_addr; - break; - } + switch (s->be->options & PR_O_TPXY_MASK) { + case PR_O_TPXY_ADDR: + remote = (struct sockaddr_in *)&s->be->tproxy_addr; + flags = 3; + break; + case PR_O_TPXY_CLI: + flags |= 2; + /* fall through */ + case PR_O_TPXY_CIP: + /* FIXME: what can we do if the client connects in IPv6 ? */ + flags |= 1; + remote = (struct sockaddr_in *)&s->cli_addr; + break; } - ret = bind_ipv4(fd, flags, &s->srv->source_addr, remote); + ret = bind_ipv4(fd, flags, &s->be->source_addr, remote); if (ret) { close(fd); if (ret == 1) {