patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] ethdev: fix GENEVE option item conversion
@ 2024-07-15 12:13 Michael Baum
  2024-07-19  8:31 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Baum @ 2024-07-15 12:13 UTC (permalink / raw)
  To: dev; +Cc: Dariusz Sosnowski, Thomas Monjalon, Ferruh Yigit, Ori Kam, stable

The "rte_flow_conv()" function, enables, among other things, to copy
item list.

For GENEVE option item, the function copies it without considering deep
copy. It copies the "data" pointer without copying the pointed values.

This patch adds deep copy for after regular copy.

Fixes: 2b4c72b4d10d ("ethdev: introduce GENEVE header TLV option item")
Cc: stable@dpdk.org

Signed-off-by: Michael Baum <michaelba@nvidia.com>
---
 lib/ethdev/rte_flow.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index ca2f85c3fa..4076ae4ee1 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -623,6 +623,7 @@ rte_flow_conv_item_spec(void *buf, const size_t size,
 	switch (item->type) {
 		union {
 			const struct rte_flow_item_raw *raw;
+			const struct rte_flow_item_geneve_opt *geneve_opt;
 		} spec;
 		union {
 			const struct rte_flow_item_raw *raw;
@@ -632,10 +633,13 @@ rte_flow_conv_item_spec(void *buf, const size_t size,
 		} mask;
 		union {
 			const struct rte_flow_item_raw *raw;
+			const struct rte_flow_item_geneve_opt *geneve_opt;
 		} src;
 		union {
 			struct rte_flow_item_raw *raw;
+			struct rte_flow_item_geneve_opt *geneve_opt;
 		} dst;
+		void *deep_src;
 		size_t tmp;
 
 	case RTE_FLOW_ITEM_TYPE_RAW:
@@ -664,13 +668,30 @@ rte_flow_conv_item_spec(void *buf, const size_t size,
 			tmp = last.raw->length & mask.raw->length;
 		if (tmp) {
 			off = RTE_ALIGN_CEIL(off, sizeof(*dst.raw->pattern));
-			if (size >= off + tmp)
-				dst.raw->pattern = rte_memcpy
-					((void *)((uintptr_t)dst.raw + off),
-					 src.raw->pattern, tmp);
+			if (size >= off + tmp) {
+				deep_src = (void *)((uintptr_t)dst.raw + off);
+				dst.raw->pattern = rte_memcpy(deep_src,
+							      src.raw->pattern,
+							      tmp);
+			}
 			off += tmp;
 		}
 		break;
+	case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
+		off = rte_flow_conv_copy(buf, data, size,
+					 rte_flow_desc_item, item->type);
+		spec.geneve_opt = item->spec;
+		src.geneve_opt = data;
+		dst.geneve_opt = buf;
+		tmp = spec.geneve_opt->option_len << 2;
+		if (size > 0 && src.geneve_opt->data) {
+			deep_src = (void *)((uintptr_t)(dst.geneve_opt + 1));
+			dst.geneve_opt->data = rte_memcpy(deep_src,
+							  src.geneve_opt->data,
+							  tmp);
+		}
+		off += tmp;
+		break;
 	default:
 		off = rte_flow_conv_copy(buf, data, size,
 					 rte_flow_desc_item, item->type);
-- 
2.25.1


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

* Re: [PATCH] ethdev: fix GENEVE option item conversion
  2024-07-15 12:13 [PATCH] ethdev: fix GENEVE option item conversion Michael Baum
@ 2024-07-19  8:31 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2024-07-19  8:31 UTC (permalink / raw)
  To: Michael Baum, dev; +Cc: Dariusz Sosnowski, Thomas Monjalon, Ori Kam, stable

On 7/15/2024 1:13 PM, Michael Baum wrote:
> The "rte_flow_conv()" function, enables, among other things, to copy
> item list.
> 
> For GENEVE option item, the function copies it without considering deep
> copy. It copies the "data" pointer without copying the pointed values.
> 
> This patch adds deep copy for after regular copy.
> 
> Fixes: 2b4c72b4d10d ("ethdev: introduce GENEVE header TLV option item")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Michael Baum <michaelba@nvidia.com>
>

Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>

Applied to dpdk-next-net/main, thanks.


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

end of thread, other threads:[~2024-07-19  8:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-15 12:13 [PATCH] ethdev: fix GENEVE option item conversion Michael Baum
2024-07-19  8:31 ` Ferruh Yigit

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).