summaryrefslogtreecommitdiff
path: root/socket.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2016-08-16 10:08:01 +0200
committerTobias Klauser <tklauser@distanz.ch>2016-08-16 10:08:01 +0200
commitf1081b6b0f47160f83ded689d956bd577819d752 (patch)
tree4ecb5f7701b8104a39f87c23ef845b32bc140b47 /socket.c
parent348e1614d6ddb9fdc3c0c9c8389753d2d9cc0314 (diff)
llmnrd: Don't enumerate and store IPv6 addresses if IPv6 is disabled
Currently IPv6 addresses are always enumerated via RTNL socket and then stored internally, even if llmnrd was started without the IPv6 command line option '-6'. Even though no queries on AF_INET6 sockets will be answered, this behavior might be confusing. Especially due to messages like: Added IPv6 address fe80::f0eb:aaff:feb3:ae58 on interface tap0 being logged. Explicitely disable IPv6 address enumeration on the RTNL socket to fix this behavior. Closes #8 Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/socket.c b/socket.c
index 872796d..21e715a 100644
--- a/socket.c
+++ b/socket.c
@@ -136,7 +136,7 @@ err:
return -1;
}
-int socket_open_rtnl(void)
+int socket_open_rtnl(bool ipv6)
{
int sock;
struct sockaddr_nl sa;
@@ -153,9 +153,11 @@ int socket_open_rtnl(void)
* listen for following events:
* - network interface create/delete/up/down
* - IPv4 address add/delete
- * - IPv6 address add/delete
+ * - IPv6 address add/delete (if enabled)
*/
- sa.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR;
+ sa.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR;
+ if (ipv6)
+ sa.nl_groups |= RTMGRP_IPV6_IFADDR;
if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
log_err("Failed to bind() netlink socket: %s\n", strerror(errno));