Skip to contentSkip to conversation

octeontx2-af: npc: Warn on NPC_IPSEC_SPI key overlap

PATCH Applied Ratheesh Kannoth 2 participants 3 messages Jul 21 – Jul 28

Subsystems (3)
lore
Share & tools
lore

Ratheesh Kannoth

author maintainer
#0 lore raw

PATCH v2 1/1 octeontx2-af: npc: Warn on NPC_IPSEC_SPI key overlap

From: Hariprasad Kelam <[email protected]>

When scanning the MKEX profile to determine supported NPC features, warn if the SPI extraction field overlaps with other key fields. AH and ESP may legitimately use the same key offset for SPI, so continue to advertise NPC_IPSEC_SPI via npc_is_field_present() instead of treating the overlap as a hard failure.

---
v1 -> v2: Addressed Simon comments

	https://lore.kernel.org/netdev/[email protected]/
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +6 -1
index 91b5947dae06..d422bdd5e8f8 100644
@@ -729,7 +729,12 @@ static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf)
 		if (!npc_check_field(rvu, blkaddr, NPC_LB, intf))
 			*features &= ~BIT_ULL(NPC_OUTER_VID);
 
-	/* Allow extracting SPI field from AH and ESP headers at same offset */
+	/* Warn on unrelated MKEX fields colliding with SPI key bits.  AH/ESP
+	 * sharing the same SPI key offset is valid; use npc_is_field_present(),
+	 * not npc_check_field(), to advertise the feature.
+	 */
+	if (npc_check_overlap(rvu, blkaddr, NPC_IPSEC_SPI, 0, intf))
+		dev_warn(rvu->dev, "Overlap detected the field NPC_IPSEC_SPI\n");
 	if (npc_is_field_present(rvu, NPC_IPSEC_SPI, intf) &&
 	    (*features & (BIT_ULL(NPC_IPPROTO_ESP) | BIT_ULL(NPC_IPPROTO_AH))))
 		*features |= BIT_ULL(NPC_IPSEC_SPI);
Signature · 1 line
2.43.0
author maintainer
#1 lore raw
Quoted 10 lines · Ratheesh Kannoth

From: Hariprasad Kelam <[email protected]>

When scanning the MKEX profile to determine supported NPC features, warn if the SPI extraction field overlaps with other key fields. AH and ESP may legitimately use the same key offset for SPI, so continue to advertise NPC_IPSEC_SPI via npc_is_field_present() instead of treating the overlap as a hard failure.

https://sashiko.dev/#/patchset/20260721070303.986740-1-rkannoth%40marvell.com wrote

Quoted 18 lines
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +0 -0

[ ... ]

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf) · line 737

Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +6 -1
-	/* Allow extracting SPI field from AH and ESP headers at same offset */
+	/* Warn on unrelated MKEX fields colliding with SPI key bits.  AH/ESP
+	 * sharing the same SPI key offset is valid; use npc_is_field_present(),
+	 * not npc_check_field(), to advertise the feature.
+	 */
+	if (npc_check_overlap(rvu, blkaddr, NPC_IPSEC_SPI, 0, intf))
+		dev_warn(rvu->dev, "Overlap detected the field NPC_IPSEC_SPI\n");

Will this warning spuriously trigger for valid AH and ESP configurations?

The NPC_IPSEC_SPI field extracts data from two different layers, NPC_LID_LD for AH and NPC_LID_LE for ESP. However, rx_key_fields[NPC_IPSEC_SPI].layer_mdata only stores the metadata of the last scanned layer.

Quoted 8 lines

When npc_check_overlap() processes the AH layer, npc_is_same() evaluates to false because the LIDs differ. Then npc_check_overlap_fields() compares their kw_masks, which intersect because the SPI kw_mask accumulated both AH and ESP extraction bits.

This appears to cause npc_check_overlap() to return true for its own layer component, warning unconditionally on valid profiles and contradicting the goal of ignoring legitimate AH/ESP overlap.

npc_check_overlap() is to check whether there is an overlap for the extracted key in meta data. We can ignore sashiko comment.

Quoted 7 lines

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c static void npc_set_features(struct rvu *rvu, int blkaddr, u8 intf) · line 740

Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +0 -0
 	if (npc_is_field_present(rvu, NPC_IPSEC_SPI, intf) &&
 	    (*features & (BIT_ULL(NPC_IPPROTO_ESP) | BIT_ULL(NPC_IPPROTO_AH))))
 		*features |= BIT_ULL(NPC_IPSEC_SPI);

Does bypassing the overlap check here allow corrupted key extraction?

Quoted 7 lines

If npc_check_overlap() detects a true collision with a completely unrelated MKEX field, such as VLAN or DMAC, this logic merely prints the warning above but still continues to set the NPC_IPSEC_SPI feature bit.

This seems to advertise support for the feature even when the hardware MKEX profile has genuinely overlapping extraction keys that could misclassify packets and incorrectly steer IPsec traffic.

Evenif overlap detected, system functions for most of the traffic, so print warning and continue. We can ignore sashiko comment.

#2 lore raw
In reply to Ratheesh Kannoth
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 9 lines · On Tue, 21 Jul 2026 12:33:03 +0530 you wrote:

From: Hariprasad Kelam <[email protected]>

When scanning the MKEX profile to determine supported NPC features, warn if the SPI extraction field overlaps with other key fields. AH and ESP may legitimately use the same key offset for SPI, so continue to advertise NPC_IPSEC_SPI via npc_is_field_present() instead of treating the overlap as a hard failure.

[...]

Here is the summary with links:
- [v2,net-next] octeontx2-af: npc: Warn on NPC_IPSEC_SPI key overlap

    https://git.kernel.org/netdev/net-next/c/72207e1b15d4

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html