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 9B7A3A0527 for ; Mon, 9 Nov 2020 23:39:56 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5D46A5B3C; Mon, 9 Nov 2020 23:39:55 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id C9B6E5B3C for ; Mon, 9 Nov 2020 23:39:52 +0100 (CET) IronPort-SDR: b7QLqcJEhjvlX1pDAv8oSEAoTIKzds8NbE0vp4/l2Pmh1HaKIt7fqCZ+TQmMDqnZ7Hbxq7gMvY +cNZ7i5vRYSQ== X-IronPort-AV: E=McAfee;i="6000,8403,9800"; a="149162517" X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="149162517" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2020 14:39:50 -0800 IronPort-SDR: 4yJTJtbraZCodPZhJzQzF77rztUXqACE39T3LB9H2oikuUcU/froteqdXDC/4vkBLyTCWyMvkb JJ6DWeR/2Yvg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,464,1596524400"; d="scan'208";a="359854842" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga002.fm.intel.com with ESMTP; 09 Nov 2020 14:39:50 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 9 Nov 2020 14:39:50 -0800 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 9 Nov 2020 14:39:49 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 9 Nov 2020 14:39:49 -0800 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.170) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Mon, 9 Nov 2020 14:39:49 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WeC4TVy1KzUJ+JF27975r2CxmfmBG/mFg45LsqeZr7+APUVU2h7Ssh6Y7kcLZVpTQvLubvyN5LkUmwiOYBxfpgFjCYfS8/QpbW153l5BWLRVl0Id31XbB267ucMdKcyiDxqobwa5hYUAjnTCvb0DPQwpEChHh5THX70Y2maOlecl795iLx79oC1gkNxkmomGTxeCJ2ZvCTUHP7zkgyIoCR1vSWLebrqAx76UanP5hwG6zcv85VyfN+Y9fQMIusc3hwA39CaXvN28kfhiXS71qX9L0SEmdLY8VkcMRrHfOhPc//iZPW7RwUJ2RxoT0RGmhuxEmnhDjFyqpFxIz5UrJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i8twIQi17dLoslk/DNgriQimBaOTAdMzLZANSQzt8v4=; b=WD9oQWpbkJ9FXsE0l+WVa7hpzyqhuiruiYseMVhjRBT97Enp/iAyZjo8tvk+VfiprsqZnB5tmK6JQLA34AqkjpSncNNzEU67zw6s3V3iv8GM4o4NtoUBZZZnMLw1ok7OKO9mqKy782LvAuetDm9Qd9uktjep6KzpRlB0Gzju5cPQ5V/JGyexeyctaWaJdi7IIcLvg+Av44VQ/UGl8Bly1/2r7Q6zcz3DEGs9oEctX5jU03fXEPkZ3lbmq6UE+04E6iPdATz2NYVebCrRaXBrdZYVe56XdUdeaW+HJ9M2BYFAp3CDgzgmtLewqoUAGvnWusOnpDWaVM0nsaBlDTxmXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i8twIQi17dLoslk/DNgriQimBaOTAdMzLZANSQzt8v4=; b=Ty5btwM8uhWnWs3jdzDb+psHIWHW+eLKv0ZDgqT8Ngrn2N1AiJZhOCuzRlWafg9Q5Y51F4zeqq7Qwz8pXTN5Bg1UKV7fP0toYFKChNr8jQ4fPecjoQCMTE4c+SQtVP8WKxkN0jpHI0bhLEJ+gkuU8igng3/NEaeNlOWM3tGDetg= Received: from DM6PR11MB3308.namprd11.prod.outlook.com (2603:10b6:5:d::22) by DM6PR11MB2939.namprd11.prod.outlook.com (2603:10b6:5:70::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.21; Mon, 9 Nov 2020 22:39:47 +0000 Received: from DM6PR11MB3308.namprd11.prod.outlook.com ([fe80::fd2d:9bbb:599e:72dd]) by DM6PR11MB3308.namprd11.prod.outlook.com ([fe80::fd2d:9bbb:599e:72dd%6]) with mapi id 15.20.3541.021; Mon, 9 Nov 2020 22:39:47 +0000 From: "Ananyev, Konstantin" To: "luca.boccassi@gmail.com" , Yi Yang CC: "Hu, Jiayu" , dpdk stable Thread-Topic: patch 'gso: fix mbuf freeing responsibility' has been queued to stable release 19.11.6 Thread-Index: AQHWtsghCM/snvuB402xxCoW6XN0AqnAZFJg Date: Mon, 9 Nov 2020 22:39:47 +0000 Message-ID: References: <20201028104606.3504127-207-luca.boccassi@gmail.com> <20201109184111.3463090-1-luca.boccassi@gmail.com> <20201109184111.3463090-24-luca.boccassi@gmail.com> In-Reply-To: <20201109184111.3463090-24-luca.boccassi@gmail.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [46.7.39.127] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e43698b4-fcd6-42ce-2081-08d885005c8d x-ms-traffictypediagnostic: DM6PR11MB2939: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YXFtRay/TByInDNQKj9E22jdxDnny2KxXS9gT9SYwpro3jmRCRMrVymLxTxU/iz9moRDqAEMKHaMf+HpDFYK8kdkWS4PSELOCHkpF4BO7rt+0xdHvugkv5MOLDkM8X7Iy1ei4lAM/W1KqCkSkwZxA2tJzLCxtKBbq23BsiH2z7lX5klW00mfiAFj+hGMbpCKP+JdJqqV1ucfUDZHpaSrd3u9knoT8bE8Sfccw7zndprTti12GB3A8HxTy4lUVZNM1VZ94P7lGN6GGqmIEORQUyBWFPrcsXHDQvyFjJO7sP5KcMzh/2FlMpOo72mEkfabuvWQIY6dpceQNRjmHyiNJZLmpJar4dOs4x8m2+JrVsY3RuFeFpWFh2C+5+Y9nWjzbN+01vKClpDc75X5kd+p0A== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB3308.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(366004)(376002)(39860400002)(346002)(55016002)(66946007)(66446008)(52536014)(5660300002)(186003)(26005)(83380400001)(4326008)(966005)(86362001)(64756008)(66476007)(66556008)(8676002)(6506007)(53546011)(110136005)(2906002)(7696005)(33656002)(8936002)(76116006)(71200400001)(316002)(9686003)(478600001)(30864003)(54906003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: jLhOiEWG+jpGSEBLWstVS2FPLNSeq6DXFYFRNDhvtrWBBCBqpdHyHjmATH1v3C+nOYnp/Ly/eQjMs8EPLgVTYu/ISb3pQk7ONTn5HFhdB0cYpdVcULRw8Z7xq7J1Z5lr8MGWhb1l5+ooV0qwgEd9YfnrPmujqFRUOtW0CROEzKzzIdJmXNTGvSj87k80fxMRFc7JQmCpJVBYTiPbZg3+zcrEUXP/nlNg3n4IkjIk9SbZ8V408qTDog7GDT23U66TYjvgYzJFlf+graMFBkcXoqrWk8Ci13DaBLaBkJbooHrK+CLtIATbxVsSAnSZhTM8Gx3o59mJmuuX/U0AlWunRMhycjEhypIO3xjBiSs67V8b3zXFSaKS682cG9Gj9GNlR3rnseAJDUaLjrOzsbqbuYgbKRQZoovEsL0W5RkF9Ynk6xU0Ki5Cdbs740dF3D0a9LbXL4+6VBjfd6Hnijgut3lhUbZ9THU/3lxiulDmMrabsECACrLyUYhEiV19GFBogXg+p0t+qLUyKLeLeVYN3v91cJlO7GJpsRPrmYcmsK7ceF0O5xTLxy17i07pw2juPu9u6hhyeJlFgg9rDP0bFEZdWrcXxuR0e3socj3JgBO4sSIAdqyabZdxNnL+cbTp7leUSpxES+qmetgPiUKu1g== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB3308.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e43698b4-fcd6-42ce-2081-08d885005c8d X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Nov 2020 22:39:47.1102 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: j72LVTvDYbnM0/3jJqgzvzc11yMfDzjPqq45HD3PVjTjy98XtLlu1bvzi/Sorva8MdszxEA2P9n3ZEN460p5EEPevatE305/wvcxDW3TGBI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2939 X-OriginatorOrg: intel.com Subject: Re: [dpdk-stable] patch 'gso: fix mbuf freeing responsibility' has been queued to stable release 19.11.6 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi Luca, > Hi, >=20 > FYI, your patch has been queued to stable release 19.11.6 >=20 > 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/11/20. So please > shout if anyone has objections. Not sure it has to be backported to 19.11 LTS. Yes it fixes a problem, but it also introduces a functional change. AFAIK, we have to avoid it with LTS patches. Konstantin >=20 > Also note that after the patch there's a diff of the upstream commit vs t= he > 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 reba= sing > (ie: not only metadata diffs), please double check that the rebase was > correctly done. >=20 > Queued patches are on a temporary branch at: > https://github.com/bluca/dpdk-stable >=20 > This queued commit can be viewed at: > https://github.com/bluca/dpdk-stable/commit/6dce2ff12e8191ffd4d23e1ab9322= f2d042f6e5b >=20 > Thanks. >=20 > Luca Boccassi >=20 > --- > From 6dce2ff12e8191ffd4d23e1ab9322f2d042f6e5b Mon Sep 17 00:00:00 2001 > From: Yi Yang > Date: Mon, 26 Oct 2020 14:47:13 +0800 > Subject: [PATCH] gso: fix mbuf freeing responsibility >=20 > [ upstream commit c0d002aed98d6d1d38d6bb318a5bd2ed5cdc01b1 ] >=20 > 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. >=20 > One correct way is application should call > rte_pktmbuf_free after calling rte_gso_segment to free > pkt explicitly. rte_gso_segment must not handle it, this > should be responsibility of application. >=20 > This commit changed rte_gso_segment in functional behavior > and return value, so the application must take appropriate > actions according to return values, "ret < 0" means it > should free and drop 'pkt', "ret =3D=3D 0" means 'pkt' isn't > GSOed but 'pkt' can be transmitted as a normal packet, > "ret > 0" means 'pkt' has been GSOed into two or multiple > segments, it should use "pkts_out" to transmit these > segments. The application must free 'pkt' after call > rte_gso_segment when return value isn't equal to 0. >=20 > Fixes: 119583797b6a ("gso: support TCP/IPv4 GSO") >=20 > Signed-off-by: Yi Yang > Acked-by: Jiayu Hu > Acked-by: Konstantin Ananyev > --- > app/test-pmd/csumonly.c | 12 ++++++++++-- > .../generic_segmentation_offload_lib.rst | 7 +++++-- > drivers/net/tap/rte_eth_tap.c | 12 ++++++++++-- > lib/librte_gso/gso_tcp4.c | 6 ++---- > lib/librte_gso/gso_tunnel_tcp4.c | 14 +++++--------- > lib/librte_gso/gso_udp4.c | 6 ++---- > lib/librte_gso/rte_gso.c | 15 +++------------ > lib/librte_gso/rte_gso.h | 8 ++++++-- > 8 files changed, 43 insertions(+), 37 deletions(-) >=20 > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c > index 7b92ab1195..d0eef8b51c 100644 > --- a/app/test-pmd/csumonly.c > +++ b/app/test-pmd/csumonly.c > @@ -1050,9 +1050,17 @@ tunnel_update: > ret =3D rte_gso_segment(pkts_burst[i], gso_ctx, > &gso_segments[nb_segments], > GSO_MAX_PKT_BURST - nb_segments); > - if (ret >=3D 0) > + if (ret >=3D 1) { > + /* pkts_burst[i] can be freed safely here. */ > + rte_pktmbuf_free(pkts_burst[i]); > nb_segments +=3D ret; > - else { > + } else if (ret =3D=3D 0) { > + /* 0 means it can be transmitted directly > + * without gso. > + */ > + gso_segments[nb_segments] =3D pkts_burst[i]; > + nb_segments +=3D 1; > + } else { > TESTPMD_LOG(DEBUG, "Unable to segment packet"); > rte_pktmbuf_free(pkts_burst[i]); > } > diff --git a/doc/guides/prog_guide/generic_segmentation_offload_lib.rst b= /doc/guides/prog_guide/generic_segmentation_offload_lib.rst > index 205cb8a866..ad91c6e5fc 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 appl= ications to segment > packets in software. Note however, that GSO is implemented as a standalo= ne > library, and not via a 'fallback' mechanism (i.e. for when TSO is unsupp= orted > in the underlying hardware); that is, applications must explicitly invok= e 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 attached after calling ``rte_gso_segment()``. > +The size of GSO segments (``segsz``) is configurable by the application. >=20 > Limitations > ----------- > @@ -233,6 +234,8 @@ To segment an outgoing packet, an application must: >=20 > #. Invoke the GSO segmentation API, ``rte_gso_segment()``. >=20 > +#. Call ``rte_pktmbuf_free()`` to free mbuf ``rte_gso_segment()`` segmen= ts. > + > #. If required, update the L3 and L4 checksums of the newly-created segm= ents. > For tunneled packets, the outer IPv4 headers' checksums should also b= e > updated. Alternatively, the application may offload checksum calculat= ion > diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.= c > index cfbd579cd6..1e2f21d96f 100644 > --- a/drivers/net/tap/rte_eth_tap.c > +++ b/drivers/net/tap/rte_eth_tap.c > @@ -713,8 +713,16 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, ui= nt16_t nb_pkts) > if (num_tso_mbufs < 0) > break; >=20 > - mbuf =3D gso_mbufs; > - num_mbufs =3D num_tso_mbufs; > + if (num_tso_mbufs >=3D 1) { > + mbuf =3D gso_mbufs; > + num_mbufs =3D num_tso_mbufs; > + } else { > + /* 0 means it can be transmitted directly > + * without gso. > + */ > + mbuf =3D &mbuf_in; > + num_mbufs =3D 1; > + } > } else { > /* stats.errs will be incremented */ > if (rte_pktmbuf_pkt_len(mbuf_in) > max_size) > diff --git a/lib/librte_gso/gso_tcp4.c b/lib/librte_gso/gso_tcp4.c > index ade172ac73..d31feaff95 100644 > --- a/lib/librte_gso/gso_tcp4.c > +++ b/lib/librte_gso/gso_tcp4.c > @@ -50,15 +50,13 @@ gso_tcp4_segment(struct rte_mbuf *pkt, > pkt->l2_len); > frag_off =3D rte_be_to_cpu_16(ipv4_hdr->fragment_offset); > if (unlikely(IS_FRAGMENTED(frag_off))) { > - pkts_out[0] =3D pkt; > - return 1; > + return 0; > } >=20 > /* Don't process the packet without data */ > hdr_offset =3D pkt->l2_len + pkt->l3_len + pkt->l4_len; > if (unlikely(hdr_offset >=3D pkt->pkt_len)) { > - pkts_out[0] =3D pkt; > - return 1; > + return 0; > } >=20 > pyld_unit_size =3D gso_size - hdr_offset; > diff --git a/lib/librte_gso/gso_tunnel_tcp4.c b/lib/librte_gso/gso_tunnel= _tcp4.c > index e0384c26d0..166aace73a 100644 > --- a/lib/librte_gso/gso_tunnel_tcp4.c > +++ b/lib/librte_gso/gso_tunnel_tcp4.c > @@ -62,7 +62,7 @@ gso_tunnel_tcp4_segment(struct rte_mbuf *pkt, > { > struct rte_ipv4_hdr *inner_ipv4_hdr; > uint16_t pyld_unit_size, hdr_offset, frag_off; > - int ret =3D 1; > + int ret; >=20 > hdr_offset =3D pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len; > inner_ipv4_hdr =3D (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *= ) + > @@ -73,25 +73,21 @@ gso_tunnel_tcp4_segment(struct rte_mbuf *pkt, > */ > frag_off =3D rte_be_to_cpu_16(inner_ipv4_hdr->fragment_offset); > if (unlikely(IS_FRAGMENTED(frag_off))) { > - pkts_out[0] =3D pkt; > - return 1; > + return 0; > } >=20 > hdr_offset +=3D pkt->l3_len + pkt->l4_len; > /* Don't process the packet without data */ > if (hdr_offset >=3D pkt->pkt_len) { > - pkts_out[0] =3D pkt; > - return 1; > + return 0; > } > pyld_unit_size =3D gso_size - hdr_offset; >=20 > /* Segment the payload */ > ret =3D gso_do_segment(pkt, hdr_offset, pyld_unit_size, direct_pool, > indirect_pool, pkts_out, nb_pkts_out); > - if (ret <=3D 1) > - return ret; > - > - update_tunnel_ipv4_tcp_headers(pkt, ipid_delta, pkts_out, ret); > + if (ret > 1) > + update_tunnel_ipv4_tcp_headers(pkt, ipid_delta, pkts_out, ret); >=20 > return ret; > } > diff --git a/lib/librte_gso/gso_udp4.c b/lib/librte_gso/gso_udp4.c > index 6fa68f243a..5d0186aa24 100644 > --- a/lib/librte_gso/gso_udp4.c > +++ b/lib/librte_gso/gso_udp4.c > @@ -52,8 +52,7 @@ gso_udp4_segment(struct rte_mbuf *pkt, > pkt->l2_len); > frag_off =3D rte_be_to_cpu_16(ipv4_hdr->fragment_offset); > if (unlikely(IS_FRAGMENTED(frag_off))) { > - pkts_out[0] =3D pkt; > - return 1; > + return 0; > } >=20 > /* > @@ -65,8 +64,7 @@ gso_udp4_segment(struct rte_mbuf *pkt, >=20 > /* Don't process the packet without data. */ > if (unlikely(hdr_offset + pkt->l4_len >=3D pkt->pkt_len)) { > - pkts_out[0] =3D pkt; > - return 1; > + return 0; > } >=20 > /* pyld_unit_size must be a multiple of 8 because frag_off > diff --git a/lib/librte_gso/rte_gso.c b/lib/librte_gso/rte_gso.c > index 751b5b625e..896350ebc8 100644 > --- a/lib/librte_gso/rte_gso.c > +++ b/lib/librte_gso/rte_gso.c > @@ -30,7 +30,6 @@ rte_gso_segment(struct rte_mbuf *pkt, > 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; > @@ -44,8 +43,7 @@ rte_gso_segment(struct rte_mbuf *pkt, >=20 > if (gso_ctx->gso_size >=3D pkt->pkt_len) { > pkt->ol_flags &=3D (~(PKT_TX_TCP_SEG | PKT_TX_UDP_SEG)); > - pkts_out[0] =3D pkt; > - return 1; > + return 0; > } >=20 > direct_pool =3D gso_ctx->direct_pool; > @@ -75,18 +73,11 @@ rte_gso_segment(struct rte_mbuf *pkt, > indirect_pool, pkts_out, nb_pkts_out); > } else { > /* unsupported packet, skip */ > - pkts_out[0] =3D pkt; > RTE_LOG(DEBUG, GSO, "Unsupported packet type\n"); > - return 1; > + ret =3D 0; > } >=20 > - if (ret > 1) { > - pkt_seg =3D pkt; > - while (pkt_seg) { > - rte_mbuf_refcnt_update(pkt_seg, -1); > - pkt_seg =3D pkt_seg->next; > - } > - } else if (ret < 0) { > + if (ret < 0) { > /* Revert the ol_flags in the event of failure. */ > pkt->ol_flags =3D ol_flags; > } > diff --git a/lib/librte_gso/rte_gso.h b/lib/librte_gso/rte_gso.h > index 3aab297f44..d93ee8e5b1 100644 > --- a/lib/librte_gso/rte_gso.h > +++ b/lib/librte_gso/rte_gso.h > @@ -89,8 +89,11 @@ struct rte_gso_ctx { > * the GSO segments are sent to should support transmission of multi-seg= ment > * packets. > * > - * If the input packet is GSO'd, its mbuf refcnt reduces by 1. Therefore= , > - * when all GSO segments are freed, the input packet is freed automatica= lly. > + * If the input packet is GSO'd, all the indirect segments are attached = to the > + * input packet. > + * > + * rte_gso_segment() will not free the input packet no matter whether it= is > + * GSO'd or not, the application should free it after calling rte_gso_se= gment(). > * > * If the memory space in pkts_out or MBUF pools is insufficient, this > * function fails, and it returns (-1) * errno. Otherwise, GSO succeeds, > @@ -109,6 +112,7 @@ struct rte_gso_ctx { > * > * @return > * - The number of GSO segments filled in pkts_out on success. > + * - Return 0 if it does not need to be GSO'd. > * - Return -ENOMEM if run out of memory in MBUF pools. > * - Return -EINVAL for invalid parameters. > */ > -- > 2.27.0 >=20 > --- > Diff of the applied patch vs upstream commit (please double-check if no= n-empty: > --- > --- - 2020-11-09 18:40:12.168193728 +0000 > +++ 0024-gso-fix-mbuf-freeing-responsibility.patch 2020-11-09 18:40:11.10= 3310846 +0000 > @@ -1 +1 @@ > -From c0d002aed98d6d1d38d6bb318a5bd2ed5cdc01b1 Mon Sep 17 00:00:00 2001 > +From 6dce2ff12e8191ffd4d23e1ab9322f2d042f6e5b Mon Sep 17 00:00:00 2001 > @@ -5,0 +6,2 @@ > +[ upstream commit c0d002aed98d6d1d38d6bb318a5bd2ed5cdc01b1 ] > + > @@ -28 +29,0 @@ > -Cc: stable@dpdk.org > @@ -36 +36,0 @@ > - doc/guides/rel_notes/release_20_11.rst | 6 ++++++ > @@ -43 +43 @@ > - 9 files changed, 49 insertions(+), 37 deletions(-) > + 8 files changed, 43 insertions(+), 37 deletions(-) > @@ -46 +46 @@ > -index 3d7d244d1e..d813d4fae0 100644 > +index 7b92ab1195..d0eef8b51c 100644 > @@ -49 +49 @@ > -@@ -1080,9 +1080,17 @@ tunnel_update: > +@@ -1050,9 +1050,17 @@ tunnel_update: > @@ -94,17 +93,0 @@ > -diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_not= es/release_20_11.rst > -index 7c8246d1b3..1524f61915 100644 > ---- a/doc/guides/rel_notes/release_20_11.rst > -+++ b/doc/guides/rel_notes/release_20_11.rst > -@@ -569,6 +569,12 @@ API Changes > - > - * bpf: ``RTE_BPF_XTYPE_NUM`` has been dropped from ``rte_bpf_xtype``. > - > -+* gso: Changed ``rte_gso_segment`` behaviour and return value: > -+ > -+ * ``pkt`` is not saved to ``pkts_out[0]`` if not GSOed. > -+ * Return 0 instead of 1 for the above case. > -+ * ``pkt`` is not freed, no matter whether it is GSOed, leaving to the= caller. > -+ > - * acl: ``RTE_ACL_CLASSIFY_NUM`` enum value has been removed. > - This enum value was not used inside DPDK, while it prevented to add n= ew > - classify algorithms without causing an ABI breakage. > @@ -112 +95 @@ > -index 81c688471d..2f8abb12c5 100644 > +index cfbd579cd6..1e2f21d96f 100644 > @@ -115 +98 @@ > -@@ -751,8 +751,16 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, u= int16_t nb_pkts) > +@@ -713,8 +713,16 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, u= int16_t nb_pkts)