BUG/MEDIUM: tcp: transparent bind to the source only when address is set
Thomas Heil reported that health checks did not work anymore when a backend
or server has "usesrc clientip". This is because the source address is not
set and tcp_bind_socket() tries to bind to that address anyway.
The solution consists in explicitly clearing the source address in the checks
and to make tcp_bind_socket() avoid binding when the address is not set. This
also has an indirect benefit that a useless bind() syscall will be avoided
when using "source 0.0.0.0 usesrc clientip" in health checks.
diff --git a/src/checks.c b/src/checks.c
index 32f8c91..326ffde 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -1308,6 +1308,9 @@
set_target_server(&conn->target, s);
conn_prepare(conn, &check_conn_cb, s->check.proto, s->check.xprt, s);
+ /* no client address */
+ clear_addr(&conn->addr.from);
+
if (is_addr(&s->check.addr))
/* we'll connect to the check addr specified on the server */
conn->addr.to = s->check.addr;