Subject: Re: PROBLEM: Linux kernel 2.6.31 IPv4 TCP fails to open huge amount of outgoing connections (unable to bind ... )

From: Evgeniy Polyakov <[email-masked]>
Date: Wed, 21 Apr 2010 04:14:48 +0400

Hi.

On Wed, Apr 21, 2010 at 01:42:25AM +0200, Eric Dumazet ([email-masked]) wrote:
> If you want to check source, its in file net/ipv4/inet_connection_sock.c
> 
> function inet_csk_get_port()
> 
> you can remove the 
> 
> if (atomic_read(&hashinfo->bsockets) > (high - low) + 1) { 
> 	spin_unlock(&head->lock); 
> 	snum = smallest_rover; 
> 	goto have_snum;
> }
> 
> It will solve your problem (but bind() will probably be slow)

Netcat uses SO_REUSEADDR, so its the code path which generates an error,
but this part actually returns a port number not en error. I suppose
what happend is 'attempts' check faired and thus system failed to find
a small enough bucket which does not conflict. To test this we can
remove 'smallest_size = tb->num_owners;' assignment, but bind() can be
damn slow in this case indeed.

-- 
	Evgeniy Polyakov