[V1,1/3] gso: fix refcnt update issue for external mbuf
diff mbox series

Message ID 20200730120900.108232-2-yang_y_yi@163.com
State New
Delegated to: Thomas Monjalon
Headers show
  • Fix external mbuf free issue in GSO case
Related show


Context Check Description
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

yang_y_yi July 30, 2020, 12:08 p.m. UTC
From: Yi Yang <yangyi01@inspur.com>

rte_gso_segment will segment original mbuf to multiple
small size mbufs, every mbuf of them has two segments,
the second segment will attach to original mbuf, if
original mbuf is external, rte_gso_segment should update
refcnt of mbuf->shinfo but not refcnt of mbuf. Otherwise,
original mbuf will be invalid on doing sanity check
because refcnt of mbuf is 0.

Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO")

Signed-off-by: Yi Yang <yangyi01@inspur.com>
 lib/librte_gso/rte_gso.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff mbox series

diff --git a/lib/librte_gso/rte_gso.c b/lib/librte_gso/rte_gso.c
index 751b5b6..b5e8b2a 100644
--- a/lib/librte_gso/rte_gso.c
+++ b/lib/librte_gso/rte_gso.c
@@ -83,7 +83,10 @@ 
 	if (ret > 1) {
 		pkt_seg = pkt;
 		while (pkt_seg) {
-			rte_mbuf_refcnt_update(pkt_seg, -1);
+			if (RTE_MBUF_HAS_EXTBUF(pkt_seg))
+				rte_mbuf_ext_refcnt_update(pkt_seg->shinfo, -1);
+			else
+				rte_mbuf_refcnt_update(pkt_seg, -1);
 			pkt_seg = pkt_seg->next;
 	} else if (ret < 0) {