From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E0AB0A0577; Tue, 7 Apr 2020 06:23:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BD79F1BF1B; Tue, 7 Apr 2020 06:23:06 +0200 (CEST) Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) by dpdk.org (Postfix) with ESMTP id 9409F1BF0B; Tue, 7 Apr 2020 06:23:04 +0200 (CEST) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 6CB7D7C2E7501DD3A038; Tue, 7 Apr 2020 12:23:03 +0800 (CST) Received: from localhost (10.173.251.152) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Tue, 7 Apr 2020 12:22:55 +0800 From: wangyunjian To: CC: , , , Yunjian Wang , Date: Tue, 7 Apr 2020 12:22:50 +0800 Message-ID: <1586233370-13856-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.173.251.152] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v3 2/5] net/tap: fix mbuf and mem leak during queue release X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Yunjian Wang 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 --- 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