diff --git a/include/common/compat.h b/include/common/compat.h index efc2a6e043..0085a3aa1b 100644 --- a/include/common/compat.h +++ b/include/common/compat.h @@ -96,6 +96,7 @@ #if defined(IP_FREEBIND) \ || defined(IP_BINDANY) \ || defined(IPV6_BINDANY) \ + || defined(SO_BINDANY) \ || defined(IP_TRANSPARENT) \ || defined(IPV6_TRANSPARENT) #define CONFIG_HAP_TRANSPARENT diff --git a/src/haproxy.c b/src/haproxy.c index ee0bd65815..5b5bea4c64 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -332,6 +332,9 @@ void display_build_opts() #endif #if defined(IPV6_BINDANY) " IPV6_BINDANY" +#endif +#if defined(SO_BINDANY) + " SO_BINDANY" #endif "\n"); #endif diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 0ae359a767..5638257c4a 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -141,6 +141,9 @@ int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct so #endif #if defined(IP_BINDANY) || (setsockopt(fd, IPPROTO_IP, IP_BINDANY, &one, sizeof(one)) == 0) +#endif +#if defined(SO_BINDANY) + || (setsockopt(fd, SOL_SOCKET, SO_BINDANY, &one, sizeof(one)) == 0) #endif ) foreign_ok = 1; @@ -156,6 +159,9 @@ int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct so #endif #if defined(IPV6_BINDANY) || (setsockopt(fd, IPPROTO_IPV6, IPV6_BINDANY, &one, sizeof(one)) == 0) +#endif +#if defined(SO_BINDANY) + || (setsockopt(fd, SOL_SOCKET, SO_BINDANY, &one, sizeof(one)) == 0) #endif ) foreign_ok = 1; @@ -653,6 +659,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen) #endif #if defined(IP_BINDANY) && (setsockopt(fd, IPPROTO_IP, IP_BINDANY, &one, sizeof(one)) == -1) +#endif +#if defined(SO_BINDANY) + && (setsockopt(fd, SOL_SOCKET, SO_BINDANY, &one, sizeof(one)) == -1) #endif ) { msg = "cannot make listening socket transparent"; @@ -666,6 +675,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen) #endif #if defined(IPV6_BINDANY) && (setsockopt(fd, IPPROTO_IPV6, IPV6_BINDANY, &one, sizeof(one)) == -1) +#endif +#if defined(SO_BINDANY) + && (setsockopt(fd, SOL_SOCKET, SO_BINDANY, &one, sizeof(one)) == -1) #endif ) { msg = "cannot make listening socket transparent";