From patchwork Thu Apr 7 11:04:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 8771111 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AB965C0553 for ; Thu, 7 Apr 2016 11:04:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 194A5201EC for ; Thu, 7 Apr 2016 11:04:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6166A2011E for ; Thu, 7 Apr 2016 11:04:44 +0000 (UTC) Received: from localhost ([::1]:48956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ao7jv-0005hu-OP for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Apr 2016 07:04:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ao7jc-0005Vi-FQ for qemu-devel@nongnu.org; Thu, 07 Apr 2016 07:04:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ao7jZ-0007dW-Ky for qemu-devel@nongnu.org; Thu, 07 Apr 2016 07:04:24 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:9020) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ao7jZ-0007cy-EK for qemu-devel@nongnu.org; Thu, 07 Apr 2016 07:04:21 -0400 X-IronPort-AV: E=Sophos;i="5.24,449,1454972400"; d="scan'208";a="173049774" Received: from unknown (HELO var.youpi.perso.aquilenet.fr) ([193.50.110.219]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 07 Apr 2016 13:04:14 +0200 Received: from samy by var.youpi.perso.aquilenet.fr with local (Exim 4.87) (envelope-from ) id 1ao7jS-0005Wx-7P; Thu, 07 Apr 2016 13:04:14 +0200 From: Samuel Thibault To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Thu, 7 Apr 2016 13:04:12 +0200 Message-Id: <1460027053-21211-4-git-send-email-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1460027053-21211-1-git-send-email-samuel.thibault@ens-lyon.org> References: <1460027053-21211-1-git-send-email-samuel.thibault@ens-lyon.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.134.164.104 Cc: "Edgar E . Iglesias" , jan.kiszka@siemens.com, steven@steven676.net, Steven Luo , Samuel Thibault , "Edgar E. Iglesias" Subject: [Qemu-devel] [PULL 3/4] slirp: Propagate host TCP RST to the guest. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Edgar E. Iglesias" When the host aborts (RST) its 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. Signed-off-by: Edgar E. Iglesias [steven@steven676.net: coding style adjustments] Signed-off-by: Steven Luo Signed-off-by: Samuel Thibault --- slirp/socket.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/slirp/socket.c b/slirp/socket.c index 7f022a6..0d67b12 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -176,9 +176,24 @@ soread(struct socket *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; } }