net/mlx5: fix chosen L3/L4 layer with tunnel
authorSuanming Mou <suanmingm@mellanox.com>
Thu, 21 Nov 2019 12:09:30 +0000 (14:09 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 26 Nov 2019 17:05:15 +0000 (18:05 +0100)
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 <suanmingm@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
drivers/net/mlx5/mlx5_flow_dv.c

index 02f20fb..73aaea4 100644 (file)
@@ -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;