Skip to contentSkip to conversation

sctp: full support for ipv6 ip_nonlocal_bind & IP_FREEBIND

PATCH Superseded Laszlo Toth 2 participants 3 messages Oct 21, 2017 – Oct 23, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sctp: full support for ipv6 ip_nonlocal_bind & IP_FREEBIND

Commit 9b9742022888 ("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)

---
 net/sctp/ipv6.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/sctp/ipv6.c +3 -1
index 51c4887..ca75d2a 100644
@@ -883,7 +883,9 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr)
 			rcu_read_lock();
 			dev = dev_get_by_index_rcu(net, addr->v6.sin6_scope_id);
 			if (!dev ||
-			    !ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0)) {
+			    !(opt->inet.freebind ||
+			    net->ipv6.sysctl.ip_nonlocal_bind ||
+			    ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0))) {
 				rcu_read_unlock();
 				return 0;
 			}
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 32 lines · Laszlo Toth

Commit 9b9742022888 ("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)

---
 net/sctp/ipv6.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/sctp/ipv6.c +0 -0
index 51c4887..ca75d2a 100644

net/sctp/ipv6.c static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr) · line 888

Quoted 7 lines
net/sctp/ipv6.c +3 -1
@@ -883,7 +883,9 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr)
                        rcu_read_lock();
                        dev = dev_get_by_index_rcu(net, addr->v6.sin6_scope_id);
                        if (!dev ||
-                           !ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0)) {
+                           !(opt->inet.freebind ||
+                           net->ipv6.sysctl.ip_nonlocal_bind ||
+                           ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0))) {

pls fix your indent, like:
https://paste.fedoraproject.org/paste/ZhWmaJjepHfG~3DUp7YsBQ

Quoted 10 lines
net/sctp/ipv6.c +0 -1
                                rcu_read_unlock();
                                return 0;
                        }
--

2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#2 lore raw
In reply to Laszlo Toth
Quoted 28 lines · Xin Long
Quoted 27 lines · Laszlo Toth

Commit 9b9742022888 ("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)

---
 net/sctp/ipv6.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 14 lines

net/sctp/ipv6.c static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr) · line 888

Quoted 12 lines
net/sctp/ipv6.c +3 -1
index 51c4887..ca75d2a 100644
@@ -883,7 +883,9 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr)
                        rcu_read_lock();
                        dev = dev_get_by_index_rcu(net, addr->v6.sin6_scope_id);
                        if (!dev ||
-                           !ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0)) {
+                           !(opt->inet.freebind ||
+                           net->ipv6.sysctl.ip_nonlocal_bind ||
+                           ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0))) {

pls fix your indent, like:
https://paste.fedoraproject.org/paste/ZhWmaJjepHfG~3DUp7YsBQ

and also add cc in your next post:
network dev <[email protected]>
David S. Miller <[email protected]>

Quoted 11 lines
Quoted 11 lines
net/sctp/ipv6.c +0 -1
                                rcu_read_unlock();
                                return 0;
                        }
--

2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html