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: 4bb14c83df ("net/mlx5: support modify header using Direct Verbs")
Cc: stable@dpdk.org

Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
This commit is contained in:
Suanming Mou 2019-11-21 14:09:30 +02:00 committed by Ferruh Yigit
parent 7392ad06f5
commit 7c1852e48f

View File

@ -75,6 +75,9 @@ union flow_dv_attr {
/** /**
* Initialize flow attributes structure according to flow items' types. * 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 * @param[in] item
* Pointer to item specification. * Pointer to item specification.
* @param[out] attr * @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++) { for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
switch (item->type) { switch (item->type) {
case RTE_FLOW_ITEM_TYPE_IPV4: case RTE_FLOW_ITEM_TYPE_IPV4:
attr->ipv4 = 1; if (!attr->ipv6)
attr->ipv4 = 1;
break; break;
case RTE_FLOW_ITEM_TYPE_IPV6: case RTE_FLOW_ITEM_TYPE_IPV6:
attr->ipv6 = 1; if (!attr->ipv4)
attr->ipv6 = 1;
break; break;
case RTE_FLOW_ITEM_TYPE_UDP: case RTE_FLOW_ITEM_TYPE_UDP:
attr->udp = 1; if (!attr->tcp)
attr->udp = 1;
break; break;
case RTE_FLOW_ITEM_TYPE_TCP: case RTE_FLOW_ITEM_TYPE_TCP:
attr->tcp = 1; if (!attr->udp)
attr->tcp = 1;
break; break;
default: default:
break; break;