From: Baptiste Assmann Date: Tue, 3 Oct 2017 21:16:36 +0000 (+0200) Subject: BUG/MEDIUM: tcp/http: set-dst-port action broken X-Git-Tag: v1.8-dev3~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46392fdd083ee36f5ee5a82e138080a25e3340f1;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: tcp/http: set-dst-port action broken A regression has been introduced in commit 00005ce5a14310d248c9f20af9ef258d245d43b1: the port being changed is the one from 'cli_conn->addr.from' instead of 'cli_conn->addr.to'. This patch fixes the regression. Backport status: should be backported to HAProxy 1.7 and above. --- diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 0fad867a92..fdb897e3e5 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -1300,14 +1300,14 @@ enum act_return tcp_action_req_set_dst_port(struct act_rule *rule, struct proxy smp = sample_fetch_as_type(px, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->arg.expr, SMP_T_SINT); if (smp) { - if (cli_conn->addr.from.ss_family == AF_INET6) { - ((struct sockaddr_in6 *)&cli_conn->addr.from)->sin6_port = htons(smp->data.u.sint); + if (cli_conn->addr.to.ss_family == AF_INET6) { + ((struct sockaddr_in6 *)&cli_conn->addr.to)->sin6_port = htons(smp->data.u.sint); } else { - if (cli_conn->addr.from.ss_family != AF_INET) { - cli_conn->addr.from.ss_family = AF_INET; - ((struct sockaddr_in *)&cli_conn->addr.from)->sin_addr.s_addr = 0; + if (cli_conn->addr.to.ss_family != AF_INET) { + cli_conn->addr.to.ss_family = AF_INET; + ((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr.s_addr = 0; } - ((struct sockaddr_in *)&cli_conn->addr.from)->sin_port = htons(smp->data.u.sint); + ((struct sockaddr_in *)&cli_conn->addr.to)->sin_port = htons(smp->data.u.sint); } } }