DPDK patches and discussions
 help / color / mirror / Atom feed
From: Moti Haimovsky <motih@mellanox.com>
To: adrien.mazarguil@6wind.com
Cc: dev@dpdk.org, Moti Haimovsky <motih@mellanox.com>, stable@dpdk.org
Subject: [dpdk-dev] [PATCH] net/mlx4: fix drop flow resources not freed
Date: Tue, 30 Jan 2018 17:54:00 +0200	[thread overview]
Message-ID: <1517327640-182072-1-git-send-email-motih@mellanox.com> (raw)

This patch fixes the drop-flow resources not being freed when the device
is closed.
Issue can be observed when running testpmd and adding the following rule
more than once:
"flow create 0 ingress pattern eth / end actions drop / end"
then either exiting testpmd using the "quit" command or by running the
command: "port stop all"

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

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
 drivers/net/mlx4/mlx4_flow.c | 33 +++++++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
index fb84060..9e6d8dc 100644
--- a/drivers/net/mlx4/mlx4_flow.c
+++ b/drivers/net/mlx4/mlx4_flow.c
@@ -895,6 +895,30 @@ struct mlx4_drop {
 }
 
 /**
+ * Return the number of active drop flow rules currently present
+ * in the list of flows.
+ * Active flow is defined as a flow associated with an ibv_flow.
+ *
+ * @param priv
+ *   Pointer to private structure.
+ *
+ * @return
+ *   Number of active drop-flows.
+ */
+static int
+drop_refcnt(struct priv *priv)
+{
+	struct rte_flow *flow;
+	int count = 0;
+
+	LIST_FOREACH(flow, &priv->flows, next) {
+		if (flow->drop && flow->ibv_flow)
+			count++;
+	}
+	return count;
+}
+
+/**
  * Get a drop flow rule resources instance.
  *
  * @param priv
@@ -910,9 +934,8 @@ struct mlx4_drop {
 	struct mlx4_drop *drop = priv->drop;
 
 	if (drop) {
-		assert(drop->refcnt);
+		assert(drop_refcnt(priv));
 		assert(drop->priv == priv);
-		++drop->refcnt;
 		return drop;
 	}
 	drop = rte_malloc(__func__, sizeof(*drop), 0);
@@ -955,8 +978,10 @@ struct mlx4_drop {
 static void
 mlx4_drop_put(struct mlx4_drop *drop)
 {
-	assert(drop->refcnt);
-	if (--drop->refcnt)
+	int refcnt = drop_refcnt(drop->priv);
+
+	assert(refcnt >= 0);
+	if (refcnt)
 		return;
 	drop->priv->drop = NULL;
 	claim_zero(ibv_destroy_qp(drop->qp));
-- 
1.8.3.1

             reply	other threads:[~2018-01-30 15:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-30 15:54 Moti Haimovsky [this message]
2018-01-30 16:41 ` Adrien Mazarguil
2018-01-30 17:24   ` Adrien Mazarguil
2018-01-31 15:33 ` [dpdk-dev] [PATCH v2] " Adrien Mazarguil
2018-02-01  8:40   ` Shahaf Shuler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517327640-182072-1-git-send-email-motih@mellanox.com \
    --to=motih@mellanox.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).