🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18668

Re: [PATCH net-next] net: mlx5: Allow police as the last action of a TC rule

#18668
From: netdev-bot+sashiko
Date: Wed, 18 Nov 2026 18:13
134 lines
13518 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] This patch makes a rate police allowed as the last action.
- [Low] The `FLOW_ACTION_ACCEPT` change in `alloc_branch_attr()`
  (en_tc.c:3894-3897) changes how already-deployed police rules forward…

--

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

In switchdev mode, this commit lets mlx5 offload a TC rule whose only or
last action is police. tc_act_parse_police() now sets
MLX5_FLOW_CONTEXT_ACTION_FWD_DEST for rate police as well as mtu police,
so verify_attr_actions() no longer rejects the rule. The police ok result
now goes to the end of the TC chains instead of being treated as pipe.

> 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;
> +

[Severity: High]
Every rate police now sets FWD_DEST, so verify_attr_actions() accepts a
police-last rule whatever its conform/exceed results are. What happens
when the result is pipe or jump? For example:

  action police rate 100mbit burst 1m conform-exceed drop/pipe

alloc_branch_attr() still sends PIPE and JUMP through set_branch_dest_ft().
That function only points the branch at the post_act table:

  attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
  attr->dest_ft = mlx5e_tc_post_act_get_ft(post_act);

It does not write FTEID_TO_REG. Only mlx5e_tc_post_act_set_handle() writes
that register, through mlx5e_tc_act_set_next_post_act().
alloc_flow_post_acts() calls that only when a following attr exists:

  if (next_attr && !(attr->flags & MLX5_ATTR_FLAG_TERMINATING)) {
          err = mlx5e_tc_act_set_next_post_act(flow, attr, next_attr);

The jumping_attr case set up in dec_jump_count() also needs a later attr.
When police is the last action, neither path runs.

The post_act rules match only on the register:

  mlx5e_tc_match_to_reg_match(spec, FTEID_TO_REG, handle->id, MLX5_POST_ACTION_MASK);

On chain 0 the register is 0 and ids start at 1. The lookup misses and the
packet falls through, which happens to behave like accept.

If the packet reached this rule through an earlier post_act hop, though,
nothing clears the register. Take a CT pipeline: chain 0 has "ct zone Z
pipe action goto chain 1", and a chain 1 rule has "ct_state +trk+est
action police ... conform-exceed drop/pipe".

In that setup, couldn't green packets go back to the post_act table, match
the chain 0 rule's entry again, repeat its actions (goto chain 1), hit the
same meter, and loop? Any mirror, redirect or counter in that earlier entry
would also run again.

mtu police already set FWD_DEST before this patch, so it had the same gap.
This patch now exposes it for rate police too.

Should pipe at the end of the action list, and jump past the end, also go
to the end of the TC chains as ACCEPT now does? Or should they be rejected?

>  	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;

[Severity: Low]
This isn't a bug, but the change also affects existing offloaded rules
where other actions follow police, not only police-last rules.

Before, ACCEPT fell through to PIPE (from commit f86488cb4685 "net/mlx5e:
TC, initialize branch flow attributes"). An ok branch went to the post_act
table and ran the following actions.

Now MLX5_ATTR_FLAG_ACCEPT makes esw_setup_dests() call
esw_setup_accept_dest(), which sends the branch to the chains end table.

tcfp_result defaults to TC_ACT_OK when TCA_POLICE_RESULT is absent, so the
common form is affected too:

  police ... conform-exceed drop action mirred egress redirect dev X

Conforming traffic that was redirected in hardware now goes to the end of
the chains.

This matches software TC semantics. Could it be split into its own fix
with a Fixes: f86488cb4685 tag? Could the commit message also say that
existing offloaded rules will forward traffic differently?

>  	case FLOW_ACTION_PIPE:
>  		err = set_branch_dest_ft(flow->priv, attr);
>  		if (err)

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117031337.4126403-1-mohsin.bashr%40gmail.com
Technical Details
Message-ID: <179502562008.3136.323213503024507641@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366322-linux-kernel-netdev=dewy.ru
References: <20261117031337.4126403-1-mohsin.bashr@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366322-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next] net: mlx5: Allow police as the last action of a TC rule
Date: Wed, 18 Nov 2026 18:13:40 +0000
Organization: Usenet Network
Message-ID: <179502562008.3136.323213503024507641@kernel.org>
References: <20261117031337.4126403-1-mohsin.bashr@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2660824"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:LjND1/Q9bM+lBzNnDZ3MQ0+C/jA= sha256:OmdPg0UERUbH1sAA2V7c0eeWuitnlDRdI90TnbF29eo=
	sha1:/YzhngSGwpMvFk+7NDlvY0CaYtk= sha256:psFXVJdcl9JoGQLvxs4bKZuu/Pp5xVSGt2gP5L373L8=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 991B91152BE; Wed, 18 Nov 2026 21:14:02 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id BswGHCm2u8ys;
	Wed, 18 Nov 2026 21:13:54 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-366322-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id D51BE114CB4; Wed, 18 Nov 2026 21:13:45 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id A30756337D; Wed, 18 Nov 2026 18:13:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795025622;
	b=COgNv8IRrenj9VZkw2R4Lir7KtoHB1YTSHCKlDbYaVF+SmBKlbvAEqjmT2CRS90h3wlP
	 sNFB69pK/60dCHtFcYbED4QdtrFykAj3TA+WgvNa3DL2sHmiilIn11pU4VLnF5csBisq4
	 MozlxlRF6TkHH4RPQ4xXt3Ts829Oknly2ZDad2He/LA22x7S7BcPMyoDeyEyZRI0pA3sO
	 hHbRfnkU4h+/j3yb5kXaCLJqRJlBSuXNIliS3XMypChFVKVhzn1X9tHVj9ukZWxps2pz/
	 w5m1jlRJ9hmTZunA7ziVYicxxucjD5N2TZaMOmFW7EntpEqP66LczrAnLtvrnW4TuCQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795025622;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=RNHYn9Uwf55o6irSeRoRJDXCOCtcjhiRfm7mwVUfGnQ=;
	b=plX2PoMd8+LMi/+TW+630nuEOobvRXIkU1NVWaFKYYy4Mwc8OmUB1pNP46VBjZRWyE1U
	 cqiY5QRon7hJx/Bs+JsvFKIKGvd4RoDrEHrcTPSRyfZC4A+FdJFg5YOy1jZrgfH7biU57
	 ys6MeTNR93n168U6BtwjTLA8zU6WWAQERLQQVn2vzXeshj633glI3jaFVHeMIsChTdLqJ
	 3pItLSO/1cBAhJBXFjxiwwlC50WxKdWz5Aw/hjfmxB0ynGqLDq7cC9yn5L28HAZtO19ob
	 4ZYT0/dhJ8cvpAFL5BPWsX4RabiQc/VBPRrtM3Y67FpQnTnyRVyNt/HtiTvraNxUKzg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bWehsiFL;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 942C4606A339;
	Wed, 18 Nov 2026 18:13:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bWehsiFL
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795025621;
	b=WyjCOcVFLnYiD2yA10nwwJ4bBVT44RVlr1qkvsL+0NsdCb9+fuYb7tdkh+8se0xiVW9B
	 zupIvFMoEyzTXu5dMiEu1BorlYvbfvW8wDa+8U8DxdftPzoUx82PYvR5AA8VYIw7+4Wrs
	 mSCpRSnO81j/GL9b4tIpw4/O4ioSQniemRcNOW+ps0erSZrWNbaYZgDbsSt9gZwgHx1LZ
	 21qycYYbNAIkVuV99lULGfS29XgN0o+xr421PT7OShAHDADgoXcyJcIvDoiXitt7G0HjB
	 TofZX0kYrxt8h99wTB22EY7W9RwsAERzk4GAhE50QIp3PAkUYIsX7kyE7Y9ZORAEQEg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795025621;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=RNHYn9Uwf55o6irSeRoRJDXCOCtcjhiRfm7mwVUfGnQ=;
	b=g0Cl86D8jJP+tGfAzKyUrqcq6e4q9MTdlp/n8mch1vu74PlOoUYghcbxcCxw4yuyRe4Y
	 dWuuD7wDP3+ggpQqpk016lBJIJXiYWtnNcT6aNrX9raMTfKSUKSQaBsR9ipgev1kYME72
	 xlHdLlFTq1+CpnHPCMEkZri1BMH2a5ns1kXh4KSqkEaGeV8D3Lsz5ZaJQQ3eYBXxioWaA
	 AG/rkT9Po8zwtld1/kX/rncXQHPjJhNDBwRW06nq7zpdVI0IRY5wDxQ2p1+MgbPb5qABr
	 0uwYnDYt8Zi/K+cutt03k7nlLxeDFCDI4EqKVXFkbDHmLPCivgyMEL2Vfx0maf7N00A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bWehsiFL;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1FB9606A325;
	Wed, 18 Nov 2026 18:13:41 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F6D11F000C4;
	Wed, 18 Nov 2026 18:13:40 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795025621;
	bh=RNHYn9Uwf55o6irSeRoRJDXCOCtcjhiRfm7mwVUfGnQ=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=bWehsiFLMVL0rkfPobD94C5KM6JS/oObv9+Vx/5V6XdQrotyi6Iag/90eFPhO1c1m
	 hqJfAXOP+rSusgETD+FEEw0+6JZQUnShPwdL8vRwdbCy/LzxB/pMm7BiYrQdrgHULm
	 kGn5sjZT7nDzfA00fV/qKumkjHqqOIpumyoP/+p54s6W/oFoPnD024TiOzBnoCpzkl
	 wVEvoHyKKWOT0G3o9qJl9709ScwEB12rIhzid65Maxjtk5/OqWSlPXJGFIvD3WvzhM
	 SqZzblacmfn4JMP5Viqen8/pwZeuL2/7q29MwKd6X4c/s4SGlrcbVxWom0ODQtYIfi
	 KUqCNopVDur+g==
X-Cc: netdev@vger.kernel.org, saeedm@nvidia.com, leon@kernel.org,
 tariqt@nvidia.com, mbloch@nvidia.com, cjubran@nvidia.com,
 andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, linux-rdma@vger.kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261117031337.4126403-1-mohsin.bashr@gmail.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list