diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 2ed689a..3226970 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -114,6 +114,8 @@ ipv4_connected: goto out; } + fl.oif = sk->sk_bound_dev_if; + if (addr_type&IPV6_ADDR_LINKLOCAL) { if (addr_len >= sizeof(struct sockaddr_in6) && usin->sin6_scope_id) { @@ -122,14 +124,14 @@ ipv4_connected: err = -EINVAL; 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; + fl.oif = sk->sk_bound_dev_if = usin->sin6_scope_id; } + if (!fl.oif && (addr_type & IPV6_ADDR_MULTICAST)) + fl.oif = np->mcast_oif; + /* Connect to link-local address requires an interface */ - if (!sk->sk_bound_dev_if) { + if (!fl.oif) { err = -EINVAL; goto out; } @@ -148,7 +150,6 @@ ipv4_connected: fl.proto = sk->sk_protocol; ipv6_addr_copy(&fl.fl6_dst, &np->daddr); ipv6_addr_copy(&fl.fl6_src, &np->saddr); - fl.oif = sk->sk_bound_dev_if; fl.fl_ip_dport = inet->dport; fl.fl_ip_sport = inet->sport;