From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id ED6FF288C for ; Fri, 25 Jan 2019 16:17:33 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 25 Jan 2019 17:17:32 +0200 Received: from pegasus12.mtr.labs.mlnx. (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x0PFHW0Q018133; Fri, 25 Jan 2019 17:17:32 +0200 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: shahafs@mellanox.com Date: Fri, 25 Jan 2019 15:17:30 +0000 Message-Id: <1548429450-27678-1-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: fix ETH and VLAN items for E-Switch flows 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: Fri, 25 Jan 2019 15:17:34 -0000 This patch fixes two issues for E-Switch Flows - RTE_FLOW_ITEM_TYPE_ETH and RTE_FLOW_ITEM_TYPE_VLAN with NULL in spec field caused the asserts in debug version and segfault in release, fixed, now empty items are allowed and treated in correctl way - empty RTE_FLOW_ITEM_TYPE_VLAN now sets the ethernet type to ETH_P_802.1Q, in previous version empty VLAN item was ignored Fixes: 3d14ad9be30e ("net/mlx5: support ethernet type for tunnels on E-Switch") Signed-off-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_tcf.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c index b8204df..916d3a0 100644 --- a/drivers/net/mlx5/mlx5_flow_tcf.c +++ b/drivers/net/mlx5/mlx5_flow_tcf.c @@ -2052,7 +2052,8 @@ struct pedit_parser { mask.eth, "no support for partial mask on" " \"type\" field"); - assert(items->spec); + if (!items->spec) + break; spec.eth = items->spec; if (mask.eth->type && (item_flags & MLX5_FLOW_LAYER_TUNNEL) && @@ -2123,7 +2124,8 @@ struct pedit_parser { "outer eth_type conflict," " must be 802.1Q"); outer_etype = RTE_BE16(ETH_P_8021Q); - assert(items->spec); + if (!items->spec) + break; spec.vlan = items->spec; if (mask.vlan->inner_type && vlan_etype != RTE_BE16(ETH_P_ALL) && @@ -2520,10 +2522,14 @@ struct pedit_parser { case RTE_FLOW_ITEM_TYPE_PORT_ID: break; case RTE_FLOW_ITEM_TYPE_ETH: + if (!items->spec) + break; size += SZ_NLATTR_DATA_OF(ETHER_ADDR_LEN) * 4; /* dst/src MAC addr and mask. */ break; case RTE_FLOW_ITEM_TYPE_VLAN: + if (!items->spec) + break; size += SZ_NLATTR_TYPE_OF(uint16_t) + /* VLAN Ether type. */ SZ_NLATTR_TYPE_OF(uint8_t) + /* VLAN prio. */ @@ -3319,6 +3325,8 @@ struct pedit_parser { assert(mask.eth); if (mask.eth == &flow_tcf_mask_empty.eth) break; + if (!items->spec) + break; spec.eth = items->spec; if (mask.eth->type) { if (item_flags & MLX5_FLOW_LAYER_TUNNEL) @@ -3363,12 +3371,13 @@ struct pedit_parser { sizeof(flow_tcf_mask_supported.vlan), error); assert(mask.vlan); - if (mask.vlan == &flow_tcf_mask_empty.vlan) - break; - spec.vlan = items->spec; assert(outer_etype == RTE_BE16(ETH_P_ALL) || outer_etype == RTE_BE16(ETH_P_8021Q)); outer_etype = RTE_BE16(ETH_P_8021Q); + if (mask.vlan == &flow_tcf_mask_empty.vlan) + break; + assert(items->spec); + spec.vlan = items->spec; if (mask.vlan->inner_type) vlan_etype = spec.vlan->inner_type; if (mask.vlan->tci & RTE_BE16(0xe000)) -- 1.8.3.1