summaryrefslogtreecommitdiff
path: root/iface.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 /iface.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 'iface.c')
-rw-r--r--iface.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/iface.c b/iface.c
index bcbca49..ab80063 100644
--- a/iface.c
+++ b/iface.c
@@ -319,18 +319,24 @@ static void iface_rtnl_enumerate(int sock, uint16_t type, unsigned char family)
log_err("Failed to enumerate rtnl interfaces: %s\n", strerror(errno));
}
-void iface_init(int sock, const char *iface, bool ipv6,
+int iface_init(int sock, const char *iface, bool ipv6,
iface_event_handler_t event_handler)
{
INIT_LIST_HEAD(&iface_list_head);
iface_event_handler = event_handler;
- if (iface)
+ if (iface) {
iface_ifindex = if_nametoindex(iface);
+ if (!iface_ifindex) {
+ log_err("Interface %s not found: %s\n", iface, strerror(errno));
+ return -1;
+ }
+ }
/* send RTM_GETADDR request to initially populate the interface list */
iface_rtnl_enumerate(sock, RTM_GETADDR, AF_INET);
if (ipv6)
iface_rtnl_enumerate(sock, RTM_GETADDR, AF_INET6);
+ return 0;
}
int iface_recv(int sock)