[dpdk-dev] net/mlx5: fix drop action seg fault

Message ID 4233196997a3d8aba05b16a130ccc87f27f076bf.1498046009.git.shacharbe@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Shachar Beiser June 21, 2017, 11:55 a.m. UTC
  Missing room in flow allocation to store the drop specification.
Changing flow without storing the change in rte_flow.
Fixes: 88c77dedfbb0 ("net/mlx5: implement drop action in hardware classifier")

Signed-off-by: Shachar Beiser <shacharbe@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
  

Comments

Nélio Laranjeiro June 21, 2017, 1:02 p.m. UTC | #1
On Wed, Jun 21, 2017 at 11:55:58AM +0000, Shachar Beiser wrote:
> Missing room in flow allocation to store the drop specification.
> Changing flow without storing the change in rte_flow.
> Fixes: 88c77dedfbb0 ("net/mlx5: implement drop action in hardware classifier")
> 
> Signed-off-by: Shachar Beiser <shacharbe@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_flow.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 12893c6..cad3d16 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -580,6 +580,8 @@ struct mlx5_flow_action {
>  	}
>  	if (action->mark && !flow->ibv_attr && !action->drop)
>  		flow->offset += sizeof(struct ibv_exp_flow_spec_action_tag);
> +	if (!flow->ibv_attr && action->drop)
> +		flow->offset += sizeof(struct ibv_exp_flow_spec_action_drop);
>  	if (!action->queue && !action->drop) {
>  		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE,
>  				   NULL, "no valid action");
> @@ -1011,9 +1013,6 @@ struct mlx5_flow_action {
>  		return NULL;
>  	}
>  	rte_flow->drop = 1;
> -	rte_flow->ibv_attr = flow->ibv_attr;
> -	if (!priv->started)
> -		return rte_flow;
>  #ifdef HAVE_VERBS_IBV_EXP_FLOW_SPEC_ACTION_DROP
>  	drop = (void *)((uintptr_t)flow->ibv_attr + flow->offset);
>  	*drop = (struct ibv_exp_flow_spec_action_drop){
> @@ -1023,6 +1022,9 @@ struct mlx5_flow_action {
>  	++flow->ibv_attr->num_of_specs;
>  	flow->offset += sizeof(struct ibv_exp_flow_spec_action_drop);
>  #endif
> +	rte_flow->ibv_attr = flow->ibv_attr;
> +	if (!priv->started)
> +		return rte_flow;
>  	rte_flow->qp = priv->flow_drop_queue->qp;
>  	rte_flow->ibv_flow = ibv_exp_create_flow(rte_flow->qp,
>  						 rte_flow->ibv_attr);
> -- 
> 1.8.3.1

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

Ferruh, this patch is fixing an issue of a patch only present in your
master-net branch, the fixline sha1 will be wrong.

Thanks,
  
Ferruh Yigit June 22, 2017, 9:51 a.m. UTC | #2
Hi Nelio,

On 6/21/2017 2:02 PM, Nélio Laranjeiro wrote:
> On Wed, Jun 21, 2017 at 11:55:58AM +0000, Shachar Beiser wrote:
>> Missing room in flow allocation to store the drop specification.
>> Changing flow without storing the change in rte_flow.
>> Fixes: 88c77dedfbb0 ("net/mlx5: implement drop action in hardware classifier")
>>
>> Signed-off-by: Shachar Beiser <shacharbe@mellanox.com>

<...>

>> -- 
>> 1.8.3.1
> 
> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> 
> Ferruh, this patch is fixing an issue of a patch only present in your
> master-net branch, the fixline sha1 will be wrong.

I can squash this into relevant patch (88c77dedfbb0).

But there is another patch [1] that cause conflict and seems fixing same
commit (88c77dedfbb0) again.

What do you think squashing all three into one?
I can share latest patch if you want.


[1] net/mlx5: fix creation of drop flows
http://dpdk.org/browse/next/dpdk-next-net/commit/?id=e0e37c1f80a00a2acbb581649b3125a5d465f2c6

> 
> Thanks,
>
  
Ferruh Yigit June 22, 2017, 11:11 a.m. UTC | #3
On 6/21/2017 12:55 PM, Shachar Beiser wrote:
> Missing room in flow allocation to store the drop specification.
> Changing flow without storing the change in rte_flow.
> Fixes: 88c77dedfbb0 ("net/mlx5: implement drop action in hardware classifier")
> 
> Signed-off-by: Shachar Beiser <shacharbe@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_flow.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 12893c6..cad3d16 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -580,6 +580,8 @@ struct mlx5_flow_action {
>  	}
>  	if (action->mark && !flow->ibv_attr && !action->drop)
>  		flow->offset += sizeof(struct ibv_exp_flow_spec_action_tag);
> +	if (!flow->ibv_attr && action->drop)
> +		flow->offset += sizeof(struct ibv_exp_flow_spec_action_drop);

Is using "struct ibv_exp_flow_spec_action_drop" here required
HAVE_VERBS_IBV_EXP_FLOW_SPEC_ACTION_DROP check?

>  	if (!action->queue && !action->drop) {
>  		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE,
>  				   NULL, "no valid action");
> @@ -1011,9 +1013,6 @@ struct mlx5_flow_action {
>  		return NULL;
>  	}
>  	rte_flow->drop = 1;
> -	rte_flow->ibv_attr = flow->ibv_attr;
> -	if (!priv->started)
> -		return rte_flow;
>  #ifdef HAVE_VERBS_IBV_EXP_FLOW_SPEC_ACTION_DROP
>  	drop = (void *)((uintptr_t)flow->ibv_attr + flow->offset);
>  	*drop = (struct ibv_exp_flow_spec_action_drop){
> @@ -1023,6 +1022,9 @@ struct mlx5_flow_action {
>  	++flow->ibv_attr->num_of_specs;
>  	flow->offset += sizeof(struct ibv_exp_flow_spec_action_drop);
>  #endif
> +	rte_flow->ibv_attr = flow->ibv_attr;
> +	if (!priv->started)
> +		return rte_flow;
>  	rte_flow->qp = priv->flow_drop_queue->qp;
>  	rte_flow->ibv_flow = ibv_exp_create_flow(rte_flow->qp,
>  						 rte_flow->ibv_attr);
>
  
Shachar Beiser June 25, 2017, 7:42 a.m. UTC | #4
Shachar Beiser (1):
  net/mlx5: fix drop action seg fault

 drivers/net/mlx5/mlx5_flow.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
  
Shachar Beiser June 25, 2017, 7:53 a.m. UTC | #5
Shachar Beiser (1):
  net/mlx5: fix drop action seg fault

 drivers/net/mlx5/mlx5_flow.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 12893c6..cad3d16 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -580,6 +580,8 @@  struct mlx5_flow_action {
 	}
 	if (action->mark && !flow->ibv_attr && !action->drop)
 		flow->offset += sizeof(struct ibv_exp_flow_spec_action_tag);
+	if (!flow->ibv_attr && action->drop)
+		flow->offset += sizeof(struct ibv_exp_flow_spec_action_drop);
 	if (!action->queue && !action->drop) {
 		rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE,
 				   NULL, "no valid action");
@@ -1011,9 +1013,6 @@  struct mlx5_flow_action {
 		return NULL;
 	}
 	rte_flow->drop = 1;
-	rte_flow->ibv_attr = flow->ibv_attr;
-	if (!priv->started)
-		return rte_flow;
 #ifdef HAVE_VERBS_IBV_EXP_FLOW_SPEC_ACTION_DROP
 	drop = (void *)((uintptr_t)flow->ibv_attr + flow->offset);
 	*drop = (struct ibv_exp_flow_spec_action_drop){
@@ -1023,6 +1022,9 @@  struct mlx5_flow_action {
 	++flow->ibv_attr->num_of_specs;
 	flow->offset += sizeof(struct ibv_exp_flow_spec_action_drop);
 #endif
+	rte_flow->ibv_attr = flow->ibv_attr;
+	if (!priv->started)
+		return rte_flow;
 	rte_flow->qp = priv->flow_drop_queue->qp;
 	rte_flow->ibv_flow = ibv_exp_create_flow(rte_flow->qp,
 						 rte_flow->ibv_attr);