Commit b71d21c2 authored by Laszlo Toth's avatar Laszlo Toth Committed by David S. Miller

sctp: full support for ipv6 ip_nonlocal_bind & IP_FREEBIND

Commit 9b974202 ("sctp: support ipv6 nonlocal bind")
introduced support for the above options as v4 sctp did,
so patched sctp_v6_available().

In the v4 implementation it's enough, because
sctp_inet_bind_verify() just returns with sctp_v4_available().
However sctp_inet6_bind_verify() has an extra check before that
for link-local scope_id, which won't respect the above options.

Added the checks before calling ipv6_chk_addr(), but
not before the validation of scope_id.

before (w/ both options):
 ./v6test fe80::10 sctp
 bind failed, errno: 99 (Cannot assign requested address)
 ./v6test fe80::10 tcp
 bind success, errno: 0 (Success)

after (w/ both options):
 ./v6test fe80::10 sctp
 bind success, errno: 0 (Success)
Signed-off-by: default avatarLaszlo Toth <laszlth@gmail.com>
Reviewed-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 082297e6
...@@ -882,8 +882,10 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr) ...@@ -882,8 +882,10 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr)
net = sock_net(&opt->inet.sk); net = sock_net(&opt->inet.sk);
rcu_read_lock(); rcu_read_lock();
dev = dev_get_by_index_rcu(net, addr->v6.sin6_scope_id); dev = dev_get_by_index_rcu(net, addr->v6.sin6_scope_id);
if (!dev || if (!dev || !(opt->inet.freebind ||
!ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0)) { net->ipv6.sysctl.ip_nonlocal_bind ||
ipv6_chk_addr(net, &addr->v6.sin6_addr,
dev, 0))) {
rcu_read_unlock(); rcu_read_unlock();
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment