Skip to content

Commit

Permalink
tcp: bind() fix autoselection to share ports
Browse files Browse the repository at this point in the history
The current code checks for conflicts when the application
requests a specific port.  If there is no conflict, then
the request is granted.

On the other hand, the port autoselection done by the kernel
fails when all ports are bound even when there is a port
with no conflict available.

The fix changes port autoselection to check if there is a
conflict and use it if not.

Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Marcelo Ricardo Leitner <mleitner@redhat.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Flavio Leitner authored and David S. Miller committed Jan 26, 2012
1 parent 6831580 commit 2b05ad3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions net/ipv4/inet_connection_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
goto have_snum;
}
}
if (!inet_csk(sk)->icsk_af_ops->bind_conflict(sk, tb)) {
spin_unlock(&head->lock);
snum = rover;
goto have_snum;
}
goto next;
}
break;
Expand Down

0 comments on commit 2b05ad3

Please sign in to comment.