Bug 62051
Summary: | SCTP fails to bind to link-local IPv6 address. | ||
---|---|---|---|
Product: | Networking | Reporter: | Ben Greear (greearb) |
Component: | IPV6 | Assignee: | Hideaki YOSHIFUJI (yoshfuji) |
Status: | NEW --- | ||
Severity: | normal | CC: | ellydwivedi2093, lucien.xin, szg00000 |
Priority: | P1 | ||
Hardware: | All | ||
OS: | Linux | ||
Kernel Version: | 3.9.11+ | Subsystem: | |
Regression: | No | Bisected commit-id: |
Description
Ben Greear
2013-09-25 03:46:09 UTC
the reason is that : sctp_do_bind invoke sctp_inet6_bind_verify(),which have the following limit: ... if (type & IPV6_ADDR_LINKLOCAL) { struct net *net; if (!addr->v6.sin6_scope_id) <=== the limit return 0; net = sock_net(&opt->inet.sk); 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)) { rcu_read_unlock(); return 0; } rcu_read_unlock(); } else if (type == IPV6_ADDR_MAPPED) { ... so it's not a bug , you can workaround it like: 1.add a line: aiHead->ai_addr.sin6_scope_id=3 (3 is the dev's ifindex , you need to know it). or, 2.getting your sockaddr to bind from getifaddrs(), which will fill out the scope id for you. note: sin6_scope_id is net_device's ifindex when sockaddr is link local addr in ipv6. @lucien I was wondering if you could point to the easiest way to test this bug. I am a novice and this is my first try at fixing a bug. Thanks, Aarti (In reply to lucien from comment #1) > the reason is that : sctp_do_bind invoke sctp_inet6_bind_verify(),which have > the following limit: > ... > if (type & IPV6_ADDR_LINKLOCAL) { > struct net *net; > if (!addr->v6.sin6_scope_id) <=== the limit > return 0; > net = sock_net(&opt->inet.sk); > 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)) { > rcu_read_unlock(); > return 0; > } > rcu_read_unlock(); > } else if (type == IPV6_ADDR_MAPPED) { > ... > > so it's not a bug , you can workaround it like: > 1.add a line: aiHead->ai_addr.sin6_scope_id=3 (3 is the dev's ifindex , you > need to know it). > > or, > 2.getting your sockaddr to bind from getifaddrs(), which will fill out the > scope id for you. > > note: sin6_scope_id is net_device's ifindex when sockaddr is link local addr > in ipv6. |