slirp: Port redirection option behave differently on Linux and Windows
PATCH v2 1/1 slirp: Port redirection option behave differently on Linux and Windows
From: Taimoor Mirza <[email protected]>
port redirection code uses SO_REUSEADDR socket option before binding to host port. Behavior of SO_REUSEADDR is different on Windows and Linux. Relaunching QEMU with same host and guest port redirection values on Linux throws error but on Windows it does not throw any error.
Problem is discussed in http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg03089.html
---
Changed #ifdef to #ifndef as SO_REUSEADDR should not be set in case of Windows.
slirp/socket.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
slirp/socket.c +3 -1
@@ -1,4 +1,4 @@ -/* +x/* * Copyright (c) 1995 Danny Gasparovski. * * Please read the file COPYRIGHT for the
@@ -627,7 +627,9 @@ 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 (bind (s,(struct sockaddr *)&addr,sizeof (addr)) <0 ) || (listen (s,1 ) <0 )) {int tmperrno = errno;/* Don't clobber the real reason we failed */
Signature · 1 line
1.7.5.4
slirp/socket.c tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport,
Quoted 11 lines · --On 15 August 2013 23:13:28 +0500 Taimoor <[email protected]> wrote:
slirp/socket.c +1
-1@@ -1,4 +1,4 @@ -/* +x/* * Copyright (c) 1995 Danny Gasparovski. * * Please read the file COPYRIGHT for the @@ -627,7 +627,9 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport,
You appear to have introduced an additional character at the top of the file.
Signature · 1 line
Alex Bligh
Michael Tokarev
AppliedQuoted 7 lines · Taimoor
From: Taimoor Mirza <[email protected]>
port redirection code uses
SO_REUSEADDRsocket option before binding to host port. Behavior ofSO_REUSEADDRis different on Windows and Linux. Relaunching QEMU with same host and guest port redirection values on Linux throws error but on Windows it does not throw any error.
Problem is discussed in http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg03089.html
Thanks, applied to the trivial-patches queue (after fixing the diff as mentioned by Alex Bligh).
/mjt