Skip to content

Commit ec5caf5

Browse files
laszlothgregkh
authored andcommitted
sctp: full support for ipv6 ip_nonlocal_bind & IP_FREEBIND
[ Upstream commit b71d21c ] Commit 9b97420 ("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: Laszlo Toth <laszlth@gmail.com> Reviewed-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 28fa583 commit ec5caf5

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

net/sctp/ipv6.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,10 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr)
881881
net = sock_net(&opt->inet.sk);
882882
rcu_read_lock();
883883
dev = dev_get_by_index_rcu(net, addr->v6.sin6_scope_id);
884-
if (!dev ||
885-
!ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0)) {
884+
if (!dev || !(opt->inet.freebind ||
885+
net->ipv6.sysctl.ip_nonlocal_bind ||
886+
ipv6_chk_addr(net, &addr->v6.sin6_addr,
887+
dev, 0))) {
886888
rcu_read_unlock();
887889
return 0;
888890
}

0 commit comments

Comments
 (0)