[dpdk-dev,v2] net/mlx4: fix drop flow resources not freed

Message ID 20180131153141.1289-1-adrien.mazarguil@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Adrien Mazarguil Jan. 31, 2018, 3:33 p.m. UTC
  Resources allocated for drop flow rules are not freed properly. This causes
a memory leak and triggers an assertion failure on a reference counter when
compiled in debug mode.

This issue can be reproduced with testpmd by entering the following
commands:

 flow create 0 ingress pattern eth / end actions drop / end
 port start all
 port stop all
 port start all
 port stop all
 quit

The reason is additional references are taken when re-enabling existing
flow rules, a common occurrence when rehashing configuration.

Fixes: d3a7e09234e4 ("net/mlx4: allocate drop flow resources on demand")
Cc: stable@dpdk.org

Reported-by: Moti Haimovsky <motih@mellanox.com>
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/mlx4/mlx4_flow.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Shahaf Shuler Feb. 1, 2018, 8:40 a.m. UTC | #1
Wednesday, January 31, 2018 5:33 PM, Adrien Mazarguil:
> Resources allocated for drop flow rules are not freed properly. This causes a
> memory leak and triggers an assertion failure on a reference counter when
> compiled in debug mode.
> 
> This issue can be reproduced with testpmd by entering the following
> commands:
> 
>  flow create 0 ingress pattern eth / end actions drop / end  port start all  port
> stop all  port start all  port stop all  quit
> 
> The reason is additional references are taken when re-enabling existing flow
> rules, a common occurrence when rehashing configuration.
> 
> Fixes: d3a7e09234e4 ("net/mlx4: allocate drop flow resources on demand")
> Cc: stable@dpdk.org
> 
> Reported-by: Moti Haimovsky <motih@mellanox.com>
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> ---

Applied to next-net-mlx, thanks.
  

Patch

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index 8b6f8a01d..3a195b17a 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -1058,6 +1058,8 @@  mlx4_flow_toggle(struct priv *priv,
 		flow->drop = missing;
 	}
 	if (flow->drop) {
+		if (flow->ibv_flow)
+			return 0;
 		mlx4_drop_get(priv);
 		if (!priv->drop) {
 			err = rte_errno;