net/ixgbe: fix parsing FDIR NVGRE issue
authorWei Zhao <wei.zhao1@intel.com>
Fri, 22 Dec 2017 05:45:59 +0000 (13:45 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
This patch fixes the issue of mask check in NVGRE parser
for flow API.

Fixes: 11777435c727 ("net/ixgbe: parse flow director filter")
Cc: stable@dpdk.org
Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
drivers/net/ixgbe/ixgbe_flow.c

index f31aebd..b143b72 100644 (file)
@@ -2492,8 +2492,7 @@ ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,
                                item, "Not supported by fdir filter");
                        return -rte_errno;
                }
-               if (nvgre_mask->c_k_s_rsvd0_ver !=
-                       rte_cpu_to_be_16(0x3000) ||
+               if (nvgre_mask->protocol &&
                    nvgre_mask->protocol != 0xFFFF) {
                        memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
                        rte_flow_error_set(error, EINVAL,
@@ -2501,6 +2500,15 @@ ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,
                                item, "Not supported by fdir filter");
                        return -rte_errno;
                }
+               if (nvgre_mask->c_k_s_rsvd0_ver &&
+                   nvgre_mask->c_k_s_rsvd0_ver !=
+                       rte_cpu_to_be_16(0xFFFF)) {
+                       memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
+                       rte_flow_error_set(error, EINVAL,
+                               RTE_FLOW_ERROR_TYPE_ITEM,
+                               item, "Not supported by fdir filter");
+                       return -rte_errno;
+               }
                /* TNI must be totally masked or not. */
                if (nvgre_mask->tni[0] &&
                    ((nvgre_mask->tni[0] != 0xFF) ||
@@ -2522,7 +2530,15 @@ ixgbe_parse_fdir_filter_tunnel(const struct rte_flow_attr *attr,
                        nvgre_spec =
                                (const struct rte_flow_item_nvgre *)item->spec;
                        if (nvgre_spec->c_k_s_rsvd0_ver !=
-                           rte_cpu_to_be_16(0x2000) ||
+                           rte_cpu_to_be_16(0x2000) &&
+                               nvgre_mask->c_k_s_rsvd0_ver) {
+                               memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
+                               rte_flow_error_set(error, EINVAL,
+                                       RTE_FLOW_ERROR_TYPE_ITEM,
+                                       item, "Not supported by fdir filter");
+                               return -rte_errno;
+                       }
+                       if (nvgre_mask->protocol &&
                            nvgre_spec->protocol !=
                            rte_cpu_to_be_16(NVGRE_PROTOCOL)) {
                                memset(rule, 0, sizeof(struct ixgbe_fdir_rule));