From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K6YAc-0008Gx-Ht for qemu-devel@nongnu.org; Wed, 11 Jun 2008 17:47:54 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K6YAb-0008GY-6Z for qemu-devel@nongnu.org; Wed, 11 Jun 2008 17:47:54 -0400 Received: from [199.232.76.173] (port=38749 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K6YAb-0008GR-09 for qemu-devel@nongnu.org; Wed, 11 Jun 2008 17:47:53 -0400 Received: from miranda.se.axis.com ([193.13.178.8]:46243) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K6YAa-0003j4-HN for qemu-devel@nongnu.org; Wed, 11 Jun 2008 17:47:52 -0400 Received: from axis.com (edgar.se.axis.com [10.93.151.1]) by miranda.se.axis.com (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id m5BLloRH025806 for ; Wed, 11 Jun 2008 23:47:50 +0200 Date: Wed, 11 Jun 2008 23:47:50 +0200 From: "Edgar E. Iglesias" Message-ID: <20080611214750.GD20729@edgar.se.axis.com> References: <485009A9.6000900@windriver.com> <20080611180739.GA20729@edgar.se.axis.com> <20080611193712.GB20729@edgar.se.axis.com> <4850313B.8030304@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4850313B.8030304@windriver.com> Subject: [Qemu-devel] [PATCH] slirp: Propagate host TCP RST to the guest. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, Jason found a bug in teh slirp TCP RST code. Here is a patch to fix it. Is this OK to commit? Best regards -- Edgar E. Iglesias Axis Communications AB When the host aborts (RST) it's side of a TCP connection we need to propagate that RST to the guest. The current code can leave such guest connections dangling forever. Spotted by Jason Wessel. diff --git a/slirp/socket.c b/slirp/socket.c index 75003af..bb10d69 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -165,9 +165,21 @@ soread(so) if (nn < 0 && (errno == EINTR || errno == EAGAIN)) return 0; else { + int err; + socklen_t slen = sizeof err; + + err = errno; + if (nn == 0) + getsockopt(so->s, SOL_SOCKET, SO_ERROR, + &err, &slen); + DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno))); sofcantrcvmore(so); - tcp_sockclosed(sototcpcb(so)); + if (err == ECONNRESET + || err == ENOTCONN || err == EPIPE) + tcp_drop(sototcpcb(so), err); + else + tcp_sockclosed(sototcpcb(so)); return -1; } }