DPDK patches and discussions
 help / color / mirror / Atom feed
From: wangyunjian <wangyunjian@huawei.com>
To: <dev@dpdk.org>
Cc: <keith.wiles@intel.com>, <jerry.lilijun@huawei.com>,
	<xudingke@huawei.com>, Yunjian Wang <wangyunjian@huawei.com>,
	<stable@dpdk.org>
Subject: [dpdk-dev] [PATCH 2/3] net/tap: fix mbuf and mem leak during queue release
Date: Thu, 19 Mar 2020 21:11:19 +0800	[thread overview]
Message-ID: <1584623480-19232-3-git-send-email-wangyunjian@huawei.com> (raw)
In-Reply-To: <1584623480-19232-1-git-send-email-wangyunjian@huawei.com>

From: Yunjian Wang <wangyunjian@huawei.com>

For the tap PMD, we should release mbufs and iovecs from the Rx queue
when close or remove device.

Fixes: 0781f5762cfe ("net/tap: support segmented mbufs")
CC: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/tap/rte_eth_tap.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 4c4b6b0b2..a9ba0ca68 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1022,6 +1022,7 @@ tap_dev_close(struct rte_eth_dev *dev)
 	int i;
 	struct pmd_internals *internals = dev->data->dev_private;
 	struct pmd_process_private *process_private = dev->process_private;
+	struct rx_queue *rxq;
 
 	tap_link_set_down(dev);
 	tap_flow_flush(dev, NULL);
@@ -1029,8 +1030,13 @@ tap_dev_close(struct rte_eth_dev *dev)
 
 	for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
 		if (process_private->rxq_fds[i] != -1) {
+			rxq = &internals->rxq[i];
 			close(process_private->rxq_fds[i]);
 			process_private->rxq_fds[i] = -1;
+			rte_pktmbuf_free(rxq->pool);
+			rte_free(rxq->iovecs);
+			rxq->pool = NULL;
+			rxq->iovecs = NULL;
 		}
 		if (process_private->txq_fds[i] != -1) {
 			close(process_private->txq_fds[i]);
@@ -2399,6 +2405,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
 	struct rte_eth_dev *eth_dev = NULL;
 	struct pmd_internals *internals;
 	struct pmd_process_private *process_private;
+	struct rx_queue *rxq;
 	int i;
 
 	/* find the ethdev entry */
@@ -2425,8 +2432,13 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev)
 	}
 	for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) {
 		if (process_private->rxq_fds[i] != -1) {
+			rxq = &internals->rxq[i];
 			close(process_private->rxq_fds[i]);
 			process_private->rxq_fds[i] = -1;
+			rte_pktmbuf_free(rxq->pool);
+			rte_free(rxq->iovecs);
+			rxq->pool = NULL;
+			rxq->iovecs = NULL;
 		}
 		if (process_private->txq_fds[i] != -1) {
 			close(process_private->txq_fds[i]);
-- 
2.19.1



  parent reply	other threads:[~2020-03-19 13:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19 13:11 [dpdk-dev] [PATCH 0/3] fixes for tap wangyunjian
2020-03-19 13:11 ` [dpdk-dev] [PATCH 1/3] net/tap: fix mbuf double free when write fails wangyunjian
2020-03-19 13:11 ` wangyunjian [this message]
2020-03-19 13:11 ` [dpdk-dev] [PATCH 3/3] net/tap: fix check for mbuf's nb_segs failure wangyunjian

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=1584623480-19232-3-git-send-email-wangyunjian@huawei.com \
    --to=wangyunjian@huawei.com \
    --cc=dev@dpdk.org \
    --cc=jerry.lilijun@huawei.com \
    --cc=keith.wiles@intel.com \
    --cc=stable@dpdk.org \
    --cc=xudingke@huawei.com \
    /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).