From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 370CFF982 for ; Wed, 16 May 2018 17:42:04 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id m129-v6so2911992wmb.3 for ; Wed, 16 May 2018 08:42:04 -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:mime-version:content-disposition; bh=PIDh3pvukLYqP+DxTGTapdMpqWmvqi38LTMeHkm7ZDI=; b=S7LfHz8Z9Ejkjh7WIwgs6Hnwl8eX4EWxTV1bztIuTzTMoQuuZbWWpoY7RDyz787S1R g6hljySlE5LC2jSlkOVE+7DeUNfhAd2k0PbROrg+06HayVjyM3J6dNwNjmtIBxQtQwOu d1JvfYw/TQolqZg9O1NSNXbZQHQYw6qxmWvd4LZINUimWru8KH8hthKqaeNtMd63wmiO SYqxn1CzO787h8rKXMpmgpNxMTft24WXtq20b7morP4TD104QKuGvl8cvCtFfb6dWBsQ GN53lQPDJdWr9HzFYcInYWKt80GV7jaGAa/GfrFni2RjB1dxfsJkqvtHWXu+xf/Z4U8e W0eA== 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:mime-version :content-disposition; bh=PIDh3pvukLYqP+DxTGTapdMpqWmvqi38LTMeHkm7ZDI=; b=YnPBwso7Fg6pFWW4ocU5yv0ejdF/Xj+gQ+shpPtOjjFQK4UhodfySQRPoIas0RqyeT vwPWCg6YmUnAa7HmAxxmYdxJeY792jftvlwr/heZUsTKPCoscG4VctBYOVMwBapq7iNT frWl2AeG08P9KlEplL05AbCuu2XOY9Iy2fkUxoO59EAJ8kN7jNrRpLVbFpG+FG3EBFTE 3XAvQgLHEVB/gq2W9fNIGfm2wLdjr0rJzMzQmrH/dsFXkndWmQW+kxqyevVrtVeFy78j 1VZ5tjlYUmmtB1DOgY8uzU21TEP6srqVHk9zub/jGBhZkGFjW3e+u5i97gm0B+HkzG6o vA7g== X-Gm-Message-State: ALKqPwehsUq2+BbvIlVBYZBnGX+SehZ7j23JbrkNHHscTMw2Cj11XnF+ LHiRbw+kNTcGfvCImRWnX8xnQQ== X-Google-Smtp-Source: AB8JxZqqA3iUVIXcD6KL+XmNYcH+R2eEMrIpNcbk7x/d+09o4Fd8Sa+3L5hEMVFoz88q7FYZJHfqig== X-Received: by 2002:a1c:c10b:: with SMTP id r11-v6mr1039536wmf.120.1526485323832; Wed, 16 May 2018 08:42:03 -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 j9-v6sm2786834wri.55.2018.05.16.08.42.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 May 2018 08:42:02 -0700 (PDT) Date: Wed, 16 May 2018 17:41:48 +0200 From: Adrien Mazarguil To: Ferruh Yigit Cc: dev@dpdk.org, stable@dpdk.org, Qi Zhang Message-ID: <20180516154052.16836-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH 1/2] app/testpmd: fix copy of raw flow item (revisited) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 May 2018 15:42:04 -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