提交 4953f0fc 编写于 作者: B Brian Haley 提交者: David S. Miller

[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: NBrian Haley <brian.haley@hp.com>
Acked-by: NDavid L Stevens <dlstevens@us.ibm.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 73aaf935
...@@ -539,12 +539,15 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, ...@@ -539,12 +539,15 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
case IPV6_MULTICAST_IF: case IPV6_MULTICAST_IF:
if (sk->sk_type == SOCK_STREAM) if (sk->sk_type == SOCK_STREAM)
goto e_inval; 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) { if (val) {
retv = -ENODEV; if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
break; goto e_inval;
if (__dev_get_by_index(&init_net, val) == NULL) {
retv = -ENODEV;
break;
}
} }
np->mcast_oif = val; np->mcast_oif = val;
retv = 0; retv = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册