From 6ee7781d8464dc3298b1157389df9785e20ce041 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 11 May 2018 23:54:05 +0200 Subject: slirp: clean up guestfwd command execution The previous guestfwd command execution functionality created a TCP socket for communication with the child. Besides being convoluted, this also had a practical performance issue: communications with the child process (e.g. netcat) could stall for 40ms due to delayed ack. As fork_exec has a lot of cruft (unused telnetd/pty code, whitespace issues, racy connect/accept logic) and a buffer overflow while building argv in the child ("guestfwd=tcp:0.0.0.0:80-cmd:$(printf %300s)"), just rewrite the whole thing to use socketpair with a local socket. Tested with a Windows 7 guest, using guestfwd (+netcat) to connect to a SMB server. Executing an installer from the share now does not take ages and a packet capture shows no 40ms latency in the guest. Signed-off-by: Peter Wu --- slirp/tcp_subr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'slirp/tcp_subr.c') diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index da0d53743f..f7ab06479a 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -954,7 +954,6 @@ int tcp_ctl(struct socket *so) Slirp *slirp = so->slirp; struct sbuf *sb = &so->so_snd; struct ex_list *ex_ptr; - int do_pty; DEBUG_CALL("tcp_ctl"); DEBUG_ARG("so = %p", so); @@ -969,9 +968,10 @@ int tcp_ctl(struct socket *so) so->extra = (void *)ex_ptr->ex_exec; return 1; } - do_pty = ex_ptr->ex_pty; + /* TODO rename ex_pty to something more sensible. */ + g_assert(ex_ptr->ex_pty == 0); DEBUG_MISC((dfd, " executing %s\n", ex_ptr->ex_exec)); - return fork_exec(so, ex_ptr->ex_exec, do_pty); + return fork_exec(so, ex_ptr->ex_exec); } } } -- cgit v1.2.1