net/mlx5: fix crash on null operation
authorMoti Haimovsky <motih@mellanox.com>
Mon, 1 Jul 2019 09:34:21 +0000 (12:34 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 4 Jul 2019 23:52:02 +0000 (01:52 +0200)
mlx5 implements mlx5_flow_null_drv_ops to be used when a specific
flow typei/driver is not available or invalid.
This routines return error without modifying the rte_flow_error
parameter passed to them which causes testpmd, for example, to crash.
This commit addresses the issue by modifying the rte_flow_error
parameter in theses routines.

Fixes: 0c76d1c9a18d ("net/mlx5: add abstraction for multiple flow drivers")
Fixes: 684dafe795d0 ("net/mlx5: add flow query abstraction interface")
Cc: stable@dpdk.org
Signed-off-by: Moti Haimovsky <motih@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
drivers/net/mlx5/mlx5_flow.c

index c03eb4c..251da41 100644 (file)
@@ -1694,19 +1694,20 @@ flow_null_validate(struct rte_eth_dev *dev __rte_unused,
                   const struct rte_flow_attr *attr __rte_unused,
                   const struct rte_flow_item items[] __rte_unused,
                   const struct rte_flow_action actions[] __rte_unused,
-                  struct rte_flow_error *error __rte_unused)
+                  struct rte_flow_error *error)
 {
-       rte_errno = ENOTSUP;
-       return -rte_errno;
+       return rte_flow_error_set(error, ENOTSUP,
+                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, NULL);
 }
 
 static struct mlx5_flow *
 flow_null_prepare(const struct rte_flow_attr *attr __rte_unused,
                  const struct rte_flow_item items[] __rte_unused,
                  const struct rte_flow_action actions[] __rte_unused,
-                 struct rte_flow_error *error __rte_unused)
+                 struct rte_flow_error *error)
 {
-       rte_errno = ENOTSUP;
+       rte_flow_error_set(error, ENOTSUP,
+                          RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, NULL);
        return NULL;
 }
 
@@ -1716,19 +1717,19 @@ flow_null_translate(struct rte_eth_dev *dev __rte_unused,
                    const struct rte_flow_attr *attr __rte_unused,
                    const struct rte_flow_item items[] __rte_unused,
                    const struct rte_flow_action actions[] __rte_unused,
-                   struct rte_flow_error *error __rte_unused)
+                   struct rte_flow_error *error)
 {
-       rte_errno = ENOTSUP;
-       return -rte_errno;
+       return rte_flow_error_set(error, ENOTSUP,
+                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, NULL);
 }
 
 static int
 flow_null_apply(struct rte_eth_dev *dev __rte_unused,
                struct rte_flow *flow __rte_unused,
-               struct rte_flow_error *error __rte_unused)
+               struct rte_flow_error *error)
 {
-       rte_errno = ENOTSUP;
-       return -rte_errno;
+       return rte_flow_error_set(error, ENOTSUP,
+                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, NULL);
 }
 
 static void
@@ -1748,10 +1749,10 @@ flow_null_query(struct rte_eth_dev *dev __rte_unused,
                struct rte_flow *flow __rte_unused,
                const struct rte_flow_action *actions __rte_unused,
                void *data __rte_unused,
-               struct rte_flow_error *error __rte_unused)
+               struct rte_flow_error *error)
 {
-       rte_errno = ENOTSUP;
-       return -rte_errno;
+       return rte_flow_error_set(error, ENOTSUP,
+                                 RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, NULL);
 }
 
 /* Void driver to protect from null pointer reference. */