net/mlx5: fix ICMPv6 header rewrite actions
authorShiri Kuzin <shirik@mellanox.com>
Wed, 22 Jan 2020 14:37:54 +0000 (14:37 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 5 Feb 2020 08:51:20 +0000 (09:51 +0100)
The ConnectX-5 HW cannot calculate the checksum for ICMPv6,
therefore flows with pattern 'ipv6 proto is 58' with actions that change
the header should be rejected. the actions that change the header
in this type of flow are 'set_ipv6_src' and 'set_ipv6_dst'.

Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs")
Cc: stable@dpdk.org
Signed-off-by: Shiri Kuzin <shirik@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
drivers/net/mlx5/mlx5_flow_dv.c

index c2900c5..6987592 100644 (file)
@@ -4402,6 +4402,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
        uint8_t next_protocol = 0xff;
        uint16_t ether_type = 0;
        int actions_n = 0;
+       uint8_t item_ipv6_proto = 0;
        const struct rte_flow_item *gre_item = NULL;
        struct rte_flow_item_tcp nic_tcp_mask = {
                .hdr = {
@@ -4509,6 +4510,9 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
                        if (items->mask != NULL &&
                            ((const struct rte_flow_item_ipv6 *)
                             items->mask)->hdr.proto) {
+                               item_ipv6_proto =
+                                       ((const struct rte_flow_item_ipv6 *)
+                                        items->spec)->hdr.proto;
                                next_protocol =
                                        ((const struct rte_flow_item_ipv6 *)
                                         items->spec)->hdr.proto;
@@ -4881,6 +4885,12 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
                                                                  error);
                        if (ret < 0)
                                return ret;
+                       if (item_ipv6_proto == IPPROTO_ICMPV6)
+                               return rte_flow_error_set(error, ENOTSUP,
+                                       RTE_FLOW_ERROR_TYPE_ACTION,
+                                       actions,
+                                       "Can't change header "
+                                       "with ICMPv6 proto");
                        /* Count all modify-header actions as one action. */
                        if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS))
                                ++actions_n;