Netdev List
 help / color / mirror / Atom feed
From: Alexandre Cassen <acassen@corp.free.fr>
To: Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Pirko <jiri@resnulli.us>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Michael Chan <michael.chan@broadcom.com>,
	Pavan Chebbi <pavan.chebbi@broadcom.com>,
	Potnuri Bharat Teja <bharat@chelsio.com>,
	Donald Hunter <donald.hunter@gmail.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	David Ahern <dsahern@kernel.org>,
	Ido Schimmel <idosch@nvidia.com>, Shuah Khan <shuah@kernel.org>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
	oss-drivers@corigine.com
Subject: [PATCH net-next v3 03/11] nfp: flower: refuse a tunnel key wider than the VNI
Date: Sun, 22 Nov 2026 22:31:51 +0100	[thread overview]
Message-ID: <20261122213200.3207385-4-acassen@corp.free.fr> (raw)
In-Reply-To: <20261122213200.3207385-1-acassen@corp.free.fr>

VXLAN and GENEVE rules shift the key and the mask of enc_key_id into a 24
bit VNI. An exact key above bit 23 already selects the wrong VNI. Flower
is about to accept partial masks. A mask that only covers bits above 23
would then match any VNI. Refuse a key that no VNI can match. GRE keeps
its 32 bit key.

Found by an AI code review agent while auditing the users of enc_key_id.
Confirmed by code inspection. The wrong match was not triggered. Build
tested only.

Fixes: 611aec101ab7 ("nfp: compile flower vxlan tunnel metadata match fields")
Fixes: bedeca15afd8 ("nfp: flower: compile Geneve match fields")
Signed-off-by: Alexandre Cassen <acassen@corp.free.fr>
---
 .../ethernet/netronome/nfp/flower/offload.c   | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c
index 161190200dbd..a560cdef8d23 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/offload.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c
@@ -150,6 +150,24 @@ static bool nfp_flower_check_higher_than_l3(struct flow_rule *rule)
 	       flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ICMP);
 }
 
+static int
+nfp_flower_check_tun_vni(struct flow_rule *rule,
+			 struct netlink_ext_ack *extack)
+{
+	struct flow_match_enc_keyid enc_keyid;
+
+	if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID))
+		return 0;
+
+	flow_rule_match_enc_keyid(rule, &enc_keyid);
+	if (be32_to_cpu(enc_keyid.key->keyid) < VXLAN_N_VID)
+		return 0;
+
+	NL_SET_ERR_MSG_MOD(extack,
+			   "unsupported offload: tunnel key does not fit the 24 bit VNI");
+	return -EOPNOTSUPP;
+}
+
 static int
 nfp_flower_calc_opt_layer(struct flow_dissector_key_enc_opts *enc_opts,
 			  u32 *key_layer_two, int *key_size, bool ipv6,
@@ -411,6 +429,10 @@ nfp_flower_calculate_key_layers(struct nfp_app *app,
 				NL_SET_ERR_MSG_MOD(extack, "unsupported offload: ingress netdev does not match the expected tunnel type");
 				return -EOPNOTSUPP;
 			}
+
+			err = nfp_flower_check_tun_vni(rule, extack);
+			if (err)
+				return err;
 		}
 	}
 
-- 
2.43.0


  parent reply	other threads:[~2026-11-22 21:32 UTC|newest]

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

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=20261122213200.3207385-4-acassen@corp.free.fr \
    --to=acassen@corp.free.fr \
    --cc=andrew+netdev@lunn.ch \
    --cc=bharat@chelsio.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@corigine.com \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=rdunlap@infradead.org \
    --cc=saeedm@nvidia.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tariqt@nvidia.com \
    /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