Skip to contentSkip to conversation

slirp: disable Nagle in outgoing connections

PATCH In review Andreas Gustafsson 4 participants 7 messages Jan 4, 2018 – Mar 7, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 slirp: disable Nagle in outgoing connections

slirp: disable Nagle in outgoing connections

When setting up an outgoing user mode networking TCP connection, disable the Nagle algorithm in the host-side connection. Either the guest is already doing Nagle, in which case there is no point in doing it twice, or it has chosen to disable it, in which case we should respect that choice.

This change speeds up GDB remote debugging over TCP over user mode networking (with GDB runing on the guest) by multiple orders of magnitude, and has been part of the local patches applied by pkgsrc since 2012 with no reported ill effects.

---
 slirp/tcp_subr.c | 2 ++
 1 file changed, 2 insertions(+)
slirp/tcp_subr.c +2 -0
index da0d53743f..8d0f94b75f 100644
@@ -416,6 +416,8 @@ int tcp_fconnect(struct socket *so, unsigned short af)
     socket_set_fast_reuse(s);
     opt = 1;
     qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt));
+    opt = 1;
+    qemu_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt));
 
     addr = so->fhost.ss;
     DEBUG_CALL(" connect()ing")
Signature · 1 line
2.15.1
#1 lore raw

This patch is correct. LLDB expects 1sec for reply, GDB by default 2.

Debuggers use this option to disable Nagle algorithm in order to quickly transfer messages between gdb-server and gdb-client. It's also fairy portable across systems.

Quoted 8 lines · Andreas Gustafsson

slirp: disable Nagle in outgoing connections

When setting up an outgoing user mode networking TCP connection, disable the Nagle algorithm in the host-side connection. Either the guest is already doing Nagle, in which case there is no point in doing it twice, or it has chosen to disable it, in which case we should respect that choice.

Quoted 6 lines

This change speeds up GDB remote debugging over TCP over user mode networking (with GDB runing on the guest) by multiple orders of magnitude, and has been part of the local patches applied by pkgsrc since 2012 with no reported ill effects.

Quoted 18 lines
---
 slirp/tcp_subr.c | 2 ++
 1 file changed, 2 insertions(+)
slirp/tcp_subr.c +2 -0
index da0d53743f..8d0f94b75f 100644
@@ -416,6 +416,8 @@ int tcp_fconnect(struct socket *so, unsigned short af)
     socket_set_fast_reuse(s);
     opt = 1;
     qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt));
+    opt = 1;
+    qemu_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt));
 
     addr = so->fhost.ss;
     DEBUG_CALL(" connect()ing")
#2 lore raw
Quoted 15 lines · Kamil Rytarowski

This patch is correct. LLDB expects 1sec for reply, GDB by default 2.

Debuggers use this option to disable Nagle algorithm in order to quickly transfer messages between gdb-server and gdb-client. It's also fairy portable across systems.

Quoted 8 lines · Andreas Gustafsson

slirp: disable Nagle in outgoing connections

When setting up an outgoing user mode networking TCP connection, disable the Nagle algorithm in the host-side connection. Either the guest is already doing Nagle, in which case there is no point in doing it twice, or it has chosen to disable it, in which case we should respect that choice.

Quoted 8 lines
Quoted 6 lines

This change speeds up GDB remote debugging over TCP over user mode networking (with GDB runing on the guest) by multiple orders of magnitude, and has been part of the local patches applied by pkgsrc since 2012 with no reported ill effects.

I suppose you meant "Reviewed-by: Kamil Rytarowski <[email protected]>"

Quoted 21 lines
Quoted 19 lines
---
 slirp/tcp_subr.c | 2 ++
 1 file changed, 2 insertions(+)
slirp/tcp_subr.c +2 -0
index da0d53743f..8d0f94b75f 100644
@@ -416,6 +416,8 @@ int tcp_fconnect(struct socket *so, unsigned short af)
     socket_set_fast_reuse(s);
     opt = 1;
     qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt));
+    opt = 1;
+    qemu_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt));
 
     addr = so->fhost.ss;
     DEBUG_CALL(" connect()ing")
#3 lore raw
Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 20 lines · Kamil Rytarowski

This patch is correct. LLDB expects 1sec for reply, GDB by default 2.

Debuggers use this option to disable Nagle algorithm in order to quickly transfer messages between gdb-server and gdb-client. It's also fairy portable across systems.

Quoted 13 lines · Andreas Gustafsson

slirp: disable Nagle in outgoing connections

When setting up an outgoing user mode networking TCP connection, disable the Nagle algorithm in the host-side connection. Either the guest is already doing Nagle, in which case there is no point in doing it twice, or it has chosen to disable it, in which case we should respect that choice.

This change speeds up GDB remote debugging over TCP over user mode networking (with GDB runing on the guest) by multiple orders of magnitude, and has been part of the local patches applied by pkgsrc since 2012 with no reported ill effects.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I suppose you meant "Reviewed-by: Kamil Rytarowski <[email protected]>"

Correct!

Quoted 2 lines
#4 lore raw
In reply to Philippe Mathieu-Daudé

Hello,

Thanks for the Cc.

I have applied it to my tree. I don't think there is any reason to avoid the same change for ingoing connections? Could one of your review the attached patch doing it?

Samuel

commit 99a9a5028e0e15aa3b17d6f884c1e5f48dccea90

Author: Samuel Thibault <[email protected]>
Date:   Wed Mar 7 23:29:41 2018 +0100

slirp: disable Nagle in ingoing connections

This follows 3929766fb3e4 ('slirp: disable Nagle in outgoing connections'):
for the same reasons, ingoing connections should have the Nagle algorithm disabled.

slirp/socket.c +2 -0
index cb7b5b608d..81f67b5702 100644
@@ -754,6 +754,8 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
 		return NULL;
 	}
 	qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
+	opt = 1;
+	qemu_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(int));
 
 	getsockname(s,(struct sockaddr *)&addr,&addrlen);
 	so->so_ffamily = AF_INET;
#5 lore raw
Quoted 7 lines · Samuel Thibault

Hello,

Thanks for the Cc.

I have applied it to my tree. I don't think there is any reason to avoid the same change for ingoing connections? Could one of your review the attached patch doing it?

attached patch:

Quoted 3 lines

Samuel