[dpdk-dev] [PATCH v3] gso: fix free issue of mbuf gso segments attach to

Thomas Monjalon thomas at monjalon.net
Thu Oct 29 22:39:20 CET 2020


I don't have a clear opinion on this patch.
Techboard members, ping for feedbacks.
If no objection, I will merge it soon, but I would prefer having more acks.


27/10/2020 20:55, Ananyev, Konstantin:
> From: yang_y_yi at 163.com <yang_y_yi at 163.com>
> > From: Yi Yang <yangyi01 at inspur.com>
> > 
> > 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.
> > 
> > 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 == 0" means 'pkt' isn't
> > GSOed but 'pkt' can be transimmitted 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.
> 
> Tech-board members: this is not a formal API breakage,
> but it is a functional change (i.e. all code that uses that API will need to be changed).
> There was no deprecation note in advance.
> So please provide your input: are you ok with such change or not.
> 
> I am ok with the proposed changes.
> Acked-by: Konstantin Ananyev <konstantin.ananyev at intel.com>

[...]
> >  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.
[...]
> >  #. Invoke the GSO segmentation API, ``rte_gso_segment()``.
> > 
> > +#. Call ``rte_pktmbuf_free()`` to free mbuf ``rte_gso_segment()`` segments.
[...]
> > --- a/doc/guides/rel_notes/release_20_11.rst
> > +++ b/doc/guides/rel_notes/release_20_11.rst
> > @@ -543,6 +543,13 @@ API Changes
> > +* **Changed ``rte_gso_segment`` in functional behavior and return value.**
> > +
> > +  * Don't save pkt to pkts_out[0] if it isn't GSOed in case of ret == 1.
> > +  * Return 0 instead of 1 for the above case.
> > +  * ``rte_gso_segment`` won't free pkt no matter whether it is GSOed, the
> > +    application has responsibility to free it after call ``rte_gso_segment``.
[...]
> > --- a/lib/librte_gso/rte_gso.h
> > +++ b/lib/librte_gso/rte_gso.h
> > - * 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 automatically.
> > + * 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 call rte_gso_segment().
> >   *
> >   * 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 needn't GSOed.
> >   *  - Return -ENOMEM if run out of memory in MBUF pools.
> >   *  - Return -EINVAL for invalid parameters.
> >   */





More information about the dev mailing list