From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org, stable@dpdk.org, Qi Zhang <qi.z.zhang@intel.com>
Subject: [dpdk-dev] [PATCH 2/2] ethdev: fix shallow copy of flow API RAW item
Date: Wed, 16 May 2018 17:41:50 +0200 [thread overview]
Message-ID: <20180516154052.16836-2-adrien.mazarguil@6wind.com> (raw)
In-Reply-To: <20180516154052.16836-1-adrien.mazarguil@6wind.com>
Like original commit mentioned below, this fix synchronizes flow rule copy
function with testpmd's own implementation following "app/testpmd: fix copy
of raw flow item (revisited)".
Fixes: d0ad8648b1c5 ("ethdev: fix shallow copy of flow API RSS action")
Cc: stable@dpdk.org
Cc: Qi Zhang <qi.z.zhang@intel.com>
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_ethdev/rte_flow.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c
index 7947529da..b2afba089 100644
--- a/lib/librte_ethdev/rte_flow.c
+++ b/lib/librte_ethdev/rte_flow.c
@@ -300,17 +300,26 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
enum item_spec_type type)
{
size_t size = 0;
- const void *item_spec =
+ const void *data =
type == ITEM_SPEC ? item->spec :
type == ITEM_LAST ? item->last :
type == ITEM_MASK ? item->mask :
NULL;
- if (!item_spec)
+ if (!item->spec || !data)
goto empty;
switch (item->type) {
union {
const struct rte_flow_item_raw *raw;
+ } spec;
+ union {
+ const struct rte_flow_item_raw *raw;
+ } last;
+ union {
+ const struct rte_flow_item_raw *raw;
+ } mask;
+ union {
+ const struct rte_flow_item_raw *raw;
} src;
union {
struct rte_flow_item_raw *raw;
@@ -318,11 +327,21 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
size_t off;
case RTE_FLOW_ITEM_TYPE_RAW:
- src.raw = item_spec;
+ spec.raw = item->spec;
+ last.raw = item->last ? item->last : item->spec;
+ mask.raw = item->mask ? item->mask : &rte_flow_item_raw_mask;
+ src.raw = data;
dst.raw = buf;
off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw),
sizeof(*src.raw->pattern));
- size = off + src.raw->length * sizeof(*src.raw->pattern);
+ if (type == ITEM_SPEC ||
+ (type == ITEM_MASK &&
+ ((spec.raw->length & mask.raw->length) >=
+ (last.raw->length & mask.raw->length))))
+ size = spec.raw->length & mask.raw->length;
+ else
+ size = last.raw->length & mask.raw->length;
+ size = off + size * sizeof(*src.raw->pattern);
if (dst.raw) {
memcpy(dst.raw, src.raw, sizeof(*src.raw));
dst.raw->pattern = memcpy((uint8_t *)dst.raw + off,
@@ -333,7 +352,7 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
default:
size = rte_flow_desc_item[item->type].size;
if (buf)
- memcpy(buf, item_spec, size);
+ memcpy(buf, data, size);
break;
}
empty:
--
2.11.0
next prev parent reply other threads:[~2018-05-16 15:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-16 15:41 [dpdk-dev] [PATCH 1/2] app/testpmd: fix copy of raw flow item (revisited) Adrien Mazarguil
2018-05-16 15:41 ` Adrien Mazarguil [this message]
2018-05-18 17:06 ` [dpdk-dev] [PATCH 2/2] ethdev: fix shallow copy of flow API RAW item Ferruh Yigit
2018-05-19 14:25 ` Thomas Monjalon
2018-05-21 8:24 ` Adrien Mazarguil
2018-05-21 10:44 ` Ferruh Yigit
2018-05-21 11:18 ` Adrien Mazarguil
2018-05-17 14:44 ` [dpdk-dev] [PATCH 1/2] app/testpmd: fix copy of raw flow item (revisited) Iremonger, Bernard
2018-05-21 11:44 ` [dpdk-dev] [PATCH v2 " Adrien Mazarguil
2018-05-21 11:44 ` [dpdk-dev] [PATCH v2 2/2] ethdev: fix shallow copy of flow API RAW item Adrien Mazarguil
2018-05-21 12:44 ` [dpdk-dev] [PATCH v2 1/2] app/testpmd: fix copy of raw flow item (revisited) Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180516154052.16836-2-adrien.mazarguil@6wind.com \
--to=adrien.mazarguil@6wind.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=qi.z.zhang@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).