[PATCH net mlxsw 2/2] mlxsw: core_acl_flex_actions: Remove redundant resource destruction

Nir Dotan nird at mellanox.com
Sun Jul 29 21:46:59 AEST 2018


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 mirror actions the destruction was done twice leading to a crash.
The first upon error on action setup phase and the second time as the
rule was destroyed.

The following sequence generated this 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

This patch handles two additional actions which acquire a separate
resource and their destruction was also found to be redundant.
The fix itself adds symmetry to the resource handling and adds a
removal of a resource from a rule upon destruction of that resource.

Fixes: d0d13c1858a1 ("mlxsw: spectrum_acl: Add support for mirror action")
Fixes: c18c1e186ba8 ("mlxsw: core: Make counter index allocated inside the action append")
Fixes: 140ce421217e ("mlxsw: core: Convert fwd_entry_ref list to be generic per-block resource list")
Signed-off-by: Nir Dotan <nird at mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c | 9 ++++++++-
 1 file changed, 8 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..f6f6a56 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);
 }
@@ -579,6 +584,7 @@ static void
 mlxsw_afa_counter_destroy(struct mlxsw_afa_block *block,
 			  struct mlxsw_afa_counter *counter)
 {
+	mlxsw_afa_resource_del(&counter->resource);
 	block->afa->ops->counter_index_put(block->afa->ops_priv,
 					   counter->counter_index);
 	kfree(counter);
@@ -856,6 +862,7 @@ static void
 mlxsw_afa_mirror_destroy(struct mlxsw_afa_block *block,
 			 struct mlxsw_afa_mirror *mirror)
 {
+	mlxsw_afa_resource_del(&mirror->resource);
 	block->afa->ops->mirror_del(block->afa->ops_priv,
 				    mirror->local_in_port,
 				    mirror->span_id,
-- 
2.8.4



More information about the Linux-mlxsw mailing list