[dpdk-stable] patch 'net/memif: fix chained mbuf determination' has been queued to stable release 20.11.4

Xueming Li xuemingl at nvidia.com
Wed Nov 10 07:29:21 CET 2021


Hi,

FYI, your patch has been queued to stable release 20.11.4

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/12/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/steevenlee/dpdk

This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/edfd68842c44515e006f83e1e4ee47f8260776b6

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From edfd68842c44515e006f83e1e4ee47f8260776b6 Mon Sep 17 00:00:00 2001
From: Junxiao Shi <git at mail1.yoursunny.com>
Date: Thu, 9 Sep 2021 14:42:06 +0000
Subject: [PATCH] net/memif: fix chained mbuf determination
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit 3e3f736e50fba910d1d484b9c763d884dff6688f ]

Previously, TX functions call rte_pktmbuf_is_contiguous to determine
whether an mbuf is chained. However, rte_pktmbuf_is_contiguous is
designed to work on the first mbuf of a packet only. In case a packet
contains three or more segment mbufs in a chain, it may cause truncated
packets or rte_mbuf_sanity_check panics.

This patch updates TX functions to determine chained mbufs using
mbuf_head->nb_segs field, which works in all cases. Moreover, it
maintains that the second cacheline is only accessed when chained mbuf
is actually present.

Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")
Fixes: 43b815d88188 ("net/memif: support zero-copy slave")

Signed-off-by: Junxiao Shi <git at mail1.yoursunny.com>
Reviewed-by: Jakub Grajciar <jgrajcia at cisco.com>
---
 drivers/net/memif/rte_eth_memif.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/memif/rte_eth_memif.c b/drivers/net/memif/rte_eth_memif.c
index 15284b3d2c..aded2ac134 100644
--- a/drivers/net/memif/rte_eth_memif.c
+++ b/drivers/net/memif/rte_eth_memif.c
@@ -199,6 +199,7 @@ memif_dev_info(struct rte_eth_dev *dev __rte_unused, struct rte_eth_dev_info *de
 	dev_info->max_rx_queues = ETH_MEMIF_MAX_NUM_Q_PAIRS;
 	dev_info->max_tx_queues = ETH_MEMIF_MAX_NUM_Q_PAIRS;
 	dev_info->min_rx_bufsize = 0;
+	dev_info->tx_offload_capa = DEV_TX_OFFLOAD_MULTI_SEGS;
 
 	return 0;
 }
@@ -566,7 +567,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 		rte_eth_devices[mq->in_port].process_private;
 	memif_ring_t *ring = memif_get_ring_from_queue(proc_private, mq);
 	uint16_t slot, saved_slot, n_free, ring_size, mask, n_tx_pkts = 0;
-	uint16_t src_len, src_off, dst_len, dst_off, cp_len;
+	uint16_t src_len, src_off, dst_len, dst_off, cp_len, nb_segs;
 	memif_ring_type_t type = mq->type;
 	memif_desc_t *d0;
 	struct rte_mbuf *mbuf;
@@ -614,6 +615,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	while (n_tx_pkts < nb_pkts && n_free) {
 		mbuf_head = *bufs++;
+		nb_segs = mbuf_head->nb_segs;
 		mbuf = mbuf_head;
 
 		saved_slot = slot;
@@ -657,7 +659,7 @@ next_in_chain:
 			d0->length = dst_off;
 		}
 
-		if (rte_pktmbuf_is_contiguous(mbuf) == 0) {
+		if (--nb_segs > 0) {
 			mbuf = mbuf->next;
 			goto next_in_chain;
 		}
@@ -694,6 +696,7 @@ memif_tx_one_zc(struct pmd_process_private *proc_private, struct memif_queue *mq
 		uint16_t slot, uint16_t n_free)
 {
 	memif_desc_t *d0;
+	uint16_t nb_segs = mbuf->nb_segs;
 	int used_slots = 1;
 
 next_in_chain:
@@ -714,7 +717,7 @@ next_in_chain:
 	d0->flags = 0;
 
 	/* check if buffer is chained */
-	if (rte_pktmbuf_is_contiguous(mbuf) == 0) {
+	if (--nb_segs > 0) {
 		if (n_free < 2)
 			return 0;
 		/* mark buffer as chained */
-- 
2.33.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-11-10 14:17:05.501718884 +0800
+++ 0077-net-memif-fix-chained-mbuf-determination.patch	2021-11-10 14:17:01.844079642 +0800
@@ -1 +1 @@
-From 3e3f736e50fba910d1d484b9c763d884dff6688f Mon Sep 17 00:00:00 2001
+From edfd68842c44515e006f83e1e4ee47f8260776b6 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 3e3f736e50fba910d1d484b9c763d884dff6688f ]
@@ -19 +21,0 @@
-Cc: stable at dpdk.org
@@ -28 +30 @@
-index de6becd45e..fd9e877c3d 100644
+index 15284b3d2c..aded2ac134 100644
@@ -39 +41 @@
-@@ -567,7 +568,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+@@ -566,7 +567,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
@@ -48 +50 @@
-@@ -615,6 +616,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+@@ -614,6 +615,7 @@ eth_memif_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
@@ -56 +58 @@
-@@ -659,7 +661,7 @@ next_in_chain:
+@@ -657,7 +659,7 @@ next_in_chain:
@@ -65 +67 @@
-@@ -696,6 +698,7 @@ memif_tx_one_zc(struct pmd_process_private *proc_private, struct memif_queue *mq
+@@ -694,6 +696,7 @@ memif_tx_one_zc(struct pmd_process_private *proc_private, struct memif_queue *mq
@@ -73 +75 @@
-@@ -716,7 +719,7 @@ next_in_chain:
+@@ -714,7 +717,7 @@ next_in_chain:


More information about the stable mailing list