diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 2ed689a..0b1e7eb 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -123,9 +123,15 @@ ipv4_connected: goto out; } sk->sk_bound_dev_if = usin->sin6_scope_id; - if (!sk->sk_bound_dev_if && - (addr_type & IPV6_ADDR_MULTICAST)) - fl.oif = np->mcast_oif; + } + + if ((addr_type & IPV6_ADDR_MULTICAST) && np->mcast_oif) { + if (sk->sk_bound_dev_if && + sk->sk_bound_dev_if != np->mcast_oif) { + err = -EINVAL; + goto out; + } + sk->sk_bound_dev_if = np->mcast_oif; } /* Connect to link-local address requires an interface */