Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mohsin Bashir" <mohsin.bashr@gmail.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net-next] net: mlx5: Allow police as the last action of a TC rule
Date: Wed, 18 Nov 2026 03:13:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-220007@kernel.org> (raw)
In-Reply-To: <20261117031337.4126403-1-mohsin.bashr@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] net/mlx5e: broken post_act steering when last police action
  uses pipe or jump
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Medium] net/mlx5e: memory leak of parse_attr on error path in
  alloc_branch_attr() [1]
--

commit bbe05fcd328438a7e5968a8a2b44d3bf4fffd2eb
Author: Mohsin Bashir <hmohsin@meta.com>

net: mlx5: Allow police as the last action of a TC rule

This commit sets MLX5_FLOW_CONTEXT_ACTION_FWD_DEST while parsing rate
police actions and updates alloc_branch_attr() to set MLX5_ATTR_FLAG_ACCEPT
for FLOW_ACTION_ACCEPT so police can be offloaded as the last action in a
TC rule.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
> index 1bd1c94fb9776..52295f5d644c5 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/police.c
> @@ -94,13 +94,14 @@ tc_act_parse_police(struct mlx5e_tc_act_parse_state *parse_state,
>  		      MLX5_FLOW_STEERING_CAP_MATCH_RANGES))
>  			return -EOPNOTSUPP;
>  
> -		attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
>  		attr->flags |= MLX5_ATTR_FLAG_MTU;
>  	} else {
>  		attr->action |= MLX5_FLOW_CONTEXT_ACTION_EXECUTE_ASO;
>  		attr->exe_aso_type = MLX5_EXE_ASO_FLOW_METER;
>  	}
>  
> +	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 1d35c97aea0bc..8685e41487f39 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -3892,6 +3892,9 @@ alloc_branch_attr(struct mlx5e_tc_flow *flow,
>  		attr->action |= MLX5_FLOW_CONTEXT_ACTION_DROP;
>  		break;
>  	case FLOW_ACTION_ACCEPT:
> +		attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
> +		attr->flags |= MLX5_ATTR_FLAG_ACCEPT;
> +		break;
>  	case FLOW_ACTION_PIPE:
>  		err = set_branch_dest_ft(flow->priv, attr);
>  		if (err)

[Severity: High]
What happens when a rule ends with a police action whose branch control is
FLOW_ACTION_PIPE (the iproute2 default for notexceed when configuring
"action police rate ... drop") or FLOW_ACTION_JUMP?

Setting MLX5_FLOW_CONTEXT_ACTION_FWD_DEST in tc_act_parse_police() lets a
trailing rate police action pass verify_attr_actions(), while
alloc_branch_attr() still sets branch_attr->dest_ft to post_act->ft for
FLOW_ACTION_PIPE and FLOW_ACTION_JUMP.  However, parse_tc_actions() only
splits the flow to allocate a subsequent post_act attribute when
i < flow_action->num_entries - 1, so next_attr is NULL in
alloc_flow_post_acts() and mlx5e_tc_act_set_next_post_act() never writes a
new FTEID_TO_REG or installs a target post_act rule.

Packets taking the pipe branch will miss in post_act->ft to the slow path
instead of reaching the end of the TC chains, or if an earlier multi-table
action preceded the final police action, FTEID_TO_REG still holds the final
police attribute's own post_act_handle->id and steers packets back into the
same police rule in a loop.

[Severity: Medium]
This problem wasn't introduced by this patch, but does the out_err path in
alloc_branch_attr() leak (*cond_attr)->parse_attr [1]?

mlx5e_clone_flow_attr_for_post_act() allocates both *cond_attr and a
separate (*cond_attr)->parse_attr via kvzalloc_obj(), but out_err only
calls kfree(*cond_attr) instead of a helper like free_branch_attr() when
set_branch_dest_ft() or branch validation fails.

[1] https://sashiko.dev/#/bug/linux-ad0e9c08-1f2f-44c7-a3a1-f3f69e4acf76

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117031337.4126403-1-mohsin.bashr@gmail.com?part=1

      parent reply	other threads:[~2026-11-18  3:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  3:13 [PATCH net-next] net: mlx5: Allow police as the last action of a TC rule Mohsin Bashir
2026-11-17 19:18 ` Mark Bloch
2026-11-17 21:52   ` Mohsin Bashir
2026-11-17 22:14     ` Mark Bloch
2026-11-18  0:52       ` Mohsin Bashir
2026-11-18  3:13 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-220007@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mohsin.bashr@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox