From 4ab823eb500a8a63061eb23581e73ff9d8bffce1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 6 Apr 2014 12:31:51 +0200 Subject: Set IP_FREEBIND --- cmake/config.cmake | 1 + src/fastd_config.h.in | 1 + src/socket.c | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/cmake/config.cmake b/cmake/config.cmake index e7e0f42..cbdc775 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -6,6 +6,7 @@ endif() set(USE_BINDTODEVICE ${LINUX}) +set(USE_FREEBIND ${LINUX}) set(USE_PMTU ${LINUX}) set(USE_PKTINFO ${LINUX}) set(USE_PACKET_MARK ${LINUX}) diff --git a/src/fastd_config.h.in b/src/fastd_config.h.in index 4402139..7426baf 100644 --- a/src/fastd_config.h.in +++ b/src/fastd_config.h.in @@ -33,6 +33,7 @@ #cmakedefine USE_BINDTODEVICE +#cmakedefine USE_FREEBIND #cmakedefine USE_PMTU #cmakedefine USE_PKTINFO #cmakedefine USE_PACKET_MARK diff --git a/src/socket.c b/src/socket.c index 526e63f..4f5ac0f 100644 --- a/src/socket.c +++ b/src/socket.c @@ -69,6 +69,11 @@ static int bind_socket(fastd_context_t *ctx, const fastd_bind_address_t *addr, b } #endif +#ifdef USE_FREEBIND + if (setsockopt(fd, IPPROTO_IP, IP_FREEBIND, &one, sizeof(one))) + pr_warn_errno(ctx, "setsockopt: unable to set IP_FREEBIND"); +#endif + if (af == AF_INET6) { if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one))) { pr_error_errno(ctx, "setsockopt: unable to set IPV6_RECVPKTINFO"); -- cgit v1.2.3