From: Matan Azrad Date: Mon, 24 Jul 2017 13:47:33 +0000 (+0300) Subject: ethdev: fix flow rule copy functions X-Git-Tag: spdx-start~2329 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=857dc6803b1392c5cd1c6010e04f26d34953557f;p=dpdk.git ethdev: fix flow rule copy functions The corrupted code checks only RAW flow item type special case for returning its size but doesn't deal with any other flow item type and returns 0 for all the others. This bug leaves the flow descriptor empty for non RAW types. The fix takes the correct size to any regular types from appropriate array. The same issue, with a similar fix, is in flow action size method which deals only with RSS special type. This bug was already present in the original code taken from testpmd. Fixes: 18da437b5f63 ("ethdev: add flow rule copy function") Signed-off-by: Matan Azrad Acked-by: Adrien Mazarguil --- diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 884e4f649c..2001fbbf4b 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -248,8 +248,10 @@ static void flow_item_spec_size(const struct rte_flow_item *item, size_t *size, size_t *pad) { - if (!item->spec) + if (!item->spec) { + *size = 0; goto empty; + } switch (item->type) { union { const struct rte_flow_item_raw *raw; @@ -262,10 +264,10 @@ flow_item_spec_size(const struct rte_flow_item *item, spec.raw->length * sizeof(*spec.raw->pattern); break; default: -empty: - *size = 0; + *size = rte_flow_desc_item[item->type].size; break; } +empty: *pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size; } @@ -274,8 +276,10 @@ static void flow_action_conf_size(const struct rte_flow_action *action, size_t *size, size_t *pad) { - if (!action->conf) + if (!action->conf) { + *size = 0; goto empty; + } switch (action->type) { union { const struct rte_flow_action_rss *rss; @@ -288,10 +292,10 @@ flow_action_conf_size(const struct rte_flow_action *action, conf.rss->num * sizeof(*conf.rss->queue); break; default: -empty: - *size = 0; + *size = rte_flow_desc_action[action->type].size; break; } +empty: *pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size; }