From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ferruh Yigit Subject: Re: [PATCH 2/2] ethdev: fix shallow copy of flow API RAW item Date: Fri, 18 May 2018 18:06:20 +0100 Message-ID: <465390c3-5aa9-e015-52bd-cec695d84c4c@intel.com> References: <20180516154052.16836-1-adrien.mazarguil@6wind.com> <20180516154052.16836-2-adrien.mazarguil@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org, stable@dpdk.org, Qi Zhang To: Adrien Mazarguil , Thomas Monjalon Return-path: In-Reply-To: <20180516154052.16836-2-adrien.mazarguil@6wind.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 5/16/2018 4:41 PM, Adrien Mazarguil wrote: > 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 > > Signed-off-by: Adrien Mazarguil Hi Thomas, What do you suggest about this one? Scope is limited to rte_flow but still many features are now relies on rte_flow, what is your comment on getting this in rc5? > --- > 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: >