[dpdk-dev,1/2] app/testpmd: fix copy of raw flow item (revisited)
Checks
Commit Message
While previous fix with the same title does address the main issue, root
cause is that proper handling of spec/last/mask was overlooked in the
original patch.
Mask and last fields must be taken into account at all times.
Fixes: d0ad8648b1c5 ("app/testpmd: fix RSS flow action configuration")
Fixes: 67af7ecc52ec ("app/testpmd: fix copy of raw flow item")
Cc: stable@dpdk.org
Cc: Qi Zhang <qi.z.zhang@intel.com>
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
app/test-pmd/config.c | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
Comments
Hi Adrien,
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Adrien Mazarguil
> Sent: Wednesday, May 16, 2018 4:42 PM
> To: Yigit, Ferruh <ferruh.yigit@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: [dpdk-dev] [PATCH 1/2] app/testpmd: fix copy of raw flow item
> (revisited)
>
> While previous fix with the same title does address the main issue, root cause is
> that proper handling of spec/last/mask was overlooked in the original patch.
>
> Mask and last fields must be taken into account at all times.
>
> Fixes: d0ad8648b1c5 ("app/testpmd: fix RSS flow action configuration")
> Fixes: 67af7ecc52ec ("app/testpmd: fix copy of raw flow item")
> Cc: stable@dpdk.org
> Cc: Qi Zhang <qi.z.zhang@intel.com>
>
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
@@ -1049,17 +1049,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;
@@ -1067,12 +1076,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 + ((const struct rte_flow_item_raw *)item->spec)->
- 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,
@@ -1083,7 +1101,7 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item,
default:
size = flow_item[item->type].size;
if (buf)
- memcpy(buf, item_spec, size);
+ memcpy(buf, data, size);
break;
}
empty: