BUG/MEDIUM: tcp/http: set-dst-port action broken

A regression has been introduced in commit
00005ce5a1: 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.
This commit is contained in:
Baptiste Assmann 2017-10-03 23:16:36 +02:00 committed by Willy Tarreau
parent 4473a2e9aa
commit 46392fdd08

View File

@ -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);
}
}
}