From patchwork Wed Aug 1 08:24:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nir Dotan X-Patchwork-Id: 10551851 X-Patchwork-Delegate: jiri@resnulli.us 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 1CD99174A for ; Wed, 1 Aug 2018 08:25:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E6C02AF3F for ; Wed, 1 Aug 2018 08:25:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02F772AF61; Wed, 1 Aug 2018 08:25:35 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 38A812AF3F for ; Wed, 1 Aug 2018 08:25:35 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41gRFn4mL0zF1Pt for ; Wed, 1 Aug 2018 18:25:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=193.47.165.129; helo=mellanox.co.il; envelope-from=nird@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by lists.ozlabs.org (Postfix) with ESMTP id 41gRFj5gq5zF1Hp for ; Wed, 1 Aug 2018 18:25:29 +1000 (AEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from nird@mellanox.com) with ESMTPS (AES256-SHA encrypted); 1 Aug 2018 11:28:46 +0300 Received: from r-vnc13.mtr.labs.mlnx (r-vnc13.mtr.labs.mlnx [10.208.0.13]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w718PMML023762; Wed, 1 Aug 2018 11:25:22 +0300 Received: from r-vnc13.mtr.labs.mlnx (r-vnc13.mtr.labs.mlnx [127.0.0.1]) by r-vnc13.mtr.labs.mlnx (8.14.4/8.14.4) with ESMTP id w718PMHH021092; Wed, 1 Aug 2018 11:25:22 +0300 Received: (from nird@localhost) by r-vnc13.mtr.labs.mlnx (8.14.4/8.14.4/Submit) id w718PM34021091; Wed, 1 Aug 2018 11:25:22 +0300 From: Nir Dotan To: linux-internal@mellanox.com Subject: [PATCH net mlxsw v3 2/4] mlxsw: core_acl_flex_actions: Remove redundant resource destruction Date: Wed, 1 Aug 2018 11:24:53 +0300 Message-Id: <20180801082455.19751-3-nird@mellanox.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20180801082455.19751-1-nird@mellanox.com> References: <20180801082455.19751-1-nird@mellanox.com> X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP Some ACL actions require the allocation of a separate resource prior to applying the action itself. When facing an error condition during the setup phase of the action, resource should be destroyed. For such actions the destruction was done twice which is dangerous and lead to a potential crash. The destruction took place first upon error on action setup phase and then as the rule was destroyed. The following sequence generated a crash: # tc qdisc add dev swp49 ingress # tc filter add dev swp49 parent ffff: \ protocol ip chain 100 pref 10 \ flower skip_sw dst_ip 192.168.101.1 action drop # tc filter add dev swp49 parent ffff: \ protocol ip pref 10 \ flower skip_sw dst_ip 192.168.101.1 action goto chain 100 \ action mirred egress mirror dev swp4 Therefore add mlxsw_afa_resource_del() as a complement of mlxsw_afa_resource_add() to add symmetry to resource_list membership handling. Call this from mlxsw_afa_fwd_entry_ref_destroy() to make the _fwd_entry_ref_create() and _fwd_entry_ref_destroy() pair of calls a NOP. Fixes: 140ce421217e ("mlxsw: core: Convert fwd_entry_ref list to be generic per-block resource list") Signed-off-by: Nir Dotan --- Notes: v2: * Split to 3 patches (this is 1/3) as fixing different commits * Repharse commit text v3: * Rephrase commit text drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c index ce28068..d664cc0 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c @@ -327,12 +327,16 @@ static void mlxsw_afa_resource_add(struct mlxsw_afa_block *block, list_add(&resource->list, &block->resource_list); } +static void mlxsw_afa_resource_del(struct mlxsw_afa_resource *resource) +{ + list_del(&resource->list); +} + static void mlxsw_afa_resources_destroy(struct mlxsw_afa_block *block) { struct mlxsw_afa_resource *resource, *tmp; list_for_each_entry_safe(resource, tmp, &block->resource_list, list) { - list_del(&resource->list); resource->destructor(block, resource); } } @@ -530,6 +534,7 @@ static void mlxsw_afa_fwd_entry_ref_destroy(struct mlxsw_afa_block *block, struct mlxsw_afa_fwd_entry_ref *fwd_entry_ref) { + mlxsw_afa_resource_del(&fwd_entry_ref->resource); mlxsw_afa_fwd_entry_put(block->afa, fwd_entry_ref->fwd_entry); kfree(fwd_entry_ref); }