diff options
author | tuexen <tuexen@FreeBSD.org> | 2015-05-28 19:28:08 +0000 |
---|---|---|
committer | tuexen <tuexen@FreeBSD.org> | 2015-05-28 19:28:08 +0000 |
commit | a864af135831528ff3a72d962567b12fbb560d6b (patch) | |
tree | 4876644cdf1f27dc9fc23a195f3f2fec8a013cfc /sys/netinet/sctp_output.c | |
parent | 2ff25b445e021df14558d0b4a1ce700d67e36907 (diff) | |
download | FreeBSD-src-a864af135831528ff3a72d962567b12fbb560d6b.zip FreeBSD-src-a864af135831528ff3a72d962567b12fbb560d6b.tar.gz |
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
Diffstat (limited to 'sys/netinet/sctp_output.c')
-rw-r--r-- | sys/netinet/sctp_output.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 47a341c..d2ada5d 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -5612,7 +5612,8 @@ do_a_abort: stc.laddr_type = SCTP_IPV4_ADDRESS; /* scope_id is only for v6 */ 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; } /* Must use the address in this case */ @@ -5636,16 +5637,18 @@ do_a_abort: stc.local_scope = 0; stc.site_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 - * LINK_LOCAL we must have common - * both site and local scope. Don't - * set local scope though since we - * must depend on the source to be - * added implicitly. We cannot - * assure just because we share one - * link that all links are common. + * If the new destination or source + * is a LINK_LOCAL we must have + * common both site and local scope. + * Don't set local scope though + * since we must depend on the + * source to be added implicitly. We + * cannot assure just because we + * share one link that all links are + * common. */ stc.local_scope = 0; stc.site_scope = 1; @@ -5661,11 +5664,12 @@ do_a_abort: * pull out the scope_id from * 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 - * SITE_LOCAL then we must have site - * scope in common. + * If the new destination or source + * is SITE_LOCAL then we must have + * site scope in common. */ stc.site_scope = 1; } |