diff options
author | Xin Long <lucien.xin@gmail.com> | 2017-02-24 02:18:46 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-02-26 21:24:05 -0500 |
commit | 2e3ce5bc2aa938653c3866aa7f4901a1f199b1c8 (patch) | |
tree | 1d84e80e6378e68fa84d47c171d0fd1d8d504005 /net/sctp/protocol.c | |
parent | 47d3a07528ecbbccf53bc4390d70b4e3d1c04fcf (diff) |
sctp: set sin_port for addr param when checking duplicate address
Commit b8607805dd15 ("sctp: not copying duplicate addrs to the assoc's
bind address list") tried to check for duplicate address before copying
to asoc's bind_addr list from global addr list.
But all the addrs' sin_ports in global addr list are 0 while the addrs'
sin_ports are bp->port in asoc's bind_addr list. It means even if it's
a duplicate address, af->cmp_addr will still return 0 as the their
sin_ports are different.
This patch is to fix it by setting the sin_port for addr param with
bp->port before comparing the addrs.
Fixes: b8607805dd15 ("sctp: not copying duplicate addrs to the assoc's bind address list")
Reported-by: Wei Chen <weichen@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/protocol.c')
-rw-r--r-- | net/sctp/protocol.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 8227bbbd077a..1b6d4574d2b0 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -199,6 +199,7 @@ int sctp_copy_local_addr_list(struct net *net, struct sctp_bind_addr *bp, | |||
199 | sctp_scope_t scope, gfp_t gfp, int copy_flags) | 199 | sctp_scope_t scope, gfp_t gfp, int copy_flags) |
200 | { | 200 | { |
201 | struct sctp_sockaddr_entry *addr; | 201 | struct sctp_sockaddr_entry *addr; |
202 | union sctp_addr laddr; | ||
202 | int error = 0; | 203 | int error = 0; |
203 | 204 | ||
204 | rcu_read_lock(); | 205 | rcu_read_lock(); |
@@ -220,7 +221,10 @@ int sctp_copy_local_addr_list(struct net *net, struct sctp_bind_addr *bp, | |||
220 | !(copy_flags & SCTP_ADDR6_PEERSUPP))) | 221 | !(copy_flags & SCTP_ADDR6_PEERSUPP))) |
221 | continue; | 222 | continue; |
222 | 223 | ||
223 | if (sctp_bind_addr_state(bp, &addr->a) != -1) | 224 | laddr = addr->a; |
225 | /* also works for setting ipv6 address port */ | ||
226 | laddr.v4.sin_port = htons(bp->port); | ||
227 | if (sctp_bind_addr_state(bp, &laddr) != -1) | ||
224 | continue; | 228 | continue; |
225 | 229 | ||
226 | error = sctp_add_bind_addr(bp, &addr->a, sizeof(addr->a), | 230 | error = sctp_add_bind_addr(bp, &addr->a, sizeof(addr->a), |