summaryrefslogtreecommitdiff
path: root/sysdep/unix
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2013-11-22 02:12:21 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2013-11-22 02:12:21 +0100
commit8931425d02dd8656b48142f608d3119ab6f4a96f (patch)
tree197171eab5999476b02fbe3edafb823ab94c9dbe /sysdep/unix
parent548c329cde371bceef05f86b7f904378a392d89c (diff)
Fixes problem with RIP on multiple ifaces on BSD.
RIP sockets for multiple ifaces collided, because we cannot bind to a specific iface on BSD. Workarounded by SO_REUSEPORT. Thanks to Eugene M. Zheganin for the bugreport.
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/io.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index fcf5dd1d..51c6c0c1 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -1181,6 +1181,15 @@ sk_open(sock *s)
port = s->sport;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0)
ERR("SO_REUSEADDR");
+
+#ifdef CONFIG_NO_IFACE_BIND
+ /* Workaround missing ability to bind to an iface */
+ if ((type == SK_UDP) && s->iface && ipa_zero(s->saddr))
+ {
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) < 0)
+ ERR("SO_REUSEPORT");
+ }
+#endif
}
fill_in_sockaddr(&sa, s->saddr, s->iface, port);
if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0)