From patchwork Tue Oct 30 03:50:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10660435 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 8831413BF for ; Tue, 30 Oct 2018 03:51:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 704F1299CC for ; Tue, 30 Oct 2018 03:51:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60FD0299F9; Tue, 30 Oct 2018 03:51:34 +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 E1BF1299CC for ; Tue, 30 Oct 2018 03:51:33 +0000 (UTC) Received: from localhost ([::1]:50557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHL40-0003hN-JT for patchwork-qemu-devel@patchwork.kernel.org; Mon, 29 Oct 2018 23:51:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHL3N-0003OM-VI for qemu-devel@nongnu.org; Mon, 29 Oct 2018 23:50:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHL3K-0006gY-83 for qemu-devel@nongnu.org; Mon, 29 Oct 2018 23:50:53 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:34088) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHL3K-0006fp-0f for qemu-devel@nongnu.org; Mon, 29 Oct 2018 23:50:50 -0400 Received: by mail-pl1-x641.google.com with SMTP id f10-v6so4847710plr.1 for ; Mon, 29 Oct 2018 20:50:49 -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=wJVvr0R8vRxwzDw5Od78sw3+IQHhFknkMJaBgCzyd7k=; b=pmLceoGXJgZYVQi3ptxY6CbD24CRuTlvjEG1ocC1TaZC4/QaWnb2H/dhWBRLN4zJWM H8ZbBsdAsWIQQ05/OpKeSJ9f2rDTAfqO7lNCM8CDOF27JH5YLB2ePpMp5izWrd3LmQHw I2q2V2KjfW+9wG4+L+FPNIkvVlwIffiwtZ+Dlt2KUt7LDXZxmfulmc9wSOKAMopfndLa qkpHw/SckqOXjX0FalGIECcfhE0ehDAlhqFp9vnZclkRz5xvX++6Sgm+tdSJA9Nm7/iS PjHYhSr3MiuaYS6LGr+EHN6QxZyMXcJTItyvLxkVG7Se7azJ6bwXxDgAHATsMi+Vma/S RIqw== 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=wJVvr0R8vRxwzDw5Od78sw3+IQHhFknkMJaBgCzyd7k=; b=eGLCDL96DpPM9okfRIzTZOML7HyeTfE8zQGxS6NXeQquhQY6tGtK2rnnLc2RAG+HG5 GstiFn0IUcObhyauGbJMWN3ru3nmjWYml4V2sUcknCs9Ghs75zatTWWzLSvzuOZHsrZR fNx56r7JsWflcJpNiIKq/0YRqbGYUmMyQlH0VgKHCGfMQDINViLuHiOjFn4yBydD/Doy zMdYCnnc8R25s6zP3pACxkdEiWDpYCGsLThEBlTrvyd7kNHS55BWO54d3phm6axX6tdG kcs8pBTDNj1sRV+riIWio9QdtufeO/Etydluj6Tj24yqOiJZiGHJUxrGRp1UQx0KbXOW 1TrA== X-Gm-Message-State: AGRZ1gKcHGegfrOASG6ANTAZjbpR6ABzCogG6NFoHAKMbxd8ElO8sccL N5AzNWlZ+VpIHYuZFQR+v3wefixi X-Google-Smtp-Source: AJdET5dkKNQrrX2YAqPPQYpJPYqt+Knz2rf7K+TD5MstpyPxp+FwLROLQ7BGCmS3b9WWA3ZBSyP76g== X-Received: by 2002:a17:902:7245:: with SMTP id c5-v6mr3622897pll.251.1540871447809; Mon, 29 Oct 2018 20:50:47 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id d187-v6sm31897666pfc.60.2018.10.29.20.50.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 20:50:46 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org, Peter Maydell , Jason Wang Date: Tue, 30 Oct 2018 11:50:30 +0800 Message-Id: <20181030035030.4542-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::641 Subject: [Qemu-devel] [PATCH] net/filter-rewirter.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);