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 5A496A0583; Thu, 19 Mar 2020 14:12:55 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BE3521C037; Thu, 19 Mar 2020 14:12:49 +0100 (CET) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id 729C61515; Thu, 19 Mar 2020 14:12:47 +0100 (CET) Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 283A4636B757C1019F9D; Thu, 19 Mar 2020 21:12:46 +0800 (CST) Received: from localhost (10.173.251.152) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Thu, 19 Mar 2020 21:12:37 +0800 From: wangyunjian To: CC: , , , Yunjian Wang , Date: Thu, 19 Mar 2020 21:11:20 +0800 Message-ID: <1584623480-19232-4-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1584623480-19232-1-git-send-email-wangyunjian@huawei.com> References: <1584623480-19232-1-git-send-email-wangyunjian@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.173.251.152] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 3/3] net/tap: fix check for mbuf's nb_segs failure 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 Now the rxq->pool is mbuf concatenation, But its nb_segs is 1. When do some sanity checks on the mbuf, it fails. Fixes: 0781f5762cfe ("net/tap: support segmented mbufs") CC: stable@dpdk.org Signed-off-by: Yunjian Wang --- drivers/net/tap/rte_eth_tap.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index a9ba0ca68..717d8b94c 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -339,6 +339,20 @@ tap_rx_offload_get_queue_capa(void) DEV_RX_OFFLOAD_TCP_CKSUM; } +static void +tap_rxq_pool_free(struct rte_mbuf *pool) +{ + struct rte_mbuf *mbuf = pool; + uint16_t nb_segs = 1; + + while (mbuf->next) { + mbuf = mbuf->next; + nb_segs++; + } + pool->nb_segs = nb_segs; + rte_pktmbuf_free(pool); +} + /* Callback to handle the rx burst of packets to the correct interface and * file descriptor(s) in a multi-queue setup. */ @@ -389,7 +403,7 @@ pmd_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) goto end; seg->next = NULL; - rte_pktmbuf_free(mbuf); + tap_rxq_pool_free(mbuf); goto end; } @@ -1033,7 +1047,7 @@ tap_dev_close(struct rte_eth_dev *dev) rxq = &internals->rxq[i]; close(process_private->rxq_fds[i]); process_private->rxq_fds[i] = -1; - rte_pktmbuf_free(rxq->pool); + tap_rxq_pool_free(rxq->pool); rte_free(rxq->iovecs); rxq->pool = NULL; rxq->iovecs = NULL; @@ -1072,7 +1086,7 @@ tap_rx_queue_release(void *queue) if (process_private->rxq_fds[rxq->queue_id] > 0) { close(process_private->rxq_fds[rxq->queue_id]); process_private->rxq_fds[rxq->queue_id] = -1; - rte_pktmbuf_free(rxq->pool); + tap_rxq_pool_free(rxq->pool); rte_free(rxq->iovecs); rxq->pool = NULL; rxq->iovecs = NULL; @@ -1480,7 +1494,7 @@ tap_rx_queue_setup(struct rte_eth_dev *dev, return 0; error: - rte_pktmbuf_free(rxq->pool); + tap_rxq_pool_free(rxq->pool); rxq->pool = NULL; rte_free(rxq->iovecs); rxq->iovecs = NULL; @@ -2435,7 +2449,7 @@ rte_pmd_tap_remove(struct rte_vdev_device *dev) rxq = &internals->rxq[i]; close(process_private->rxq_fds[i]); process_private->rxq_fds[i] = -1; - rte_pktmbuf_free(rxq->pool); + tap_rxq_pool_free(rxq->pool); rte_free(rxq->iovecs); rxq->pool = NULL; rxq->iovecs = NULL; -- 2.19.1