From: Brian Haley Date: Thu, 11 Oct 2007 21:39:29 +0000 (-0700) Subject: [IPv6]: Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493, try2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4953f0fcc06a125f87874743d968c0e185c8b296;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git [IPv6]: Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493, try2 From RFC 3493, Section 5.2: IPV6_MULTICAST_IF Set the interface to use for outgoing multicast packets. The argument is the index of the interface to use. If the interface index is specified as zero, the system selects the interface (for example, by looking up the address in a routing table and using the resulting interface). This patch adds support for (index == 0) to reset the value to it's original state, allowing the system to choose the best interface. IPv4 already behaves this way. Signed-off-by: Brian Haley Acked-by: David L Stevens Signed-off-by: David S. Miller --- diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 532425db11f..1334fc174bc 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -539,12 +539,15 @@ done: case IPV6_MULTICAST_IF: if (sk->sk_type == SOCK_STREAM) goto e_inval; - if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val) - goto e_inval; - if (__dev_get_by_index(&init_net, val) == NULL) { - retv = -ENODEV; - break; + if (val) { + if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val) + goto e_inval; + + if (__dev_get_by_index(&init_net, val) == NULL) { + retv = -ENODEV; + break; + } } np->mcast_oif = val; retv = 0;