From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796258890; b=AGKWp8u9t91b0Dr1E1MxyDUVkUJxk86R0fXABqpswGT/WU0Fm7TUjD7tT3CIzm0jimgt ovqDaFOQ5M7aLz+00i6qoqWuzBOg+YcP/owU5BnB8KTmSoW1s7DmarPv1AJ100UKQCWXe KLC3Cuhut4eH4Qji2bqLLG6O+d5GjU6g9npYdDE2y2KYUYMKG+O2e9neqpTY3PHQRsZ02 R61Cjs/pP39e6hwIFm8hvo6ZnoF96+/w43z2gofNwkQW9CH1FIA8eQWdADyEUoPMjPh7M O8UZUbr1GBeI3LGpCAqD7n/C0kzcEXIRoJZWiw1gDIQjqMGNP7vhc9kfK9R2Uhyux5A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796258890; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=nMGLdgvY7ft+qBCPJu7Tv814XGFkdIsbYO7bx5o5g0k=; b=U5E0+zZ4+IUrWwIN2yxoW52zehyGVgfBa7Btu4MIYpjK1h1SG6SaadPZ7GwxItArg0FG IvOBG4dp+hXfYXNpwitErkX+exNh4KiDxFy3eG0j1BPpGrNRPkE3Wr5rDA3FiY6KMaf7f SJOGJ45wCnNPT96q4kISchkf2t60ZFE6Pvo21HT/QQgHQUGF/3cqY+p4ZZUlfYeN+1Afa G3TDdm5xaQF+2yaCvcv8eDcsgSt/K888H7cYP+PGYNzWYSNLvZBhEBouXUjZWx9dTFK69 DAJ6/anVh1FR3uDdVbGOsLhfLE5zxbbtj1rnhdj/TUQMMOMoaGqXJevY4uJJkW5/o4Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=CkaXusAe; arc=none smtp.remote-ip=74.125.82.173 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A283606A322 for ; Thu, 3 Dec 2026 00:48:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6A283606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=CkaXusAe Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-385c497bf94so3575121eec.1 for ; Wed, 02 Dec 2026 16:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796258889; x=1796863689; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=nMGLdgvY7ft+qBCPJu7Tv814XGFkdIsbYO7bx5o5g0k=; b=CkaXusAeABlIopuWc8EjiZ8NT/FlrNTurLKj84H2qGJDh/6q4S2tttfRJk82HAJcco nR9KqrmN4RFPdR6KgPhRB7fzwx/7oG0RbjYvXi0Z9O3fZTafRPRxb3VcpAQekUa/kE+n THoNUz37ToucuXfnYI4dEoU8FXVlRa9MrW2sXG7tf7vbNYYtlNo7cG48y/p3p6bdV5/H WEStGYfTzXMd/kOvMNcgy3zpeGpVcbNBlLMI3oKvoszlNHaCMeD7zP3stYNBCzfU1Y7D U9qvga72TOKy2JPAOHlw6HPUhuI8UiG6kkf/ARG5RLPrmDyDwb+wGVC2yE19/xMDXRDP +OMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796258889; x=1796863689; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=nMGLdgvY7ft+qBCPJu7Tv814XGFkdIsbYO7bx5o5g0k=; b=GRogNLjGgdaLapGMgiM+ZpvV4kShBDIFH/K3ePYOOlUlLYuG68Yog7FlVHed9bmjV9 HhKFAoFt317tO/dFXoi91/4nDNIgm0JXfqsaCxK2h6zzgYYZu8Tds7oFcE0LCUrCSAz8 Or4+O5+Rwck+ffwg7oqy3tIAMbeSoNwxhjdfGHPdnSZhbMAu7Fl1C+bjePOnWQFWLqBt dBqnC83xGGBbICCvxyjRIYB1tpAd/0NQsJKhLYn5iTTSJ03v2vvD4n7DVZ0leZSGiZAC +YrzGVHif00DIhl55ka+Jn8j6I2h2NRT707lLLmIbqm8pjEl6KUSv3CUEmpRQPkswdOT I8qg== X-Gm-Message-State: APuU4Z9m5K03iWq7yZJYIWFcbhix6/Hp1hs9KremDWAymROAL5hwWEbn K02eF3MUIk96UQ3rJC/7gr71DlZ/YteY5/mq2UPuu+ul8AYvn7fL+nsd X-Gm-Gg: AZFdTZei/jnUUQ8jc6kxINBrt1xiUjj6tEax6QlGuZjQCfUX/Df9tU3BVH5lPI66M81 vQcr/NnGkTK/s1pdOtZALWExsRUxDDoayxSdJ6o/qQQ0rmZv4qs3mp5R30aaGpvrGVJ6frb2slP xC65em6qNcBqFcxRt3QBfoGzWNx6vu+d/uWY+8uvKZD/TJ225YCDmWCRLmV9QJk64i0FfK/Ul4R qN1ksDSP8t0xyddWbpAmiQW2v2Rm0smIMMFDUhTW0STmAb8T5PKFDbN5PY/uwcJwWC1kXi5WDEQ nx1YQIvs5nX5SRzz8wgKPATkFgseW+1cGHwFtRq3HxQ51opb+xuietP8ALXO85IbOlfeqkd5/qZ SnEIDCcclo3/lC8vv0RihpDpN7rqGzzy1Enx9riEEk/MgzN/RTdDTpEiXIqqtdD9/ReNdhcYs1B 4PdMRsOSsAVRU+UkcbQnaezT6V4Ezs2Rorys8mxU1EKfwCYgCWFoAurI5FwiVCdmMYD3jUVsPE5 vU0XvtKV2tziRrKlqN0LYBByR3G+hn7jDeIS2Ln8JZxd053wlISfcC6ob97MntQ7mYxh+izy61z mTYTyRJRQeE6WMROyPj9HKTSkKmTlDmOibRWSAgAmTKPc+5bGBICOZnBl7EN+B8YbgqoTCgRobS em39K2uQ= X-Received: by 2002:a05:7301:4718:b0:380:9c6f:ad0a with SMTP id 5a478bee46e88-3856e63b224mr41285217eec.10.1796258889442; Wed, 02 Dec 2026 16:48:09 -0800 (PST) Received: from ?IPV6:2a03:83e0:1151:15:18db:c1e7:4974:be38? ([2620:10d:c090:500::5:c9f5]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385672c6f31sm120258052eec.15.2026.12.02.16.48.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2026 16:48:09 -0800 (PST) Message-ID: <0c045138-6598-4781-9cae-74ce855c3936@gmail.com> Date: Wed, 2 Dec 2026 16:48:08 -0800 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v4] net: mlx5: Allow police as the last action of a TC rule To: sashiko-reviews@lists.linux.dev Cc: linux-rdma@vger.kernel.org References: <20261201212455.2836814-1-mohsin.bashr@gmail.com> Content-Language: en-US From: Mohsin Bashir In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/2/26 1:25 PM, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential > issue to consider: > - [Medium] net/mlx5e: miscompiled skipped actions in > police_act_can_offload_jump() > -- > > commit ca98fcfa7fb19e6a3e27e9587d032f9f75c3bf2b > Author: Mohsin Bashir > > net: mlx5: Allow police as the last action of a TC rule > > This commit updates mlx5 TC police action offloading to allow police as the > last action in a flow, handle ok and terminal pipe branch controls as > accept, and validate police jump targets. > >> 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..1e6babff8b2b7 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 >> @@ -37,6 +37,52 @@ static int police_act_validate(const struct flow_action_entry *act, >> return 0; >> } >> >> +static bool >> +police_act_can_offload_jump(struct mlx5e_tc_act_parse_state *parse_state, >> + const struct flow_action_entry *act, >> + int act_index, u32 target) >> +{ >> + const struct flow_action *flow_action = parse_state->flow_action; >> + struct netlink_ext_ack *extack = parse_state->extack; >> + const struct flow_action_entry *prev, *entry; >> + u32 i; >> + >> + if (act_index) { >> + NL_SET_ERR_MSG_MOD(extack, >> + "Jump is only supported when police is the first action"); >> + return false; >> + } >> + >> + if (!target || target >= flow_action->num_entries) { >> + NL_SET_ERR_MSG_MOD(extack, "Jump target must be a later action"); >> + return false; >> + } >> + >> + prev = act; >> + for (i = 1; i <= target; i++) { >> + entry = &flow_action->entries[i]; >> + >> + if (i < target && >> + (entry->id == FLOW_ACTION_MANGLE || >> + entry->id == FLOW_ACTION_ADD || >> + entry->id == FLOW_ACTION_POLICE)) { >> + NL_SET_ERR_MSG_MOD(extack, >> + "Jump over a pedit or police action is not supported"); >> + return false; >> + } > > [Severity: Medium] > Can police_act_can_offload_jump() allow skipped action sequences that > dec_jump_count() and parse_tc_actions() miscompile into hardware rules? > > dec_jump_count() only sets jump_state->jump_target and checks > tc_act->is_terminating_action when --jump_state->jump_count == 1: > > drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:dec_jump_count() { > ... > /* nothing to do for intermediate actions */ > if (--jump_state->jump_count > 1) > return; > > if (jump_state->jump_count == 1) { /* last action in the jump action list */ > > /* create a new attribute after this action */ > jump_state->jump_target = true; > > if (tc_act->is_terminating_action) { /* the branch ends here */ > attr->flags |= MLX5_ATTR_FLAG_TERMINATING; > attr->action |= MLX5_FLOW_CONTEXT_ACTION_COUNT; > } else { /* the branch continues executing the rest of the actions */ > struct mlx5e_post_act *post_act; > > attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; > post_act = get_post_action(priv); > attr->dest_ft = mlx5e_tc_post_act_get_ft(post_act); > } > ... > } > > When target >= 3, parse_tc_actions() merges all non-multi-table skipped > actions in 1 <= i < target into a single mlx5_flow_attr. If an earlier > skipped action is terminating (for example, conform-exceed pipe / jump 3 > followed by redirect eth1 and ok), TC software stops at entries[1], whereas > merging entries[2] into the same attr sets MLX5_ATTR_FLAG_ACCEPT or > combines incompatible actions (such as drop and ok) that fail in > verify_attr_actions(). > > Even when target == 2, several allowed skipped actions do not work with > the jump split in parse_tc_actions(): > - FLOW_ACTION_TRAP has is_terminating_action == false on mlx5e_tc_act_trap, > so dec_jump_count() overwrites attr->dest_ft (slow_fdb) with post_act->ft > and chains the trap rule into the jump target instead of trapping to the > CPU. > - Actions that only record state in parse_state (such as > FLOW_ACTION_TUNNEL_ENCAP, FLOW_ACTION_TUNNEL_DECAP, FLOW_ACTION_MPLS_PUSH, > FLOW_ACTION_PTYPE, FLOW_ACTION_VLAN_PUSH_ETH and FLOW_ACTION_VLAN_POP_ETH) > leave their parse_state flags set across the jump_target split because > parse_tc_actions() only resets parse_state->if_count = 0, applying the > skipped action to the jump target attribute. > - Any skipped action with is_terminating_action == false does not get > MLX5_FLOW_CONTEXT_ACTION_COUNT in dec_jump_count(), so > mlx5e_tc_act_stats_add_flow() attaches the jump target's counter to the > skipped action's cookie and counts packets that jumped over it. > These rules are offloaded the same way today. This patch only rejects more of them. The skipped actions also only run when the other police result is pipe. v3 limited the skipped actions to all drop or all ok, and I dropped that in v4 based on feedback on v3: https://lore.kernel.org/all/20261124220251.776944-1-mohsin.bashr@gmail.com/