]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: enable IP_BIND_ADDRESS_NO_PORT on backend connections
authorLukas Tribus <luky-37@hotmail.com>
Tue, 13 Sep 2016 09:51:15 +0000 (09:51 +0000)
committerWilly Tarreau <w@1wt.eu>
Tue, 13 Sep 2016 13:22:54 +0000 (15:22 +0200)
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

doc/configuration.txt
src/proto_tcp.c

index 52e6cf44bfeb59654a13f710f7397641adabb479..dc43003e84a4a7a6d333ba9b638d58380a392dfc 100644 (file)
@@ -10936,6 +10936,9 @@ source <addr>[:<pl>[-<ph>]] [interface <name>] ...
   total concurrent connections. The limit will then reach 64k connections per
   server.
 
+  Since Linux 4.2/libc 2.23 IP_BIND_ADDRESS_NO_PORT is set for connections
+  specifying the source address without port(s).
+
   Supported in default-server: No
 
 ssl
index 91d66881a5b01fed69a1af58b186d9651fa79ee6..424731a6a21283cdc320aa21aa41a082c9725246 100644 (file)
@@ -467,6 +467,10 @@ int tcp_connect_server(struct connection *conn, int data, int delack)
                        } 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;