From: Suanming Mou Date: Thu, 21 Nov 2019 12:09:30 +0000 (+0200) Subject: net/mlx5: fix chosen L3/L4 layer with tunnel X-Git-Url: http://git.droids-corp.org/?p=dpdk.git;a=commitdiff_plain;h=7c1852e48f75cebd0213698f4d7d4137a45d3a34 net/mlx5: fix chosen L3/L4 layer with tunnel For tunnel mode, there may be two L3/L4 layer match pattern items, one for inner and one for outer layers. The L3 TTL and L4 port header modify actions should handle the outermost layer items. Currently flow_dv_attr_init() doesn't distinguish between outer and inner layers, since inner layer comes later than the outer layer, this may cause inner layer values also set to the flow attributes and may lead actions to use inner L3/L4 pattern items. Adding a check in flow_dv_attr_init() to prevent inner layer to set the flow attribute if the previous L3/L4 outer pattern exist. Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs") Cc: stable@dpdk.org Signed-off-by: Suanming Mou Acked-by: Matan Azrad --- diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 02f20fb2ae..73aaea4536 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -75,6 +75,9 @@ union flow_dv_attr { /** * Initialize flow attributes structure according to flow items' types. * + * flow_dv_validate() avoids multiple L3/L4 layers cases other than tunnel + * mode. For tunnel mode, the items to be modified are the outermost ones. + * * @param[in] item * Pointer to item specification. * @param[out] attr @@ -86,16 +89,20 @@ flow_dv_attr_init(const struct rte_flow_item *item, union flow_dv_attr *attr) for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { switch (item->type) { case RTE_FLOW_ITEM_TYPE_IPV4: - attr->ipv4 = 1; + if (!attr->ipv6) + attr->ipv4 = 1; break; case RTE_FLOW_ITEM_TYPE_IPV6: - attr->ipv6 = 1; + if (!attr->ipv4) + attr->ipv6 = 1; break; case RTE_FLOW_ITEM_TYPE_UDP: - attr->udp = 1; + if (!attr->tcp) + attr->udp = 1; break; case RTE_FLOW_ITEM_TYPE_TCP: - attr->tcp = 1; + if (!attr->udp) + attr->tcp = 1; break; default: break;