]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] checks: use the correct destination port for sending checks
authorWilly Tarreau <w@1wt.eu>
Sat, 27 Aug 2011 09:51:36 +0000 (11:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 27 Aug 2011 09:51:36 +0000 (11:51 +0200)
In the number of switch/case statements added for IPv6 changes,
one was wrong and caused the check port to be ignored for outgoing
connection because the socket's family was not taken at the right
place. Use the set_host_port() macro instead to fix the issue.

The same cleanup could be performed at a number of other places
and should follow shortly.

Special thanks to Stephane Bakhos of Techboom for reporting a
detailed analysis of this bug.

src/checks.c

index 2e22b49e339e084ce7252dd41266cf8f6350a054..b98c49b85727a6520272f1fc94bed1e925ef9e7c 100644 (file)
@@ -1284,16 +1284,8 @@ struct task *process_chk(struct task *t)
                                        /* we'll connect to the addr on the server */
                                        sa = s->addr;
 
-                               switch (s->check_addr.ss_family) {
-                               case AF_INET:
-                                       /* we'll connect to the check port on the server */
-                                       ((struct sockaddr_in *)&sa)->sin_port = htons(s->check_port);
-                                       break;
-                               case AF_INET6:
-                                       /* we'll connect to the check port on the server */
-                                       ((struct sockaddr_in6 *)&sa)->sin6_port = htons(s->check_port);
-                                       break;
-                               }
+                               set_host_port(&sa, s->check_port);
+
                                /* allow specific binding :
                                 * - server-specific at first
                                 * - proxy-specific next