summaryrefslogtreecommitdiff
path: root/sysdep/unix/io.c
diff options
context:
space:
mode:
authorAlexander Zubkov <green@qrator.net>2022-01-08 18:31:56 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2022-01-08 19:02:31 +0100
commit87a02489f3880689a4e2ad72b0b981649dad2154 (patch)
treeb5e486015ab7907bf165ae20851290258e72114d /sysdep/unix/io.c
parentbcb25084d31fdb90fcf1666f10e73fe0f863afc0 (diff)
IO: Support nonlocal bind in socket interface
Add option to socket interface for nonlocal binding, i.e. binding to an IP address that is not present on interfaces. This behaviour is enabled when SKF_FREEBIND socket flag is set. For Linux systems, it is implemented by IP_FREEBIND socket flag. Minor changes done by commiter.
Diffstat (limited to 'sysdep/unix/io.c')
-rw-r--r--sysdep/unix/io.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 3d67d0a7..4fd77453 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -1436,6 +1436,10 @@ sk_open(sock *s)
if (sk_set_high_port(s) < 0)
log(L_WARN "Socket error: %s%#m", s->err);
+ if (s->flags & SKF_FREEBIND)
+ if (sk_set_freebind(s) < 0)
+ log(L_WARN "Socket error: %s%#m", s->err);
+
sockaddr_fill(&sa, s->af, bind_addr, s->iface, bind_port);
if (bind(fd, &sa.sa, SA_LEN(sa)) < 0)
ERR2("bind");