DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/mlx5/hws: fix ESP header match in strict mode
@ 2025-08-04  5:05 Viacheslav Ovsiienko
  2025-08-08  7:30 ` Dariusz Sosnowski
  2025-08-18  6:33 ` Raslan Darawsheh
  0 siblings, 2 replies; 5+ messages in thread
From: Viacheslav Ovsiienko @ 2025-08-04  5:05 UTC (permalink / raw)
  To: dev; +Cc: rasland, matan, suanmingm, dsosnowski, stable

The pattern like "eth / ipv6 / esp / end" matched on any IPv6
packet in strict mode, because there was no impicit match on the
IP.proto forced.

This patch adds the implicit match on IP.proto with value 50 (ESP)
and adds implicit match on UDP.dport with value 4500 for the case
ESP over UDP.

Fixes: 18ca4a4ec73a ("net/mlx5: support ESP SPI match and RSS hash")
Cc: stable@dpdk.org

Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 38 ++++++++++++++++++++++++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c
index 7464d95373..113feae291 100644
--- a/drivers/net/mlx5/hws/mlx5dr_definer.c
+++ b/drivers/net/mlx5/hws/mlx5dr_definer.c
@@ -14,6 +14,7 @@
 #define UDP_VXLAN_PORT	4789
 #define UDP_VXLAN_GPE_PORT	4790
 #define UDP_GTPU_PORT	2152
+#define UDP_ESP_PORT	4500
 #define UDP_PORT_MPLS	6635
 #define UDP_GENEVE_PORT 6081
 #define UDP_ROCEV2_PORT	4791
@@ -231,6 +232,8 @@ struct mlx5dr_definer_conv_data {
 	X(SET_BE16,	nvgre_protocol,		v->protocol,		rte_flow_item_nvgre) \
 	X(SET_BE32P,	nvgre_dw1,		&v->tni[0],		rte_flow_item_nvgre) \
 	X(SET,		meter_color,		rte_col_2_mlx5_col(v->color),	rte_flow_item_meter_color) \
+	X(SET,		ipsec_protocol,		IPPROTO_ESP,		rte_flow_item_esp) \
+	X(SET,		ipsec_udp_port,		UDP_ESP_PORT,		rte_flow_item_esp) \
 	X(SET_BE32,     ipsec_spi,              v->hdr.spi,             rte_flow_item_esp) \
 	X(SET_BE32,     ipsec_sequence_number,  v->hdr.seq,             rte_flow_item_esp) \
 	X(SET,		ib_l4_udp_port,		UDP_ROCEV2_PORT,	rte_flow_item_ib_bth) \
@@ -2481,7 +2484,9 @@ mlx5dr_definer_conv_item_meter_color(struct mlx5dr_definer_conv_data *cd,
 }
 
 static struct mlx5dr_definer_fc *
-mlx5dr_definer_get_flex_parser_fc(struct mlx5dr_definer_conv_data *cd, uint32_t byte_off)
+mlx5dr_definer_get_flex_parser_fc(struct mlx5dr_definer_conv_data *cd,
+				  uint32_t byte_off,
+				  int item_idx)
 {
 	uint32_t byte_off_fp7 = MLX5_BYTE_OFF(definer_hl, flex_parser.flex_parser_7);
 	uint32_t byte_off_fp0 = MLX5_BYTE_OFF(definer_hl, flex_parser.flex_parser_0);
@@ -2493,6 +2498,33 @@ mlx5dr_definer_get_flex_parser_fc(struct mlx5dr_definer_conv_data *cd, uint32_t
 		rte_errno = EINVAL;
 		return NULL;
 	}
+
+	/* To match on ESP we must match on ip_protocol and optionally on l4_dport */
+	if (!cd->relaxed) {
+		bool over_udp;
+
+		fc = &cd->fc[DR_CALC_FNAME(IP_PROTOCOL, false)];
+		over_udp = fc->tag_set == &mlx5dr_definer_udp_protocol_set;
+
+		if (over_udp) {
+			fc = &cd->fc[DR_CALC_FNAME(L4_DPORT, false)];
+			if (!fc->tag_set) {
+				fc->item_idx = item_idx;
+				fc->tag_mask_set = &mlx5dr_definer_ones_set;
+				fc->tag_set = &mlx5dr_definer_ipsec_udp_port_set;
+				DR_CALC_SET(fc, eth_l4, destination_port, false);
+			}
+		} else {
+			fc = &cd->fc[DR_CALC_FNAME(IP_PROTOCOL, false)];
+			if (!fc->tag_set) {
+				fc->item_idx = item_idx;
+				fc->tag_set = &mlx5dr_definer_ipsec_protocol_set;
+				fc->tag_mask_set = &mlx5dr_definer_ones_set;
+				DR_CALC_SET(fc, eth_l3, protocol_next_header, false);
+			}
+		}
+	}
+
 	idx = (byte_off_fp0 - byte_off) / (sizeof(uint32_t));
 	fname += (enum mlx5dr_definer_fname)idx;
 	fc = &cd->fc[fname];
@@ -2544,7 +2576,7 @@ mlx5dr_definer_conv_item_ipv6_routing_ext(struct mlx5dr_definer_conv_data *cd,
 
 	if (m->hdr.next_hdr || m->hdr.type || m->hdr.segments_left) {
 		byte_off = flow_hw_get_srh_flex_parser_byte_off_from_ctx(cd->ctx);
-		fc = mlx5dr_definer_get_flex_parser_fc(cd, byte_off);
+		fc = mlx5dr_definer_get_flex_parser_fc(cd, byte_off, item_idx);
 		if (!fc)
 			return rte_errno;
 
@@ -2666,7 +2698,7 @@ mlx5dr_definer_conv_item_ecpri(struct mlx5dr_definer_conv_data *cd,
 		if (!mask)
 			continue;
 		mask = htobe32(mask);
-		fc = mlx5dr_definer_get_flex_parser_fc(cd, byte_off[i]);
+		fc = mlx5dr_definer_get_flex_parser_fc(cd, byte_off[i], item_idx);
 		if (!fc)
 			return rte_errno;
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/mlx5/hws: fix ESP header match in strict mode
  2025-08-04  5:05 [PATCH] net/mlx5/hws: fix ESP header match in strict mode Viacheslav Ovsiienko
@ 2025-08-08  7:30 ` Dariusz Sosnowski
  2025-08-18  6:33 ` Raslan Darawsheh
  1 sibling, 0 replies; 5+ messages in thread
From: Dariusz Sosnowski @ 2025-08-08  7:30 UTC (permalink / raw)
  To: Viacheslav Ovsiienko; +Cc: dev, rasland, matan, suanmingm, stable

On Mon, Aug 04, 2025 at 08:05:14AM +0300, Viacheslav Ovsiienko wrote:
> The pattern like "eth / ipv6 / esp / end" matched on any IPv6
> packet in strict mode, because there was no impicit match on the
> IP.proto forced.
> 
> This patch adds the implicit match on IP.proto with value 50 (ESP)
> and adds implicit match on UDP.dport with value 4500 for the case
> ESP over UDP.
> 
> Fixes: 18ca4a4ec73a ("net/mlx5: support ESP SPI match and RSS hash")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>

Best regards,
Dariusz Sosnowski

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/mlx5/hws: fix ESP header match in strict mode
  2025-08-04  5:05 [PATCH] net/mlx5/hws: fix ESP header match in strict mode Viacheslav Ovsiienko
  2025-08-08  7:30 ` Dariusz Sosnowski
@ 2025-08-18  6:33 ` Raslan Darawsheh
  2025-09-08 12:12   ` Maayan Kashani
  1 sibling, 1 reply; 5+ messages in thread
From: Raslan Darawsheh @ 2025-08-18  6:33 UTC (permalink / raw)
  To: Viacheslav Ovsiienko, dev; +Cc: matan, suanmingm, dsosnowski, stable

Hi,


On 04/08/2025 8:05 AM, Viacheslav Ovsiienko wrote:
> The pattern like "eth / ipv6 / esp / end" matched on any IPv6
> packet in strict mode, because there was no impicit match on the
> IP.proto forced.
> 
> This patch adds the implicit match on IP.proto with value 50 (ESP)
> and adds implicit match on UDP.dport with value 4500 for the case
> ESP over UDP.
> 
> Fixes: 18ca4a4ec73a ("net/mlx5: support ESP SPI match and RSS hash")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] net/mlx5/hws: fix ESP header match in strict mode
  2025-08-18  6:33 ` Raslan Darawsheh
@ 2025-09-08 12:12   ` Maayan Kashani
  2025-09-08 12:26     ` Raslan Darawsheh
  0 siblings, 1 reply; 5+ messages in thread
From: Maayan Kashani @ 2025-09-08 12:12 UTC (permalink / raw)
  To: Raslan Darawsheh, Slava Ovsiienko, dev
  Cc: Matan Azrad, Suanming Mou, Dariusz Sosnowski, stable

Please drop this patch, 
the merge was incorrect and the code is incorrect.

Regards,
Maayan Kashani

> -----Original Message-----
> From: Raslan Darawsheh <rasland@nvidia.com>
> Sent: Monday, 18 August 2025 9:33
> To: Slava Ovsiienko <viacheslavo@nvidia.com>; dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>; Dariusz Sosnowski <dsosnowski@nvidia.com>;
> stable@dpdk.org
> Subject: Re: [PATCH] net/mlx5/hws: fix ESP header match in strict mode
> 
> External email: Use caution opening links or attachments
> 
> 
> Hi,
> 
> 
> On 04/08/2025 8:05 AM, Viacheslav Ovsiienko wrote:
> > The pattern like "eth / ipv6 / esp / end" matched on any IPv6 packet
> > in strict mode, because there was no impicit match on the IP.proto
> > forced.
> >
> > This patch adds the implicit match on IP.proto with value 50 (ESP) and
> > adds implicit match on UDP.dport with value 4500 for the case ESP over
> > UDP.
> >
> > Fixes: 18ca4a4ec73a ("net/mlx5: support ESP SPI match and RSS hash")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> 
> Patch applied to next-net-mlx,
> 
> Kindest regards
> Raslan Darawsheh


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net/mlx5/hws: fix ESP header match in strict mode
  2025-09-08 12:12   ` Maayan Kashani
@ 2025-09-08 12:26     ` Raslan Darawsheh
  0 siblings, 0 replies; 5+ messages in thread
From: Raslan Darawsheh @ 2025-09-08 12:26 UTC (permalink / raw)
  To: Maayan Kashani, Slava Ovsiienko, dev
  Cc: Matan Azrad, Suanming Mou, Dariusz Sosnowski, stable


On 08/09/2025 3:12 PM, Maayan Kashani wrote:
> Please drop this patch,
> the merge was incorrect and the code is incorrect.
there isn't anything wrong in the merge, the patch was merged as is.
I'll drop this version of this patch and you can send a V2 for it.

Kindest regards
Raslan Darawsheh


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-09-08 12:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-04  5:05 [PATCH] net/mlx5/hws: fix ESP header match in strict mode Viacheslav Ovsiienko
2025-08-08  7:30 ` Dariusz Sosnowski
2025-08-18  6:33 ` Raslan Darawsheh
2025-09-08 12:12   ` Maayan Kashani
2025-09-08 12:26     ` Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).