Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp725662pxb; Tue, 2 Feb 2021 16:48:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9axe/PoVYleQKhc0zOxu4Z+OLUv5v8x0bmXpaYeJCtCCkH0FpAkXVD2lMsGybQzQvXqdn X-Received: by 2002:a17:906:2495:: with SMTP id e21mr638217ejb.280.1612313339323; Tue, 02 Feb 2021 16:48:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313339; cv=none; d=google.com; s=arc-20160816; b=wafdf3Ixk865vM2AzJlDe8uUGXVFxB/gG76YVmQziOtEdaubK8Ls0XhVcTqksrTrFW EzaUq22HuY8m5wa1AoNWClznkGxm0Mu4c1PMfwMdYPz2ivjqR17j78hEJ//Rl/rnSD5H NJ1gzEgxTp5kW5Joq4KUY/GY9vmksrkEosrt+KA5horRnDkJZjtmrDnIscBi5zEzN32W hwoFMLShCICYn19tz5cNPqD/mzWFSFEu4usN5Jl0pRATbdAp45lxNDD16mfLxY5ZKqJT /+QaKc/6PxK5iVTnHgIl0CZseJcNS8xEyB58DqQn0XpSwm0G8dW6mcC5m1/i86//bb/3 CfIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6qw3ku78U1NehR15/lj7f82+UzbLz9p0EJVHM8CZAKQ=; b=q+bBxQQY0pIRP0PhUTmFFYlp1D8LZUh6PjgGGCbbPY9XR7D4X1im2rjTyI3xrrf2ny ITOEwGJLTjP3vqERweTbUB2grlZLbZT5Rwa0GkafeFHKNeI0e1n9BbFgrBEJjxGjCPDG 1j4ExMZIFqbmLgKJGDIxPtBT/08MJWtUkRGr2sRRCDgyJRRzThEsmQdlyRfXMv815LBq YueSZzksYtf6wqt2fo27GYnYvd3U1mviEgA3L/g6zEj6smOjFSfeaH69HIF7I1gp1/fm U4rJamRzbtuKt08HMmdQC24oNhNjh1yxsxrpme2Cm0gVJ7Mz+pUNRzm+G9wjMepQKvL0 aHUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RPk3TU3o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si237783edq.320.2021.02.02.16.48.35; Tue, 02 Feb 2021 16:48:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RPk3TU3o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234113AbhBBTlU (ORCPT + 99 others); Tue, 2 Feb 2021 14:41:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:41654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233172AbhBBNzG (ORCPT ); Tue, 2 Feb 2021 08:55:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 175CE64FD8; Tue, 2 Feb 2021 13:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273482; bh=b5Od0b+hCiTlDBKviMD46lVjlMg/CPQbkBzOOWWXE8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RPk3TU3o78ijlK6mU2LcFxeUoE6pPNvrINMmYgVzxjBaMlNf1LTobh3LyryhO8sRg U00+gs2gDJxBYe8HrFOmL06UDH1/x5MjFn2vNJIDOgyf5G2Ui4+nIfMTdszuuWLL9S JtCyw0vTcjUgSZrTivf4er7mn7u5wjNM5oV1KvVc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roi Dayan , Paul Blakey , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.10 124/142] net/mlx5: CT: Fix incorrect removal of tuple_nat_node from nat rhashtable Date: Tue, 2 Feb 2021 14:38:07 +0100 Message-Id: <20210202133002.816976385@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paul Blakey [ Upstream commit e2194a1744e8594e82a861687808c1adca419b85 ] If a non nat tuple entry is inserted just to the regular tuples rhashtable (ct_tuples_ht) and not to natted tuples rhashtable (ct_nat_tuples_ht). Commit bc562be9674b ("net/mlx5e: CT: Save ct entries tuples in hashtables") mixed up the return labels and names sot that on cleanup or failure we still try to remove for the natted tuples rhashtable. Fix that by correctly checking if a natted tuples insertion before removing it. While here make it more readable. Fixes: bc562be9674b ("net/mlx5e: CT: Save ct entries tuples in hashtables") Reviewed-by: Roi Dayan Signed-off-by: Paul Blakey Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- .../ethernet/mellanox/mlx5/core/en/tc_ct.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c index 072363e73f1ce..6bc6b48a56dc7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c @@ -167,6 +167,12 @@ static const struct rhashtable_params tuples_nat_ht_params = { .min_size = 16 * 1024, }; +static bool +mlx5_tc_ct_entry_has_nat(struct mlx5_ct_entry *entry) +{ + return !!(entry->tuple_nat_node.next); +} + static int mlx5_tc_ct_rule_to_tuple(struct mlx5_ct_tuple *tuple, struct flow_rule *rule) { @@ -911,13 +917,13 @@ mlx5_tc_ct_block_flow_offload_add(struct mlx5_ct_ft *ft, err_insert: mlx5_tc_ct_entry_del_rules(ct_priv, entry); err_rules: - rhashtable_remove_fast(&ct_priv->ct_tuples_nat_ht, - &entry->tuple_nat_node, tuples_nat_ht_params); + if (mlx5_tc_ct_entry_has_nat(entry)) + rhashtable_remove_fast(&ct_priv->ct_tuples_nat_ht, + &entry->tuple_nat_node, tuples_nat_ht_params); err_tuple_nat: - if (entry->tuple_node.next) - rhashtable_remove_fast(&ct_priv->ct_tuples_ht, - &entry->tuple_node, - tuples_ht_params); + rhashtable_remove_fast(&ct_priv->ct_tuples_ht, + &entry->tuple_node, + tuples_ht_params); err_tuple: err_set: kfree(entry); @@ -932,7 +938,7 @@ mlx5_tc_ct_del_ft_entry(struct mlx5_tc_ct_priv *ct_priv, { mlx5_tc_ct_entry_del_rules(ct_priv, entry); mutex_lock(&ct_priv->shared_counter_lock); - if (entry->tuple_node.next) + if (mlx5_tc_ct_entry_has_nat(entry)) rhashtable_remove_fast(&ct_priv->ct_tuples_nat_ht, &entry->tuple_nat_node, tuples_nat_ht_params); -- 2.27.0