Skip to contentSkip to conversation

slirp: Port redirection option behave differently on Linux and Windows

PATCH Applied Taimoor 3 participants 3 messages Aug 15, 2013 – Sep 1, 2013

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore

Taimoor

author
#0 lore raw

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
index 8e8819c..e4685bb 100644
@@ -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
#1 lore raw

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
index 8e8819c..e4685bb 100644
@@ -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
#2 lore raw
In reply to Taimoor
Quoted 7 lines · Taimoor

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

Thanks, applied to the trivial-patches queue (after fixing the diff as mentioned by Alex Bligh).

/mjt