All of lore.kernel.org
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/mlx5: fix the empty flow error structure
@ 2020-04-17  7:30 Bing Zhao
  2020-04-29  9:44 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Bing Zhao @ 2020-04-17  7:30 UTC (permalink / raw)
  To: orika, viacheslavo, rasland; +Cc: matan, dev

The output flow error parameter is used to indicate the detailed
reason of the failure when calling a rte_flow_* interface. Even
though sometimes the application will not check it or use it, the PMD
must fill it in the failure branch before returning. Or else, some
dirty value in the stack, heap will be accessed as a pointer and then
cause a crash.
In this case, when a port is stopped, it is not allowed to insert a
flow from application. The detailed error information should be
filled. If the application needs to check the detailed error reason,
it will get the information but not result in any crash.

Fixes: 6ec024870715 ("net/mlx5: check device stat before creating flow")

Signed-off-by: Bing Zhao <bingz@mellanox.com>
Acked-by: Ori Kam <orika@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index c529aa3..6a5522c 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -4490,9 +4490,12 @@ struct rte_flow *
 	 * are not affected.
 	 */
 	if (unlikely(!dev->data->dev_started)) {
-		rte_errno = ENODEV;
 		DRV_LOG(DEBUG, "port %u is not started when "
 			"inserting a flow", dev->data->port_id);
+		rte_flow_error_set(error, ENODEV,
+				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+				   NULL,
+				   "port not started");
 		return NULL;
 	}
 	return (void *)(uintptr_t)flow_list_create(dev, &priv->flows,
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] net/mlx5: fix the empty flow error structure
  2020-04-17  7:30 [dpdk-dev] [PATCH] net/mlx5: fix the empty flow error structure Bing Zhao
@ 2020-04-29  9:44 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2020-04-29  9:44 UTC (permalink / raw)
  To: Bing Zhao, Ori Kam, Slava Ovsiienko; +Cc: Matan Azrad, dev

Hi,

> -----Original Message-----
> From: Bing Zhao <bingz@mellanox.com>
> Sent: Friday, April 17, 2020 10:31 AM
> To: Ori Kam <orika@mellanox.com>; Slava Ovsiienko
> <viacheslavo@mellanox.com>; Raslan Darawsheh <rasland@mellanox.com>
> Cc: Matan Azrad <matan@mellanox.com>; dev@dpdk.org
> Subject: [PATCH] net/mlx5: fix the empty flow error structure
> 
> The output flow error parameter is used to indicate the detailed
> reason of the failure when calling a rte_flow_* interface. Even
> though sometimes the application will not check it or use it, the PMD
> must fill it in the failure branch before returning. Or else, some
> dirty value in the stack, heap will be accessed as a pointer and then
> cause a crash.
> In this case, when a port is stopped, it is not allowed to insert a
> flow from application. The detailed error information should be
> filled. If the application needs to check the detailed error reason,
> it will get the information but not result in any crash.
> 
> Fixes: 6ec024870715 ("net/mlx5: check device stat before creating flow")
Fixed Fixes line sha
> 
> Signed-off-by: Bing Zhao <bingz@mellanox.com>
> Acked-by: Ori Kam <orika@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_flow.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index c529aa3..6a5522c 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -4490,9 +4490,12 @@ struct rte_flow *
>  	 * are not affected.
>  	 */
>  	if (unlikely(!dev->data->dev_started)) {
> -		rte_errno = ENODEV;
>  		DRV_LOG(DEBUG, "port %u is not started when "
>  			"inserting a flow", dev->data->port_id);
> +		rte_flow_error_set(error, ENODEV,
> +				   RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
> +				   NULL,
> +				   "port not started");
>  		return NULL;
>  	}
>  	return (void *)(uintptr_t)flow_list_create(dev, &priv->flows,
> --
> 1.8.3.1

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-29  9:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17  7:30 [dpdk-dev] [PATCH] net/mlx5: fix the empty flow error structure Bing Zhao
2020-04-29  9:44 ` Raslan Darawsheh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.