From: Gregory Etelson Date: Thu, 4 Nov 2021 11:27:21 +0000 (+0200) Subject: ethdev: fix variable length flow elements support X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=de39080bd68254c15f7779e89c88b5cc9842aa36;p=dpdk.git ethdev: fix variable length flow elements support RTE flow API defines two flow elements types - common and PMD private. Common RTE flow types are defined in rte_flow.h while PMD private types exists inside specific PMD only. Application can create a flow rule with PMD private items or actions. RTE flow API restricts private PMD types to negative values. Current implementation tried to use negative PMD private item type value as index in the rte_flow_desc_item[] array. The patch allows access to rte_flow_desc_item[] and rte_flow_desc_action[] arrays to non-private PMD types only. Fixes: 6cf72047332b ("ethdev: support flow elements with variable length") Signed-off-by: Gregory Etelson Reviewed-by: Ferruh Yigit --- diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index d268784532..a93f68abbc 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -54,11 +54,13 @@ rte_flow_conv_copy(void *buf, const void *data, const size_t size, /** * Allow PMD private flow item */ - size_t sz = type >= 0 ? desc[type].size : sizeof(void *); + bool rte_type = type >= 0; + + size_t sz = rte_type ? desc[type].size : sizeof(void *); if (buf == NULL || data == NULL) return 0; rte_memcpy(buf, data, (size > sz ? sz : size)); - if (desc[type].desc_fn) + if (rte_type && desc[type].desc_fn) sz += desc[type].desc_fn(size > 0 ? buf : NULL, data); return sz; }