[MEDIUM] add support for source interface binding
Specifying "interface <name>" after the "source" statement allows
one to bind to a specific interface for proxy<->server traffic.
This makes it possible to use multiple links to reach multiple
servers, and to force traffic to pass via an interface different
from the one the system would have chosen based on the routing
table.
diff --git a/src/checks.c b/src/checks.c
index d6ce335..aad1643 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -615,6 +615,12 @@
flags = 3;
}
#endif
+#ifdef SO_BINDTODEVICE
+ /* Note: this might fail if not CAP_NET_RAW */
+ if (s->proxy->iface_name)
+ setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE,
+ s->proxy->iface_name, s->proxy->iface_len);
+#endif
ret = tcpv4_bind_socket(fd, flags, &s->proxy->source_addr, remote);
if (ret) {
s->result |= SRV_CHK_ERROR;