From patchwork Mon Nov 11 10:42:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matan Azrad X-Patchwork-Id: 62825 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BF136A04B7; Mon, 11 Nov 2019 11:42:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 85E6BCF3; Mon, 11 Nov 2019 11:42:31 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 9C360235 for ; Mon, 11 Nov 2019 11:42:29 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from matan@mellanox.com) with ESMTPS (AES256-SHA encrypted); 11 Nov 2019 12:42:24 +0200 Received: from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id xABAgOt6024005; Mon, 11 Nov 2019 12:42:24 +0200 From: Matan Azrad To: dev@dpdk.org Cc: Ori Kam , jackmin@mellanox.com Date: Mon, 11 Nov 2019 10:42:05 +0000 Message-Id: <1573468925-24415-1-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] ethdev: fix last item detection on RSS flow expand 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" There is a rte_flow API which expands a RSS flow pattern to multipile patterns according to the RSS hash types in the RSS action configuration. Aa part of the expansion, detection of the last item of the flow uses the "next proto" field of the last configured item in the pattern list. Wrongly, the mask of this field was not considered in order to validate the field. Ignore "next proto" fields when their corresponded masks invalidate them. Fixes: ec84aa45f17b ("ethdev: fix expand RSS flows") Cc: jackmin@mellanox.com Signed-off-by: Matan Azrad Acked-by: Xiaoyu Min Acked-by: Ori Kam --- lib/librte_ethdev/rte_flow.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index 8ec9c90..d7f29e5 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -218,12 +218,21 @@ struct rte_flow_desc_data { { enum rte_flow_item_type ret = RTE_FLOW_ITEM_TYPE_VOID; uint16_t ether_type = 0; + uint16_t ether_type_m; uint8_t ip_next_proto = 0; + uint8_t ip_next_proto_m; if (item == NULL || item->spec == NULL) return ret; switch (item->type) { case RTE_FLOW_ITEM_TYPE_ETH: + if (item->mask) + ether_type_m = ((const struct rte_flow_item_eth *) + (item->mask))->type; + else + ether_type_m = rte_flow_item_eth_mask.type; + if (ether_type_m != RTE_BE16(0xFFFF)) + break; ether_type = ((const struct rte_flow_item_eth *) (item->spec))->type; if (rte_be_to_cpu_16(ether_type) == RTE_ETHER_TYPE_IPV4) @@ -234,6 +243,13 @@ struct rte_flow_desc_data { ret = RTE_FLOW_ITEM_TYPE_VLAN; break; case RTE_FLOW_ITEM_TYPE_VLAN: + if (item->mask) + ether_type_m = ((const struct rte_flow_item_vlan *) + (item->mask))->inner_type; + else + ether_type_m = rte_flow_item_vlan_mask.inner_type; + if (ether_type_m != RTE_BE16(0xFFFF)) + break; ether_type = ((const struct rte_flow_item_vlan *) (item->spec))->inner_type; if (rte_be_to_cpu_16(ether_type) == RTE_ETHER_TYPE_IPV4) @@ -244,6 +260,14 @@ struct rte_flow_desc_data { ret = RTE_FLOW_ITEM_TYPE_VLAN; break; case RTE_FLOW_ITEM_TYPE_IPV4: + if (item->mask) + ip_next_proto_m = ((const struct rte_flow_item_ipv4 *) + (item->mask))->hdr.next_proto_id; + else + ip_next_proto_m = + rte_flow_item_ipv4_mask.hdr.next_proto_id; + if (ip_next_proto_m != 0xFF) + break; ip_next_proto = ((const struct rte_flow_item_ipv4 *) (item->spec))->hdr.next_proto_id; if (ip_next_proto == IPPROTO_UDP) @@ -256,6 +280,14 @@ struct rte_flow_desc_data { ret = RTE_FLOW_ITEM_TYPE_IPV6; break; case RTE_FLOW_ITEM_TYPE_IPV6: + if (item->mask) + ip_next_proto_m = ((const struct rte_flow_item_ipv6 *) + (item->mask))->hdr.proto; + else + ip_next_proto_m = + rte_flow_item_ipv6_mask.hdr.proto; + if (ip_next_proto_m != 0xFF) + break; ip_next_proto = ((const struct rte_flow_item_ipv6 *) (item->spec))->hdr.proto; if (ip_next_proto == IPPROTO_UDP)