changeset 4474:5038198ddbae draft

sun: Bind IPv6ND socket to interface. Just to be on the safe side as it is per interface ....
author Roy Marples <roy@marples.name>
date Tue, 23 Apr 2019 18:54:39 +0000
parents f6e589475882
children 0f69a209f608
files src/ipv6nd.c
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ipv6nd.c	Tue Apr 23 19:53:59 2019 +0100
+++ b/src/ipv6nd.c	Tue Apr 23 18:54:39 2019 +0000
@@ -242,6 +242,7 @@
 	    .ipv6mr_interface = ifp->index
 	};
 	struct rs_state *state = RS_STATE(ifp);
+	uint_t ifindex = ifp->index;
 
 	if (state->nd_fd != -1)
 		return state->nd_fd;
@@ -250,6 +251,13 @@
 	if (s == -1)
 		return -1;
 
+	if (setsockopt(s, IPPROTO_IPV6, IPV6_BOUND_IF,
+	    &ifindex, sizeof(ifindex)) == -1)
+	{
+		close(s);
+		return -1;
+	}
+
 	if (setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP,
 	    &mreq, sizeof(mreq)) == -1)
 	{