summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-network/icmp6-util.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsystemd-network/icmp6-util.c b/src/libsystemd-network/icmp6-util.c
index acad9d7d6a..d81e9ebd88 100644
--- a/src/libsystemd-network/icmp6-util.c
+++ b/src/libsystemd-network/icmp6-util.c
@@ -26,6 +26,7 @@
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
+#include <net/if.h>
#include <linux/if_packet.h>
#include "fd-util.h"
@@ -47,6 +48,7 @@ int icmp6_bind_router_solicitation(int index) {
.ipv6mr_interface = index,
};
_cleanup_close_ int s = -1;
+ char ifname[IF_NAMESIZE] = "";
int r, zero = 0, one = 1, hops = 255;
s = socket(AF_INET6, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, IPPROTO_ICMPV6);
@@ -83,6 +85,13 @@ int icmp6_bind_router_solicitation(int index) {
if (r < 0)
return -errno;
+ if (if_indextoname(index, ifname) == 0)
+ return -errno;
+
+ r = setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, ifname, strlen(ifname));
+ if (r < 0)
+ return -errno;
+
r = s;
s = -1;
return r;