BUG/MINOR: tcp-act: Don't forget to set the original port for IPv4 set-dst rule

If an IPv4 is set via a TCP/HTTP set-dst rule, the original port must be
preserved or set to 0 if the previous family was neither AF_INET nor
AF_INET6. The first case is not an issue because the port remains the
same. But if the previous family was, for instance, AF_UNIX, the port is not
set to 0 and have an undefined value.

This patch must be backported as far as 1.7.

(cherry picked from commit e01ca0fbc9c72de95514816e016a58c5a28ab2a8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 3a6133a3b7eff777f0c7bee0f000a763cf2ec971)
[cf: Changes applied in src/proto_tcp.c]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 7defd7020b188afb82cc20b7d63d5dba4ac756a4)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit f68962344ab994e3d949de8f70ab127130b08c24)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 2f2e0bf..f379fd1 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -1225,6 +1225,7 @@
 			if (smp->data.type == SMP_T_IPV4) {
 				((struct sockaddr_in *)&cli_conn->addr.to)->sin_family = AF_INET;
 				((struct sockaddr_in *)&cli_conn->addr.to)->sin_addr.s_addr = smp->data.u.ipv4.s_addr;
+				((struct sockaddr_in *)&cli_conn->addr.to)->sin_port = port;
 			} else if (smp->data.type == SMP_T_IPV6) {
 				((struct sockaddr_in6 *)&cli_conn->addr.to)->sin6_family = AF_INET6;
 				memcpy(&((struct sockaddr_in6 *)&cli_conn->addr.to)->sin6_addr, &smp->data.u.ipv6, sizeof(struct in6_addr));