From patchwork Wed Oct 31 00:50:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10661963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DA3013BF for ; Wed, 31 Oct 2018 01:01:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE9A92A450 for ; Wed, 31 Oct 2018 01:01:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E12EB2A470; Wed, 31 Oct 2018 01:01:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 86EEF2A450 for ; Wed, 31 Oct 2018 01:01:28 +0000 (UTC) Received: from localhost ([::1]:56454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHesx-0007Nu-I0 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 21:01:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHeii-0005Cn-PV for qemu-devel@nongnu.org; Tue, 30 Oct 2018 20:50:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHeid-0002Vs-Ou for qemu-devel@nongnu.org; Tue, 30 Oct 2018 20:50:52 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34079) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHeid-0001tK-H7 for qemu-devel@nongnu.org; Tue, 30 Oct 2018 20:50:47 -0400 Received: by mail-pf1-x441.google.com with SMTP id f78-v6so6728441pfe.1 for ; Tue, 30 Oct 2018 17:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=zq6a3D/+zNJeDzjLwa3uuUFEYjitO7RuG2aH4PO9TP8=; b=cRsxSFtwWAsQw6zGczphKnHE5BGquj2Xk98jeoE59NlevPSXdSGbL0inkgcrhDfwaE w36lhyx8zXZnQ1R0QePPlMsjavtmfMBzxq2TEXv2eu9aA2FOUHb7iUMlZ2BALXo+YxVC MoMmtZmM5LboLe6o7jGlSCCYkMtv5ceGoxmZnh8DtNcNjk66dmQ4rMyFKyhmaXW+LMvn 0b4zCmTCwptMvrSdR2ktsKJAU3M+rKTrYLeE0Dpo4NEcifNHctN7DudUtzwTrPVSaywW z/dlWAR2cnQZ45edSQmaGvJ6dwiquLXSFPWeVrva9ct3QVuFYI3O8q57RHaiY3rB7+ue kowA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=zq6a3D/+zNJeDzjLwa3uuUFEYjitO7RuG2aH4PO9TP8=; b=BRvOkC79Ru8d9oc0ECnAaFHdUIs2AtlpzDxNuBeRK7H42u/WS5nBCOZnQHR5mjmJjm 0Zi/jaVFufizqc3MgaqYFWDPKBk18cY6e5VBZGAWCLljHaVc1WBa+enwmv/5AI8/dgGa nhX/zICUdHu2qUQ7+6c/zTiL8RHrGpIf2usPU1hrbNZd/IWu5+cNcgTR8Xf4jw5m90ON Ac7DPMHxNqydWzJgI6UNtTZ2Dvhqz4iqfoGJH14UDWnMNqQLNGAsEVVyy6Zao6eUEgOV DiLtQk3fuB7Yukz4ycCBNdk5gHEiNx8FNq5w+3b3bWWe6Ih1oTQJ+LyoOP65+7FND3tl k3vw== X-Gm-Message-State: AGRZ1gK4haJ/fjnnS9qDVlA+2l87iCjlE+Sag4BkJafxdeBsM6CR+JRE IyQ+fiElK6XZLMlSF7Ft9PFWYXLV X-Google-Smtp-Source: AJdET5crFMthZlZ7enpQN+eeyghuA95FwRQVnY1bTmMgG0aB0VDAd+FxK89W4xNMmlxw8YqBv62XVQ== X-Received: by 2002:a62:1693:: with SMTP id 141-v6mr1025055pfw.183.1540947026245; Tue, 30 Oct 2018 17:50:26 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id d197-v6sm42302514pga.1.2018.10.30.17.50.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 17:50:25 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org, Peter Maydell , Jason Wang Date: Wed, 31 Oct 2018 08:50:15 +0800 Message-Id: <20181031005015.5433-1-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH V2] 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: Zhang Chen , Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 bb8f4d93b1..2e26839bc2 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);