Take source and destination address into account when determining

the scope.
This fixes a problem when a client with a global address
connects to a server with a private address.
Thanks to Irene Ruengeler in helping me to find the issue.

MFC after: 3 days
This commit is contained in:
Michael Tuexen 2015-05-28 19:28:08 +00:00
parent d60568d78a
commit 0818979a3c

View File

@ -5612,7 +5612,8 @@ do_a_abort:
stc.laddr_type = SCTP_IPV4_ADDRESS; stc.laddr_type = SCTP_IPV4_ADDRESS;
/* scope_id is only for v6 */ /* scope_id is only for v6 */
stc.scope_id = 0; stc.scope_id = 0;
if (IN4_ISPRIVATE_ADDRESS(&src4->sin_addr)) { if ((IN4_ISPRIVATE_ADDRESS(&src4->sin_addr)) ||
(IN4_ISPRIVATE_ADDRESS(&dst4->sin_addr))) {
stc.ipv4_scope = 1; stc.ipv4_scope = 1;
} }
/* Must use the address in this case */ /* Must use the address in this case */
@ -5636,16 +5637,18 @@ do_a_abort:
stc.local_scope = 0; stc.local_scope = 0;
stc.site_scope = 1; stc.site_scope = 1;
stc.ipv4_scope = 1; stc.ipv4_scope = 1;
} else if (IN6_IS_ADDR_LINKLOCAL(&src6->sin6_addr)) { } else if (IN6_IS_ADDR_LINKLOCAL(&src6->sin6_addr) ||
IN6_IS_ADDR_LINKLOCAL(&dst6->sin6_addr)) {
/* /*
* If the new destination is a * If the new destination or source
* LINK_LOCAL we must have common * is a LINK_LOCAL we must have
* both site and local scope. Don't * common both site and local scope.
* set local scope though since we * Don't set local scope though
* must depend on the source to be * since we must depend on the
* added implicitly. We cannot * source to be added implicitly. We
* assure just because we share one * cannot assure just because we
* link that all links are common. * share one link that all links are
* common.
*/ */
stc.local_scope = 0; stc.local_scope = 0;
stc.site_scope = 1; stc.site_scope = 1;
@ -5661,11 +5664,12 @@ do_a_abort:
* pull out the scope_id from * pull out the scope_id from
* incoming pkt * incoming pkt
*/ */
} else if (IN6_IS_ADDR_SITELOCAL(&src6->sin6_addr)) { } else if (IN6_IS_ADDR_SITELOCAL(&src6->sin6_addr) ||
IN6_IS_ADDR_SITELOCAL(&dst6->sin6_addr)) {
/* /*
* If the new destination is * If the new destination or source
* SITE_LOCAL then we must have site * is SITE_LOCAL then we must have
* scope in common. * site scope in common.
*/ */
stc.site_scope = 1; stc.site_scope = 1;
} }