aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-04-21 05:26:15 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-22 22:06:06 -0400
commitfda48a0d7a8412cedacda46a9c0bf8ef9cd13559 (patch)
treef749b26dea4353c6f3bd95e49fafceb06623c20b /net/ipv6
parent24acc6895616b373475e92e49925efc3ef591563 (diff)
tcp: bind() fix when many ports are bound
Port autoselection done by kernel only works when number of bound sockets is under a threshold (typically 30000). When this threshold is over, we must check if there is a conflict before exiting first loop in inet_csk_get_port() Change inet_csk_bind_conflict() to forbid two reuse-enabled sockets to bind on same (address,port) tuple (with a non ANY address) Same change for inet6_csk_bind_conflict() Reported-by: Gaspar Chilingarov <gasparch@gmail.com> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Acked-by: Evgeniy Polyakov <zbr@ioremap.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/inet6_connection_sock.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index 628db24bcf22..b4b7d40a9c95 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -42,11 +42,16 @@ int inet6_csk_bind_conflict(const struct sock *sk,
42 if (sk != sk2 && 42 if (sk != sk2 &&
43 (!sk->sk_bound_dev_if || 43 (!sk->sk_bound_dev_if ||
44 !sk2->sk_bound_dev_if || 44 !sk2->sk_bound_dev_if ||
45 sk->sk_bound_dev_if == sk2->sk_bound_dev_if) && 45 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
46 (!sk->sk_reuse || !sk2->sk_reuse || 46 if ((!sk->sk_reuse || !sk2->sk_reuse ||
47 sk2->sk_state == TCP_LISTEN) && 47 sk2->sk_state == TCP_LISTEN) &&
48 ipv6_rcv_saddr_equal(sk, sk2)) 48 ipv6_rcv_saddr_equal(sk, sk2))
49 break; 49 break;
50 else if (sk->sk_reuse && sk2->sk_reuse &&
51 !ipv6_addr_any(inet6_rcv_saddr(sk2)) &&
52 ipv6_rcv_saddr_equal(sk, sk2))
53 break;
54 }
50 } 55 }
51 56
52 return node != NULL; 57 return node != NULL;