public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* tcp: disallow bind() to reuse addr/port regression in 2.6.38
@ 2011-04-02 18:01 Cyril Bonté
  2011-04-02 18:10 ` Eric Dumazet
  0 siblings, 1 reply; 8+ messages in thread
From: Cyril Bonté @ 2011-04-02 18:01 UTC (permalink / raw)
  To: netdev
  Cc: Eric Dumazet, Daniel Baluta, Gaspar Chilingarov, Charles Duffy,
	Willy Tarreau

Hi All,

(2nd try to fix the mailing list address)

It has been reported that kernel 2.6.38 prevented the load balancer haproxy to 
reload. After reading the kernel Changelog, it looks like the following commit 
has a negative side effect on the the way haproxy "pauses" its listening 
sockets to start a new process :

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c191a836a908d1dd6b40c503741f91b914de3348

Disabling the TCPF_CLOSE flag condition reallows to work as before. I guess 
this was done for good reasons (Sorry, I haven't found the thread about that 
commit in the archives yet) but other applications may also be impacted by 
this change.

I add Willy Tarreau to the CC to open the discussion.

Here is a simple test case to reproduce the issue (with kernel 2.6.38, it will 
fail on the second loop whereas it works with previous kernel versions) :
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>

int main(int argc, char**argv)
{
	int listenfd;
	struct sockaddr_in servaddr;
	int i;
	int one = 1;
	
	for (i = 0; i < 2; i++)
	{
		printf("LOOP %d...\n", i + 1);
		listenfd=socket(AF_INET,SOCK_STREAM,0);

		setsockopt(listenfd,SOL_SOCKET,SO_REUSEADDR,(char *)&one,sizeof(one));

		bzero(&servaddr,sizeof(servaddr));
		servaddr.sin_family = AF_INET;
		servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
		servaddr.sin_port=htons(32000);

		if (bind(listenfd,(struct sockaddr *)&servaddr,sizeof(servaddr)) != 0)
		{
			perror("bind");
			exit(1);
		}

		if (listen(listenfd,1024) != 0)
		{
			perror("listen");
			exit(1);
		}

		if (shutdown(listenfd, SHUT_WR) == 0 &&
		    listen(listenfd, 1024) == 0 &&
		    shutdown(listenfd, SHUT_RD) == 0) {
			printf("shutdown OK\n");
		}
	}
	exit(0);
}

-- 
Cyril Bonté

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-04-02 21:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-02 18:01 tcp: disallow bind() to reuse addr/port regression in 2.6.38 Cyril Bonté
2011-04-02 18:10 ` Eric Dumazet
2011-04-02 18:46   ` Cyril Bonté
2011-04-02 19:15     ` Willy Tarreau
2011-04-02 19:44       ` Eric Dumazet
2011-04-02 20:37         ` Willy Tarreau
2011-04-02 21:00           ` Cyril Bonté
2011-04-02 21:18             ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox