summaryrefslogtreecommitdiff
path: root/socket.c
diff options
context:
space:
mode:
authorJon Franklin <jvfranklin@gmail.com>2020-03-26 13:22:29 -0500
committerTobias Klauser <tklauser@distanz.ch>2020-03-28 18:41:46 +0100
commit8086a3db780f8a4ee6943a3ef2f774fc78105327 (patch)
tree748e9a4367d3a01679d419f4f08034081c38d21a /socket.c
parentfdf702ec67f8eefbd3ad5bb63f193dce01ef6201 (diff)
llmnrd: don't exit on SO_BINDTODEVICE failure
The -i option requires running llmnrd as root for SO_BINDTODEVICE to work. Packets are still filtered based on interface because only rtnl messages for addresses of the specified interface are considered in iface_nlmsg_change_addr. Instead log a warning only if SO_BINDTODEVICE fails. Signed-off-by: Jon Franklin <jvfranklin@gmail.com> [tk: small adjustments to commit message, check return value of iface_init] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/socket.c b/socket.c
index 73713eb..5f58e76 100644
--- a/socket.c
+++ b/socket.c
@@ -36,7 +36,7 @@
static const int YES = 1;
static const int TTL = 255;
-static int socket_bind_to_device(int sock, const char *iface) {
+static void socket_bind_to_device(int sock, const char *iface) {
#ifdef SO_BINDTODEVICE
/* bind socket to specific interface */
if (iface) {
@@ -45,12 +45,10 @@ static int socket_bind_to_device(int sock, const char *iface) {
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name) - 1);
if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) < 0) {
- log_err("Failed to bind socket to device %s: %s\n", iface, strerror(errno));
- return -1;
+ log_warn("Failed to bind socket to device %s: %s\n", iface, strerror(errno));
}
}
#endif
- return 0;
}
int socket_open_ipv4(uint16_t port, const char *iface)
@@ -81,8 +79,7 @@ int socket_open_ipv4(uint16_t port, const char *iface)
goto err;
}
- if (socket_bind_to_device(sock, iface) < 0)
- goto err;
+ socket_bind_to_device(sock, iface);
/* bind the socket */
memset(&sa, 0, sizeof(sa));
@@ -140,8 +137,7 @@ int socket_open_ipv6(uint16_t port, const char *iface)
goto err;
}
- if (socket_bind_to_device(sock, iface) < 0)
- goto err;
+ socket_bind_to_device(sock, iface);
/* bind the socket */
memset(&sa, 0, sizeof(sa));