Skip to content

Commit

Permalink
sctp: set sin_port for addr param when checking duplicate address
Browse files Browse the repository at this point in the history
Commit b860780 ("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: b860780 ("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>
  • Loading branch information
lxin authored and davem330 committed Feb 27, 2017
1 parent 47d3a07 commit 2e3ce5b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/sctp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ int sctp_copy_local_addr_list(struct net *net, struct sctp_bind_addr *bp,
sctp_scope_t scope, gfp_t gfp, int copy_flags)
{
struct sctp_sockaddr_entry *addr;
union sctp_addr laddr;
int error = 0;

rcu_read_lock();
Expand All @@ -220,7 +221,10 @@ int sctp_copy_local_addr_list(struct net *net, struct sctp_bind_addr *bp,
!(copy_flags & SCTP_ADDR6_PEERSUPP)))
continue;

if (sctp_bind_addr_state(bp, &addr->a) != -1)
laddr = addr->a;
/* also works for setting ipv6 address port */
laddr.v4.sin_port = htons(bp->port);
if (sctp_bind_addr_state(bp, &laddr) != -1)
continue;

error = sctp_add_bind_addr(bp, &addr->a, sizeof(addr->a),
Expand Down

0 comments on commit 2e3ce5b

Please sign in to comment.