All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexandre Cassen" <acassen@corp.free.fr>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH net-next v2 09/10] net/mlx5e: TC, match the tunnel key without a tunnel device
Date: Wed, 18 Nov 2026 09:29:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-220570@kernel.org> (raw)
In-Reply-To: <20261117092915.255194-10-acassen@corp.free.fr>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net/mlx5e: missing 24-bit VNI mask check in outer key
  VXLAN/GENEVE parsers
--

commit f2971dcf3d78103aa3910311cdd90b5bd51fcc77
Author: Alexandre Cassen <acassen@corp.free.fr>

net/mlx5e: TC, match the tunnel key without a tunnel device

This commit adds TC flower support for matching the outer tunnel key
(enc_key_id) on GRE, VXLAN, GENEVE, and GTP-U traffic when no tunnel
device is used.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
> index ee04fcdca6ffe..9a2f7a409a821 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c
[ ... ]
> @@ -350,6 +351,42 @@ static bool mlx5e_tc_tun_encap_info_equal_geneve(struct mlx5e_encap_key *a,
>  						     IP_TUNNEL_GENEVE_OPT_BIT);
>  }
>  
> +static int
> +mlx5e_tc_tun_parse_outer_key_geneve(struct mlx5e_priv *priv,
> +				    struct mlx5_flow_spec *spec,
> +				    struct netlink_ext_ack *extack,
> +				    u32 key, u32 mask,
> +				    enum fs_flow_table_type fs_type)
> +{
> +	void *misc_c, *misc_v;
> +
> +	if (key >= MLX5E_TC_TUN_N_VNI) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "Tunnel key does not fit the 24 bit VNI");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	if (!mlx5e_tc_tun_can_offload_geneve(priv) ||
> +	    !MLX5_CAP_FLOWTABLE_TYPE(priv->mdev,
> +				     ft_field_support.outer_geneve_vni,
> +				     fs_type)) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "Matching on GENEVE VNI is not supported");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	misc_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
> +			      misc_parameters);
> +	misc_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
> +			      misc_parameters);
> +
> +	MLX5_SET(fte_match_set_misc, misc_c, geneve_vni, mask);
> +	MLX5_SET(fte_match_set_misc, misc_v, geneve_vni, key);
> +	spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS;
> +
> +	return 0;
> +}
[ ... ]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
> index 33911e72d20d0..610e2bbc21f1f 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c
[ ... ]
> @@ -261,6 +262,41 @@ static int mlx5e_tc_tun_get_remote_ifindex(struct net_device *mirred_dev)
>  	return ifindex;
>  }
>  
> +static int
> +mlx5e_tc_tun_parse_outer_key_vxlan(struct mlx5e_priv *priv,
> +				   struct mlx5_flow_spec *spec,
> +				   struct netlink_ext_ack *extack,
> +				   u32 key, u32 mask,
> +				   enum fs_flow_table_type fs_type)
> +{
> +	void *misc_c, *misc_v;
> +
> +	if (key >= MLX5E_TC_TUN_N_VNI) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "Tunnel key does not fit the 24 bit VNI");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	if (!MLX5_CAP_FLOWTABLE_TYPE(priv->mdev,
> +				     ft_field_support.outer_vxlan_vni,
> +				     fs_type)) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "Matching on VXLAN VNI is not supported");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	misc_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
> +			      misc_parameters);
> +	misc_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
> +			      misc_parameters);
> +
> +	MLX5_SET(fte_match_set_misc, misc_c, vxlan_vni, mask);
> +	MLX5_SET(fte_match_set_misc, misc_v, vxlan_vni, key);
> +	spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS;
> +
> +	return 0;
> +}

[Severity: Medium]
Can a 32-bit enc_key_id mask with bits set only in [31:24] (such as
0/0xff000000) bypass the 24-bit VNI check in
mlx5e_tc_tun_parse_outer_key_geneve() and
mlx5e_tc_tun_parse_outer_key_vxlan()?

When key is 0 and mask & (MLX5E_TC_TUN_N_VNI - 1) is 0, key >=
MLX5E_TC_TUN_N_VNI is false, and MLX5_SET() truncates the 24-bit
geneve_vni or vxlan_vni mask to 0 while still setting
MLX5_MATCH_MISC_PARAMETERS.  Under SMFS, HMFS, or FDB DMFS when
misc_parameters has other non-zero criteria, this installs a hardware rule
that ignores the VNI and matches all UDP traffic on the tunnel port;
otherwise, enabling MLX5_MATCH_MISC_PARAMETERS with an all-zero
misc_parameters criteria causes firmware flow group creation to fail.

Rejecting !(mask & (MLX5E_TC_TUN_N_VNI - 1)) alongside key >=
MLX5E_TC_TUN_N_VNI, as cxgb4_validate_flow_match() does, would prevent
this.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117092915.255194-1-acassen@corp.free.fr?part=9

  reply	other threads:[~2026-11-18  9:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  9:29 [PATCH net-next v2 00/10] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
2026-11-17  9:29 ` [PATCH net-next v2 01/10] bnxt_en: require an exact tunnel id in TC flows Alexandre Cassen
2026-11-18  9:29   ` sashiko-bot
2026-11-17  9:29 ` [PATCH net-next v2 02/10] cxgb4: flower: refuse a tunnel key wider than the VNI Alexandre Cassen
2026-11-17 14:05   ` Potnuri Bharat Teja
2026-11-18  9:29   ` sashiko-bot
2026-11-17  9:29 ` [PATCH net-next v2 03/10] nfp: " Alexandre Cassen
2026-11-18  9:29   ` sashiko-bot
2026-11-17  9:29 ` [PATCH net-next v2 04/10] net/mlx5e: TC, " Alexandre Cassen
2026-11-18  9:29   ` sashiko-bot
2026-11-17  9:29 ` [PATCH net-next v2 05/10] net/mlx5e: TC, reject a partial tunnel key with tunnel mapping Alexandre Cassen
2026-11-18  9:29   ` sashiko-bot
2026-11-17  9:29 ` [PATCH net-next v2 06/10] net/sched: cls_flower: add enc_key_id mask Alexandre Cassen
2026-11-18  9:29   ` sashiko-bot
2026-11-17  9:29 ` [PATCH net-next v2 07/10] selftests: forwarding: tc_flower: test the " Alexandre Cassen
2026-11-18  9:29   ` sashiko-bot
2026-11-17  9:29 ` [PATCH net-next v2 08/10] net/mlx5e: TC, offload RX queue mapping in NIC flows Alexandre Cassen
2026-11-18  9:29   ` sashiko-bot
2026-11-17  9:29 ` [PATCH net-next v2 09/10] net/mlx5e: TC, match the tunnel key without a tunnel device Alexandre Cassen
2026-11-18  9:29   ` sashiko-bot [this message]
2026-11-17  9:29 ` [PATCH net-next v2 10/10] docs: networking: describe tunnel key partitioning in TC queue filtering Alexandre Cassen
2026-11-18  9:29   ` sashiko-bot

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-220570@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=acassen@corp.free.fr \
    --cc=linux-rdma@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.