From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by dpdk.org (Postfix) with ESMTP id 2F9151AFEF for ; Mon, 21 May 2018 13:44:42 +0200 (CEST) Received: by mail-wr0-f194.google.com with SMTP id y15-v6so15679092wrg.11 for ; Mon, 21 May 2018 04:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PIDh3pvukLYqP+DxTGTapdMpqWmvqi38LTMeHkm7ZDI=; b=lGV9IveHXcH+egOz0uotTjEGze0Jdaq0vxKCJLuQnmcN6geu1jjC+wbdtcxnvtG+gx iH7ffXM2bV/IECnhUPUKcIdJBXn89rpnqYl+JgFZFYAMpzpeMBBnLqoHVapWK4t9bB6U sfEPNTBQAl70wt5VpiMZnLgVAYH50RmiIzgfxChto73q3U/7RvwCI8oEpkdS5VOHOmli vIzz7RvHzFYymg3RywHvfnvIFv0JpcIk+Rj4KeBB/iVqlw6RJ60rEvPCcX6ieYuyoP8C U2qMnLLg0L1hL/XBzA3PJTBBJl6eahcm8eq1TjYSepCuxZE/pNJgUgE3H0NQgYpnMCxL FYdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PIDh3pvukLYqP+DxTGTapdMpqWmvqi38LTMeHkm7ZDI=; b=GC076+zNIa8gECoSt1DryYQYXJAY2kDaF0bzMij9/y0oc3T81kp7kv6oFWzaTeNcsi 2CFHYrl8RZpRQ2B2wzqb5znBQSAzfsLN/S/r6GBqQJ4T2qJtV+VhEe56pC4tLlMO8sJi VGj9pMR6TOIY+BiJxJ+vdq7IGjS+a3HVbnBpQ3A8/vaPuPe7N7Bwa1Y0h3QVyFaaQqP8 e9k3YexPC99Osgkb0h0yW13PEQQsF05pN7zk0ma5EIn2k1zwJb+VSMUAz0YW0Sw2hdiZ 2pJPNaNJ3yJj2FP8iYdiJ1NN9cE7pW+ac8IssNKaZPjFbUtNe/VN5DcEjH3miYaXf2It hBbw== X-Gm-Message-State: ALKqPwdV6gUHs8HxXzJng+004nDDAA31bcSdKL9S/MCvitCmmLhhUCuU CFXOpP11o63smDpMgbiOYz89rvpJ X-Google-Smtp-Source: AB8JxZqR5KVL2UcqBcbj4ILDZzM5//FmdiW7IDtaAMtwW0fIKYcP08U28cd65LIZHNwdrXJruFIOdQ== X-Received: by 2002:adf:eb12:: with SMTP id s18-v6mr11247067wrn.174.1526903081955; Mon, 21 May 2018 04:44:41 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id x17-v6sm39885094wmd.46.2018.05.21.04.44.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 04:44:41 -0700 (PDT) Date: Mon, 21 May 2018 13:44:26 +0200 From: Adrien Mazarguil To: Ferruh Yigit Cc: dev@dpdk.org, stable@dpdk.org, Qi Zhang Message-ID: <20180521114345.690-1-adrien.mazarguil@6wind.com> References: <20180516154052.16836-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180516154052.16836-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-stable] [PATCH v2 1/2] app/testpmd: fix copy of raw flow item (revisited) X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2018 11:44:42 -0000 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 Signed-off-by: Adrien Mazarguil --- app/test-pmd/config.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index b07376af9..4520084b8 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -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: -- 2.11.0