From patchwork Fri Nov 16 03:43:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 998726 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42x3xx1KQBz9sBn for ; Fri, 16 Nov 2018 14:44:19 +1100 (AEDT) Received: from localhost ([::1]:42020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNV3H-0000jR-U5 for incoming@patchwork.ozlabs.org; Thu, 15 Nov 2018 22:44:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNV2s-0000j9-PU for qemu-devel@nongnu.org; Thu, 15 Nov 2018 22:43:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNV2s-0007mM-4k for qemu-devel@nongnu.org; Thu, 15 Nov 2018 22:43:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47224) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gNV2o-0007jn-B9 for qemu-devel@nongnu.org; Thu, 15 Nov 2018 22:43:48 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E9FC3C05D3F4; Fri, 16 Nov 2018 03:43:38 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-23.pek2.redhat.com [10.72.12.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A65A6129F; Fri, 16 Nov 2018 03:43:35 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Fri, 16 Nov 2018 11:43:31 +0800 Message-Id: <1542339811-18549-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1542339811-18549-1-git-send-email-jasowang@redhat.com> References: <1542339811-18549-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 16 Nov 2018 03:43:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL] net/filter-rewriter.c: Fix coverity static analysis issue X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , Zhang Chen Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Zhang Chen The original code just follow the TCP state diagram, but in this case, we can skip the TCPS_TIME_WAIT state to simplify the implementation. Signed-off-by: Zhang Chen Signed-off-by: Jason Wang --- net/filter-rewriter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index bb8f4d9..2e26839 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -155,12 +155,13 @@ static int handle_primary_tcp_pkt(RewriterState *rf, * Active close step 2. */ if (conn->tcp_state == TCPS_FIN_WAIT_1) { - conn->tcp_state = TCPS_TIME_WAIT; /* * For simplify implementation, we needn't wait 2MSL time * in filter rewriter. Because guest kernel will track the * TCP status and wait 2MSL time, if client resend the FIN * packet, guest will apply the last ACK too. + * So, we skip the TCPS_TIME_WAIT state here and go straight + * to TCPS_CLOSED state. */ conn->tcp_state = TCPS_CLOSED; g_hash_table_remove(rf->connection_track_table, key);