mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-28 15:42:30 +00:00
MINOR: tproxy: add support for FreeBSD
FreeBSD uses (IPPROTO_IP, IP_BINDANY) and (IPPROTO_IPV6, IPV6_BINDANY) to enable transparent proxy on a socket. This patch adds support for the relevant setsockopt() calls.
This commit is contained in:
parent
d551fb5a8d
commit
ff30b6667b
@ -94,6 +94,8 @@
|
||||
#endif /* CONFIG_HAP_LINUX_TPROXY */
|
||||
|
||||
#if defined(IP_FREEBIND) \
|
||||
|| defined(IP_BINDANY) \
|
||||
|| defined(IPV6_BINDANY) \
|
||||
|| defined(IP_TRANSPARENT) \
|
||||
|| defined(IPV6_TRANSPARENT)
|
||||
#define CONFIG_HAP_TRANSPARENT
|
||||
|
@ -326,6 +326,12 @@ void display_build_opts()
|
||||
#endif
|
||||
#if defined(IP_FREEBIND)
|
||||
" IP_FREEBIND"
|
||||
#endif
|
||||
#if defined(IP_BINDANY)
|
||||
" IP_BINDANY"
|
||||
#endif
|
||||
#if defined(IPV6_BINDANY)
|
||||
" IPV6_BINDANY"
|
||||
#endif
|
||||
"\n");
|
||||
#endif
|
||||
|
@ -138,6 +138,9 @@ int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct so
|
||||
#endif
|
||||
#if defined(IP_FREEBIND)
|
||||
|| (setsockopt(fd, SOL_IP, IP_FREEBIND, &one, sizeof(one)) == 0)
|
||||
#endif
|
||||
#if defined(IP_BINDANY)
|
||||
|| (setsockopt(fd, IPPROTO_IP, IP_BINDANY, &one, sizeof(one)) == 0)
|
||||
#endif
|
||||
)
|
||||
foreign_ok = 1;
|
||||
@ -150,6 +153,9 @@ int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct so
|
||||
if (0
|
||||
#if defined(IPV6_TRANSPARENT)
|
||||
|| (setsockopt(fd, SOL_IPV6, IPV6_TRANSPARENT, &one, sizeof(one)) == 0)
|
||||
#endif
|
||||
#if defined(IPV6_BINDANY)
|
||||
|| (setsockopt(fd, IPPROTO_IPV6, IPV6_BINDANY, &one, sizeof(one)) == 0)
|
||||
#endif
|
||||
)
|
||||
foreign_ok = 1;
|
||||
@ -644,6 +650,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
#endif
|
||||
#if defined(IP_FREEBIND)
|
||||
&& (setsockopt(fd, SOL_IP, IP_FREEBIND, &one, sizeof(one)) == -1)
|
||||
#endif
|
||||
#if defined(IP_BINDANY)
|
||||
&& (setsockopt(fd, IPPROTO_IP, IP_BINDANY, &one, sizeof(one)) == -1)
|
||||
#endif
|
||||
) {
|
||||
msg = "cannot make listening socket transparent";
|
||||
@ -654,6 +663,9 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
if (1
|
||||
#if defined(IPV6_TRANSPARENT)
|
||||
&& (setsockopt(fd, SOL_IPV6, IPV6_TRANSPARENT, &one, sizeof(one)) == -1)
|
||||
#endif
|
||||
#if defined(IPV6_BINDANY)
|
||||
&& (setsockopt(fd, IPPROTO_IPV6, IPV6_BINDANY, &one, sizeof(one)) == -1)
|
||||
#endif
|
||||
) {
|
||||
msg = "cannot make listening socket transparent";
|
||||
|
Loading…
Reference in New Issue
Block a user