MINOR: enable IP_BIND_ADDRESS_NO_PORT on backend connections
Enable IP_BIND_ADDRESS_NO_PORT on backend connections when the source
address is specified without port or port ranges. This is supported
since Linux 4.2/libc 2.23.
If the kernel supports it but the libc doesn't, we can define it at
build time:
make [...] DEFINE=-DIP_BIND_ADDRESS_NO_PORT=24
For more informations about this feature, see Linux commit 90c337da
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 91d6688..424731a 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -467,6 +467,10 @@
} while (ret != 0); /* binding NOK */
}
else {
+#ifdef IP_BIND_ADDRESS_NO_PORT
+ static int bind_address_no_port = 1;
+ setsockopt(fd, SOL_IP, IP_BIND_ADDRESS_NO_PORT, (const void *) &bind_address_no_port, sizeof(int));
+#endif
ret = tcp_bind_socket(fd, flags, &src->source_addr, &conn->addr.from);
if (ret != 0)
conn->err_code = CO_ER_CANT_BIND;