[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <201104022001.48144.cyril.bonte@free.fr>
Date: Sat, 2 Apr 2011 20:01:47 +0200
From: Cyril Bonté <cyril.bonte@...e.fr>
To: netdev@...r.kernel.org
Cc: Eric Dumazet <eric.dumazet@...il.com>,
Daniel Baluta <daniel.baluta@...il.com>,
Gaspar Chilingarov <gasparch@...il.com>,
Charles Duffy <charles@...is.net>, Willy Tarreau <w@....eu>
Subject: tcp: disallow bind() to reuse addr/port regression in 2.6.38
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é
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists