From patchwork Tue Sep 10 13:26:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ottlik X-Patchwork-Id: 273868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A9DF82C027A for ; Tue, 10 Sep 2013 23:28:27 +1000 (EST) Received: from localhost ([::1]:57914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJNzV-0000cD-HI for incoming@patchwork.ozlabs.org; Tue, 10 Sep 2013 09:28:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJNyx-0000QX-Vg for qemu-devel@nongnu.org; Tue, 10 Sep 2013 09:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJNys-00046P-0z for qemu-devel@nongnu.org; Tue, 10 Sep 2013 09:27:51 -0400 Received: from ex-e-2.perimeter.fzi.de ([141.21.8.251]:32276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJNyr-000466-OA for qemu-devel@nongnu.org; Tue, 10 Sep 2013 09:27:45 -0400 Received: from ex-ca-ht-1.fzi.de (141.21.32.98) by ex-e-2.perimeter.fzi.de (141.21.8.251) with Microsoft SMTP Server (TLS) id 14.3.158.1; Tue, 10 Sep 2013 15:27:40 +0200 Received: from orcrist.fzi.de (2a02:788:13:20:d404:ba6c:e1b2:651d) by ex-ca-ht-1.fzi.de (2a02:788:13:20::8d15:2062) with Microsoft SMTP Server id 14.3.158.1; Tue, 10 Sep 2013 15:27:44 +0200 Received: by orcrist.fzi.de (Postfix, from userid 330838105) id 9C7A71C05CA; Tue, 10 Sep 2013 15:27:44 +0200 (CEST) From: Sebastian Ottlik To: Date: Tue, 10 Sep 2013 15:26:57 +0200 Message-ID: <1378819619-20579-5-git-send-email-ottlik@fzi.de> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1378819619-20579-1-git-send-email-ottlik@fzi.de> References: <1378819619-20579-1-git-send-email-ottlik@fzi.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 141.21.8.251 Cc: Jan Kiszka , Anthony Liguori , Sebastian Ottlik , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v3 4/5] slirp: call socket_set_fast_reuse instead of setting SO_REUSEADDR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org SO_REUSEADDR should be avoided on Windows but is desired on other operating systems. So instead of setting it we call socket_set_fast_reuse that will result in the appropriate behaviour on all operating systems. Signed-off-by: Sebastian Ottlik --- slirp/misc.c | 3 +-- slirp/socket.c | 4 +--- slirp/tcp_subr.c | 6 ++---- slirp/udp.c | 4 ++-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/slirp/misc.c b/slirp/misc.c index c0d4899..6c1636f 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -212,8 +212,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty) so->s = accept(s, (struct sockaddr *)&addr, &addrlen); } while (so->s < 0 && errno == EINTR); closesocket(s); - opt = 1; - qemu_setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)); + socket_set_fast_reuse(so->s); opt = 1; qemu_setsockopt(so->s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int)); qemu_set_nonblock(so->s); diff --git a/slirp/socket.c b/slirp/socket.c index 25d60e7..37ac5cf 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -627,9 +627,7 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, addr.sin_port = hport; if (((s = qemu_socket(AF_INET,SOCK_STREAM,0)) < 0) || -#ifndef _WIN32 - (qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)) < 0) || -#endif + (socket_set_fast_reuse(s) < 0) || (bind(s,(struct sockaddr *)&addr, sizeof(addr)) < 0) || (listen(s,1) < 0)) { int tmperrno = errno; /* Don't clobber the real reason we failed */ diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index 043f28f..7571c5a 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -337,8 +337,7 @@ int tcp_fconnect(struct socket *so) struct sockaddr_in addr; qemu_set_nonblock(s); - opt = 1; - qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); + socket_set_fast_reuse(s); opt = 1; qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt)); @@ -426,8 +425,7 @@ void tcp_connect(struct socket *inso) return; } qemu_set_nonblock(s); - opt = 1; - qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)); + socket_set_fast_reuse(s); opt = 1; qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int)); socket_set_nodelay(s); diff --git a/slirp/udp.c b/slirp/udp.c index b105f87..8cc6cb6 100644 --- a/slirp/udp.c +++ b/slirp/udp.c @@ -354,7 +354,7 @@ udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, { struct sockaddr_in addr; struct socket *so; - socklen_t addrlen = sizeof(struct sockaddr_in), opt = 1; + socklen_t addrlen = sizeof(struct sockaddr_in); so = socreate(slirp); if (!so) { @@ -372,7 +372,7 @@ udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, udp_detach(so); return NULL; } - qemu_setsockopt(so->s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)); + socket_set_fast_reuse(so->s); getsockname(so->s,(struct sockaddr *)&addr,&addrlen); so->so_fport = addr.sin_port;