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 07C61A04BC; Sat, 10 Oct 2020 05:10:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9DCE81D666; Sat, 10 Oct 2020 05:10:49 +0200 (CEST) Received: from mail-m974.mail.163.com (mail-m974.mail.163.com [123.126.97.4]) by dpdk.org (Postfix) with ESMTP id 659701D63E for ; Sat, 10 Oct 2020 05:10:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=a4AMX 9wCEaexrENh1FVkn0/dfWovclstI7rtZnpyDb0=; b=MOFN0nKt0tU/sm5P0CZkg ZGaaoMrMSVNqtI68q+5JJ1+35USyCnqLPhdTc66hHFJm4yBUdasRR0LR/vurujiM z0hmOKESJjTW8ixdCfaiqeVoy7VXXaAswL4yUsURGVt2IsjM9i7xEUcLuH566uxG QrIqSMgdLz53WwwH7X/Plk= Received: from yangyi0100.home.langchao.com (unknown [111.207.123.58]) by smtp4 (Coremail) with SMTP id HNxpCgDniRwcJoFfR5F8TQ--.9694S2; Sat, 10 Oct 2020 11:10:22 +0800 (CST) From: yang_y_yi@163.com To: dev@dpdk.org Cc: jiayu.hu@intel.com, mark.b.kavanagh@intel.com, konstantin.ananyev@intel.com, olivier.matz@6wind.com, thomas@monjalon.net, yangyi01@inspur.com, yang_y_yi@163.com Date: Sat, 10 Oct 2020 11:10:20 +0800 Message-Id: <20201010031020.349516-1-yang_y_yi@163.com> X-Mailer: git-send-email 2.19.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HNxpCgDniRwcJoFfR5F8TQ--.9694S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxuF1Dtr4xCFWDuF18Zr13Arb_yoW5Ww48pr ZxKw4xtrn3Jr1xAFWvva15Xwn3CFZ5G3y3JrWkG34kArn3GayIqayDK3W5AFyfJrW5Aa1f Wr4qqayUAa15C3JanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UFsjbUUUUU= X-Originating-IP: [111.207.123.58] X-CM-SenderInfo: 51dqwsp1b1xqqrwthudrp/xtbBEh65i16iZbssxQAAs1 Subject: [dpdk-dev] [PATCH] gso: fix free issue of mbuf gso segments attach to 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: Yi Yang rte_gso_segment decreased refcnt of pkt by one, but it is wrong if pkt is external mbuf, pkt won't be freed because of incorrect refcnt, the result is application can't allocate mbuf from mempool because mbufs in mempool are run out of. One correct way is application should call rte_pktmbuf_free after calling rte_gso_segment to free pkt explicitly. rte_gso_segment mustn't handle it, this should be responsibility of application. Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO") Signed-off-by: Yi Yang --- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++-- lib/librte_gso/rte_gso.c | 9 +-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/doc/guides/prog_guide/generic_segmentation_offload_lib.rst b/doc/guides/prog_guide/generic_segmentation_offload_lib.rst index 205cb8a..8577572 100644 --- a/doc/guides/prog_guide/generic_segmentation_offload_lib.rst +++ b/doc/guides/prog_guide/generic_segmentation_offload_lib.rst @@ -25,8 +25,9 @@ Bearing that in mind, the GSO library enables DPDK applications to segment packets in software. Note however, that GSO is implemented as a standalone library, and not via a 'fallback' mechanism (i.e. for when TSO is unsupported in the underlying hardware); that is, applications must explicitly invoke the -GSO library to segment packets. The size of GSO segments ``(segsz)`` is -configurable by the application. +GSO library to segment packets, they also must call ``rte_pktmbuf_free()`` to +free mbuf GSO segments attach to after calling ``rte_gso_segment()``. The size +of GSO segments ``(segsz)`` is configurable by the application. Limitations ----------- @@ -233,6 +234,8 @@ To segment an outgoing packet, an application must: #. Invoke the GSO segmentation API, ``rte_gso_segment()``. +#. Call ``rte_pktmbuf_free()`` to free mbuf ``rte_gso_segment()`` segments. + #. If required, update the L3 and L4 checksums of the newly-created segments. For tunneled packets, the outer IPv4 headers' checksums should also be updated. Alternatively, the application may offload checksum calculation diff --git a/lib/librte_gso/rte_gso.c b/lib/librte_gso/rte_gso.c index 751b5b6..0d6cae5 100644 --- a/lib/librte_gso/rte_gso.c +++ b/lib/librte_gso/rte_gso.c @@ -30,7 +30,6 @@ uint16_t nb_pkts_out) { struct rte_mempool *direct_pool, *indirect_pool; - struct rte_mbuf *pkt_seg; uint64_t ol_flags; uint16_t gso_size; uint8_t ipid_delta; @@ -80,13 +79,7 @@ return 1; } - if (ret > 1) { - pkt_seg = pkt; - while (pkt_seg) { - rte_mbuf_refcnt_update(pkt_seg, -1); - pkt_seg = pkt_seg->next; - } - } else if (ret < 0) { + if (ret < 0) { /* Revert the ol_flags in the event of failure. */ pkt->ol_flags = ol_flags; } -- 1.8.3.1