summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-04-06 12:31:51 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-04-06 12:31:51 +0200
commit4ab823eb500a8a63061eb23581e73ff9d8bffce1 (patch)
treef8685321c376eac9ba1f9fdd12f1586877ca6d9f
parent04842eebd01dbcb0852166993c2a44ebc5ac96b1 (diff)
downloadfastd-4ab823eb500a8a63061eb23581e73ff9d8bffce1.tar
fastd-4ab823eb500a8a63061eb23581e73ff9d8bffce1.zip
Set IP_FREEBIND
-rw-r--r--cmake/config.cmake1
-rw-r--r--src/fastd_config.h.in1
-rw-r--r--src/socket.c5
3 files changed, 7 insertions, 0 deletions
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");