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 v3 3/5] net/tap: fix check for mbuf's nb_segs failure
Date: Tue, 7 Apr 2020 12:23:03 +0800 [thread overview]
Message-ID: <1586233383-1084-1-git-send-email-wangyunjian@huawei.com> (raw)
From: Yunjian Wang <wangyunjian@huawei.com>
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 <wangyunjian@huawei.com>
---
drivers/net/tap/rte_eth_tap.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index a9ba0ca68..703fcceb9 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -339,6 +339,23 @@ 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;
+
+ if (mbuf == NULL)
+ return;
+
+ 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 +406,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 +1050,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 +1089,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 +1497,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 +2452,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
next reply other threads:[~2020-04-07 4:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-07 4:23 wangyunjian [this message]
2020-04-07 15:15 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
2020-04-07 15:38 ` Stephen Hemminger
2020-04-07 15:45 ` Ferruh Yigit
2020-04-07 15:49 ` Ferruh Yigit
2020-04-07 16:08 ` Stephen Hemminger
2020-04-08 1:10 ` wangyunjian
2020-04-07 15:58 ` Ferruh Yigit
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=1586233383-1084-1-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).