gso: fix free issue of mbuf gso segments attach to
PATCH v2 1/1 gso: fix free issue of mbuf gso segments attach to
From: Yi Yang <[email protected]>
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.
---
Changelog:
v1->v2:
- update description of rte_gso_segment().
- change code which calls rte_gso_segment() to fix free issue.
--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++-- lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)
app/test-pmd/csumonly.c +2 -1
@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);if (ret >=0 ) nb_segments += ret;else {TESTPMD_LOG (DEBUG ,"Unable to segment packet" ); -rte_pktmbuf_free (pkts_burst[i]); } }
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +5 -2
@@ -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
lib/librte_gso/rte_gso.c +1 -8
@@ -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; }
lib/librte_gso/rte_gso.h +5 -2
@@ -89,8 +89,11 @@ struct rte_gso_ctx {* the GSO segments are sent to should support transmission of multi-segment * 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 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,
Signature · 1 line
1.8.3.1
Quoted 8 lines
rte_gso_segmentdecreased 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.
Quoted 4 lines
One correct way is application should call
rte_pktmbuf_freeafter callingrte_gso_segmentto free pkt explicitly.rte_gso_segmentmustn't handle it, this should be responsibility of application.
Probably needs to be stated clearly:
It is a change in functional behaviour. Without deprecation note in advance.
TB members: please provide your opinion on that patch.
Quoted 6 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")Signed-off-by Yi Yang <[email protected]>---
Changelog:
Quoted 8 lines
v1->v2:
- update description ofrte_gso_segment().
- change code which callsrte_gso_segment()to fix free issue.--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++--
I think release notes also have to be updated.
Quoted 9 lines
lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)app/test-pmd/csumonly.c +0
-0
app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1084
Quoted 5 lines
app/test-pmd/csumonly.c +2
-0@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);
It doesn't look correct to me.
I think it should be:
If (ret > 1) rte_pktmbuf_free(pkts_burst[i]);
app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1090
Quoted 7 lines
app/test-pmd/csumonly.c +0
-1if (ret >=0 ) nb_segments += ret;else {TESTPMD_LOG (DEBUG ,"Unable to segment packet" ); -rte_pktmbuf_free (pkts_burst[i]); } }
About drivers/net/tap/rte_eth_tap.c:
I think it has to be modified too, as here:
/* free original mbuf */
rte_pktmbuf_free(mbuf_in);
/* free tso mbufs */
if (num_tso_mbufs > 0)
rte_pktmbuf_free_bulk(mbuf, num_tso_mbufs);if mbuf[0] == mbuf_in
Will have a double free() for the same mbuf.
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK applications to segment · line 29
Quoted 13 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +2
-2@@ -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()``.
Probably worth to mention that if return code == 1, then
output mbuf will point to input mbuf and extra care with free() is required.
Quoted 61 lines
The size
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +3
-0+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 calculationlib/librte_gso/rte_gso.c +1
-8@@ -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; }lib/librte_gso/rte_gso.h +5
-3@@ -89,8 +89,11 @@ struct rte_gso_ctx {* the GSO segments are sent to should support transmission of multi-segment * 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 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, -- 1.8.3.1
Quoted 78 lines
Quoted 8 lines
rte_gso_segmentdecreased 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.Quoted 4 lines
One correct way is application should call
rte_pktmbuf_freeafter callingrte_gso_segmentto free pkt explicitly.rte_gso_segmentmustn't handle it, this should be responsibility of application.Probably needs to be stated clearly:
It is a change in functional behaviour. Without deprecation note in advance.
TB members: please provide your opinion on that patch.Quoted 6 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")Signed-off-by Yi Yang <[email protected]>---
Changelog:Quoted 8 lines
v1->v2:
- update description ofrte_gso_segment().
- change code which callsrte_gso_segment()to fix free issue.--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++--I think release notes also have to be updated.
Quoted 9 lines
lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)app/test-pmd/csumonly.c +0
-0app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1084
Quoted 5 lines
app/test-pmd/csumonly.c +2
-0@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);It doesn't look correct to me.
I think it should be:
If (ret > 1)rte_pktmbuf_free(pkts_burst[i]);app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1090
Quoted 7 lines
app/test-pmd/csumonly.c +0
-1if (ret >=0 ) nb_segments += ret;else {TESTPMD_LOG (DEBUG ,"Unable to segment packet" ); -rte_pktmbuf_free (pkts_burst[i]); } }About
drivers/net/tap/rte_eth_tap.c:
I think it has to be modified too, as here:/* free original mbuf */
rte_pktmbuf_free(mbuf_in); /* free tso mbufs */ if (num_tso_mbufs > 0) rte_pktmbuf_free_bulk(mbuf, num_tso_mbufs);if mbuf[0] ==
mbuf_in
Will have a doublefree()for the same mbuf.Review
Quoted 2 lines
(quoted diff) +0
-0
b/doc/guides/prog_guide/generic_segmentation_offload_lib.rst
Quoted 14 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK applications to segment · line 29
Quoted 11 lines
index 205cb8a..8577572 100644
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +2
-2@@ -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()``.Probably worth to mention that if return code == 1, then
output mbuf will point to input mbuf and extra care withfree()is required.
Another possibility - change gso_segment() behaviour even further, and don't put input_pkt into pkt_out[] when no segmentation happened. Might be even a bit cleaner and less error prone.
Quoted 62 lines
Quoted 62 lines
The size
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +3
-0+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 calculationlib/librte_gso/rte_gso.c +1
-8@@ -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; }lib/librte_gso/rte_gso.h +5
-3@@ -89,8 +89,11 @@ struct rte_gso_ctx {* the GSO segments are sent to should support transmission of multi-segment * 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 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, -- 1.8.3.1
Quoted 104 lines
-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Thursday, October 22, 2020 11:34 PM
To: [email protected]; [email protected]
Cc: Hu, Jiayu <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v2] gso: fix free issue of mbuf gso segments attach toQuoted 12 lines
Quoted 11 lines
rte_gso_segmentdecreased 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_freeafter callingrte_gso_segmentto free pkt explicitly.rte_gso_segmentmustn't handle it, this should be responsibility of application.Quoted 19 lines
Probably needs to be stated clearly:
It is a change in functional behaviour. Without deprecation note in advance.
TB members: please provide your opinion on that patch.Quoted 14 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")Signed-off-by Yi Yang <[email protected]>---
Changelog:
v1->v2:
- update description ofrte_gso_segment().
- change code which callsrte_gso_segment()to fix free issue.--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++--
Quoted 44 lines
I think release notes also have to be updated.
Quoted 9 lines
lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)app/test-pmd/csumonly.c +0
-0app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1084
Quoted 5 lines
app/test-pmd/csumonly.c +2
-0@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);It doesn't look correct to me.
I think it should be:
If (ret > 1)rte_pktmbuf_free(pkts_burst[i]);app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1090
Quoted 7 lines
app/test-pmd/csumonly.c +0
-1if (ret >=0 ) nb_segments += ret;else {TESTPMD_LOG (DEBUG ,"Unable to segment packet" ); -rte_pktmbuf_free (pkts_burst[i]); } }About
drivers/net/tap/rte_eth_tap.c:
I think it has to be modified too, as here:/* free original mbuf */
rte_pktmbuf_free(mbuf_in); /* free tso mbufs */ if (num_tso_mbufs > 0) rte_pktmbuf_free_bulk(mbuf, num_tso_mbufs);if mbuf[0] ==
mbuf_in
Will have a doublefree()for the same mbuf.Quoted 1 line
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/doc/guides/prog_guide/generic_segmentation_offload_lib.rstdoc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK
Quoted 4 lines
index 205cb8a..8577572 100644
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0@@ -25,8 +25,9 @@ Bearing that in mind, the GSO library enables DPDKapplications to segment
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK · line 25
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0packets in software. Note however, that GSO is implemented as astandalone
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK · line 26
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0library, and not via a 'fallback' mechanism (i.e. for when TSO isunsupported
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK · line 27
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0in the underlying hardware); that is, applications must explicitly invokethe
Quoted 3 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK applications to segment
Quoted 3 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +1
-2-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
Quoted 8 lines
Quoted 4 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK · line 29
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +1
-0+free mbuf GSO segments attach to after calling ``rte_gso_segment()``.Probably worth to mention that if return code == 1, then
output mbuf will point to input mbuf and extra care withfree()is required.Another possibility - change
gso_segment()behaviour even further, and don't putinput_pktinto pkt_out[] when no segmentation happened. Might be even a bit cleaner and less error prone.
Agree. Pkts_out[] better not to contain input_pkt when GSO doesn't happen.
BTW, @Yi, you also need to update the comment of describing what rte_gso_segment() returns in rte_gso.h.
Thanks,
Jiayu
Quoted 74 lines
Quoted 8 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst To segment an outgoing packet, an application
Quoted 8 lines
The size
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +1
-0+of GSO segments ``(segsz)`` is configurable by the application. Limitations -----------@@ -233,6 +234,8 @@ To segment an outgoing packet, an applicationmust:
Quoted 4 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst To segment an outgoing packet, an application must:
Quoted 4 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +1
-0#. Invoke the GSO segmentation API, ``rte_gso_segment()``. +#. Call ``rte_pktmbuf_free()`` to free mbuf ``rte_gso_segment()``segments.
Quoted 2 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst To segment an outgoing packet, an application · line 238
Quoted 2 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +1
-0+ #. If required, update the L3 and L4 checksums of the newly-createdsegments.
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst To segment an outgoing packet, an application · line 239
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0For tunneled packets, the outer IPv4 headers' checksums should alsobe
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst To segment an outgoing packet, an application · line 240
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0updated. Alternatively, the application may offload checksumcalculation
Quoted 25 lines
Quoted 25 lines
lib/librte_gso/rte_gso.c +1
-8@@ -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. */ Quoted 8 lines
lib/librte_gso/rte_gso.h struct rte_gso_ctx { · line 89
Quoted 8 lines
lib/librte_gso/rte_gso.c +0
-0pkt->ol_flags = ol_flags; }lib/librte_gso/rte_gso.h +0
-0@@ -89,8 +89,11 @@ struct rte_gso_ctx {* the GSO segments are sent to should support transmission of multi- segment
Quoted 4 lines
lib/librte_gso/rte_gso.h struct rte_gso_ctx {
Quoted 4 lines
lib/librte_gso/rte_gso.h +0
-2* 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 automatically.
Quoted 1 line
lib/librte_gso/rte_gso.h struct rte_gso_ctx { · line 92
Quoted 1 line
lib/librte_gso/rte_gso.h +1
-0+* If the input packet is GSO'd, all the indirect segments are attached to the
Quoted 3 lines
lib/librte_gso/rte_gso.h struct rte_gso_ctx {
Quoted 3 lines
lib/librte_gso/rte_gso.h +3
-0+* input packet. +* +* rte_gso_segment() will not free the input packet no matter whether it is
Quoted 1 line
lib/librte_gso/rte_gso.h struct rte_gso_ctx { · line 96
Quoted 1 line
lib/librte_gso/rte_gso.h +1
-0+* GSO'd or not, the application should free it after call
rte_gso_segment().Quoted 5 lines
Quoted 5 lines
lib/librte_gso/rte_gso.h +0
-1* * If the memory space in pkts_out or MBUF pools is insufficient, this * function fails, and it returns (-1) * errno. Otherwise, GSO succeeds, -- 1.8.3.1
Quoted 113 lines · Jiayu
Quoted 104 lines
-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Thursday, October 22, 2020 11:34 PM
To: [email protected]; [email protected]
Cc: Hu, Jiayu <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH v2] gso: fix free issue of mbuf gso segments attach toQuoted 12 lines
Quoted 11 lines
rte_gso_segmentdecreased 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_freeafter callingrte_gso_segmentto free pkt explicitly.rte_gso_segmentmustn't handle it, this should be responsibility of application.Quoted 19 lines
Probably needs to be stated clearly:
It is a change in functional behaviour. Without deprecation note in advance.
TB members: please provide your opinion on that patch.Quoted 14 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")Signed-off-by Yi Yang <[email protected]>---
Changelog:
v1->v2:
- update description ofrte_gso_segment().
- change code which callsrte_gso_segment()to fix free issue.--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++--
Quoted 44 lines
I think release notes also have to be updated.
Quoted 9 lines
lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)app/test-pmd/csumonly.c +0
-0app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1084
Quoted 5 lines
app/test-pmd/csumonly.c +2
-0@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);It doesn't look correct to me.
I think it should be:
If (ret > 1)rte_pktmbuf_free(pkts_burst[i]);app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1090
Quoted 7 lines
app/test-pmd/csumonly.c +0
-1if (ret >=0 ) nb_segments += ret;else {TESTPMD_LOG (DEBUG ,"Unable to segment packet" ); -rte_pktmbuf_free (pkts_burst[i]); } }About
drivers/net/tap/rte_eth_tap.c:
I think it has to be modified too, as here:/* free original mbuf */
rte_pktmbuf_free(mbuf_in); /* free tso mbufs */ if (num_tso_mbufs > 0) rte_pktmbuf_free_bulk(mbuf, num_tso_mbufs);if mbuf[0] ==
mbuf_in
Will have a doublefree()for the same mbuf.Quoted 1 line
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/doc/guides/prog_guide/generic_segmentation_offload_lib.rstdoc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK
Quoted 4 lines
index 205cb8a..8577572 100644
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0@@ -25,8 +25,9 @@ Bearing that in mind, the GSO library enables DPDKapplications to segment
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK · line 25
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0packets in software. Note however, that GSO is implemented as astandalone
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK · line 26
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0library, and not via a 'fallback' mechanism (i.e. for when TSO isunsupported
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK · line 27
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0in the underlying hardware); that is, applications must explicitly invokethe
Quoted 3 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK applications to segment
Quoted 3 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +1
-2-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
Quoted 8 lines
Quoted 4 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK · line 29
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +1
-0+free mbuf GSO segments attach to after calling ``rte_gso_segment()``.Probably worth to mention that if return code == 1, then
output mbuf will point to input mbuf and extra care withfree()is required.Another possibility - change
gso_segment()behaviour even further, and don't putinput_pktinto pkt_out[] when no segmentation happened. Might be even a bit cleaner and less error prone.
Quoted 7 lines
Agree. Pkts_out[] better not to contain
input_pktwhen GSO doesn't happen.BTW, @Yi, you also need to update the comment of describing what
rte_gso_segment()returns inrte_gso.h.Thanks,
Jiayu
Thanks Jiayu, I'll add this in next version.
Quoted 74 lines
Quoted 74 lines
Quoted 8 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst To segment an outgoing packet, an application
Quoted 8 lines
The size
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +1
-0+of GSO segments ``(segsz)`` is configurable by the application. Limitations -----------@@ -233,6 +234,8 @@ To segment an outgoing packet, an applicationmust:
Quoted 4 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst To segment an outgoing packet, an application must:
Quoted 4 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +1
-0#. Invoke the GSO segmentation API, ``rte_gso_segment()``. +#. Call ``rte_pktmbuf_free()`` to free mbuf ``rte_gso_segment()``segments.
Quoted 2 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst To segment an outgoing packet, an application · line 238
Quoted 2 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +1
-0+ #. If required, update the L3 and L4 checksums of the newly-createdsegments.
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst To segment an outgoing packet, an application · line 239
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0For tunneled packets, the outer IPv4 headers' checksums should alsobe
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst To segment an outgoing packet, an application · line 240
Quoted 1 line
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0updated. Alternatively, the application may offload checksumcalculation
Quoted 25 lines
Quoted 25 lines
lib/librte_gso/rte_gso.c +1
-8@@ -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. */ Quoted 8 lines
lib/librte_gso/rte_gso.h struct rte_gso_ctx { · line 89
Quoted 8 lines
lib/librte_gso/rte_gso.c +0
-0pkt->ol_flags = ol_flags; }lib/librte_gso/rte_gso.h +0
-0@@ -89,8 +89,11 @@ struct rte_gso_ctx {* the GSO segments are sent to should support transmission of multi- segment
Quoted 4 lines
lib/librte_gso/rte_gso.h struct rte_gso_ctx {
Quoted 4 lines
lib/librte_gso/rte_gso.h +0
-2* 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 automatically.
Quoted 1 line
lib/librte_gso/rte_gso.h struct rte_gso_ctx { · line 92
Quoted 1 line
lib/librte_gso/rte_gso.h +1
-0+* If the input packet is GSO'd, all the indirect segments are attached to the
Quoted 3 lines
lib/librte_gso/rte_gso.h struct rte_gso_ctx {
Quoted 3 lines
lib/librte_gso/rte_gso.h +3
-0+* input packet. +* +* rte_gso_segment() will not free the input packet no matter whether it is
Quoted 1 line
lib/librte_gso/rte_gso.h struct rte_gso_ctx { · line 96
Quoted 1 line
lib/librte_gso/rte_gso.h +1
-0+* GSO'd or not, the application should free it after call
rte_gso_segment().Quoted 5 lines
Quoted 5 lines
lib/librte_gso/rte_gso.h +0
-1* * If the memory space in pkts_out or MBUF pools is insufficient, this * function fails, and it returns (-1) * errno. Otherwise, GSO succeeds, -- 1.8.3.1
Quoted 93 lines · Konstantin
Quoted 78 lines
Quoted 8 lines
rte_gso_segmentdecreased 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.Quoted 4 lines
One correct way is application should call
rte_pktmbuf_freeafter callingrte_gso_segmentto free pkt explicitly.rte_gso_segmentmustn't handle it, this should be responsibility of application.Probably needs to be stated clearly:
It is a change in functional behaviour. Without deprecation note in advance.
TB members: please provide your opinion on that patch.Quoted 6 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")Signed-off-by Yi Yang <[email protected]>---
Changelog:Quoted 8 lines
v1->v2:
- update description ofrte_gso_segment().
- change code which callsrte_gso_segment()to fix free issue.--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++--I think release notes also have to be updated.
Quoted 9 lines
lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)app/test-pmd/csumonly.c +0
-0app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1084
Quoted 5 lines
app/test-pmd/csumonly.c +2
-0@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);It doesn't look correct to me.
I think it should be:
If (ret > 1)rte_pktmbuf_free(pkts_burst[i]);app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1090
Quoted 7 lines
app/test-pmd/csumonly.c +0
-1if (ret >=0 ) nb_segments += ret;else {TESTPMD_LOG (DEBUG ,"Unable to segment packet" ); -rte_pktmbuf_free (pkts_burst[i]); } }About
drivers/net/tap/rte_eth_tap.c:
I think it has to be modified too, as here:/* free original mbuf */
rte_pktmbuf_free(mbuf_in); /* free tso mbufs */ if (num_tso_mbufs > 0) rte_pktmbuf_free_bulk(mbuf, num_tso_mbufs);if mbuf[0] ==
mbuf_in
Will have a doublefree()for the same mbuf.Review
Quoted 2 lines
(quoted diff) +0
-0
b/doc/guides/prog_guide/generic_segmentation_offload_lib.rstQuoted 14 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK applications to segment · line 29
Quoted 11 lines
index 205cb8a..8577572 100644
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +2
-2@@ -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()``.Probably worth to mention that if return code == 1, then
output mbuf will point to input mbuf and extra care withfree()is required.
Quoted 3 lines
Another possibility - change
gso_segment()behaviour even further, and don't putinput_pktinto pkt_out[] when no segmentation happened. Might be even a bit cleaner and less error prone.
Agree, I didn't notice it before.
Quoted 63 lines
Quoted 63 lines
Quoted 63 lines
The size
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +3
-0+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 calculationlib/librte_gso/rte_gso.c +1
-8@@ -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; }lib/librte_gso/rte_gso.h +5
-3@@ -89,8 +89,11 @@ struct rte_gso_ctx {* the GSO segments are sent to should support transmission of multi-segment * 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 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, -- 1.8.3.1
Konstantin, thank you so much for comments, my replies inline, please check them.
Quoted 8 lines · Konstantin
Quoted 8 lines
rte_gso_segmentdecreased 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.
Quoted 8 lines
Quoted 4 lines
One correct way is application should call
rte_pktmbuf_freeafter callingrte_gso_segmentto free pkt explicitly.rte_gso_segmentmustn't handle it, this should be responsibility of application.Probably needs to be stated clearly:
It is a change in functional behaviour.
Without deprecation note in advance.
Ok, I'll add such statement in next version.
Quoted 13 lines
TB members: please provide your opinion on that patch.
Quoted 11 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")Signed-off-by Yi Yang <[email protected]>---
Changelog:
v1->v2:
- update description ofrte_gso_segment().
- change code which callsrte_gso_segment()to fix free issue.
Quoted 5 lines
Quoted 3 lines
--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++--I think release notes also have to be updated.
Ok, also will update it to reflect this change.
Quoted 5 lines
Quoted 5 lines
lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)
Quoted 14 lines
app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1084
Quoted 10 lines
app/test-pmd/csumonly.c +2
-0@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);It doesn't look correct to me.
I think it should be:
If (ret > 1)rte_pktmbuf_free(pkts_burst[i]);
No, in original implementation, if gso failed, application will free it, otherwise rte_gso_segment will free it (i.e. refcnt update -1 in rte_gso_segment), this change will change previous behavior. application will free it for both cases.
Quoted 13 lines
app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1090
Quoted 8 lines
app/test-pmd/csumonly.c +0
-1if (ret >=0 ) nb_segments += ret;else {TESTPMD_LOG (DEBUG ,"Unable to segment packet" ); -rte_pktmbuf_free (pkts_burst[i]); } }About
drivers/net/tap/rte_eth_tap.c:
I think it has to be modified too, as here:
Quoted 8 lines
/* free original mbuf */
rte_pktmbuf_free(mbuf_in); /* free tso mbufs */ if (num_tso_mbufs > 0) rte_pktmbuf_free_bulk(mbuf, num_tso_mbufs);if mbuf[0] ==
mbuf_in
Will have a doublefree()for the same mbuf.
Here I'm not clear, is this code ok before I change? It looks like there is same issue there before.
Quoted 17 lines
Quoted 7 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK applications to segment · line 29
Quoted 7 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +2
-2@@ -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()``.Probably worth to mention that if return code == 1, then
output mbuf will point to input mbuf and extra care withfree()is required.
Ok.
Quoted 62 lines
Quoted 62 lines
The size
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +3
-0+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 calculationlib/librte_gso/rte_gso.c +1
-8@@ -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; }lib/librte_gso/rte_gso.h +5
-3@@ -89,8 +89,11 @@ struct rte_gso_ctx {* the GSO segments are sent to should support transmission of multi-segment * 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 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, -- 1.8.3.1
Quoted 68 lines
From:
yang_y_yi<[email protected]>
Sent: Friday, October 23, 2020 2:18 PM
To: Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re:RE: [PATCH v2] gso: fix free issue of mbuf gso segments attach toKonstantin, thank you so much for comments, my replies inline, please check them.
Quoted 8 lines · Konstantin
Quoted 8 lines
rte_gso_segmentdecreased 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.Quoted 8 lines
Quoted 4 lines
One correct way is application should call
rte_pktmbuf_freeafter callingrte_gso_segmentto free pkt explicitly.rte_gso_segmentmustn't handle it, this should be responsibility of application.Probably needs to be stated clearly:
It is a change in functional behaviour.
Without deprecation note in advance.Ok, I'll add such statement in next version.
Quoted 13 lines
TB members: please provide your opinion on that patch.
Quoted 11 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")Signed-off-by Yi Yang <mailto:[email protected]>---
Changelog:
v1->v2:
- update description ofrte_gso_segment().
- change code which callsrte_gso_segment()to fix free issue.Quoted 5 lines
Quoted 3 lines
--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++--I think release notes also have to be updated.
Ok, also will update it to reflect this change.
Quoted 5 lines
Quoted 5 lines
lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)Quoted 14 lines
app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1084
Quoted 10 lines
app/test-pmd/csumonly.c +2
-0@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);It doesn't look correct to me.
I think it should be:
If (ret > 1)rte_pktmbuf_free(pkts_burst[i]);
Quoted 2 lines
No, in original implementation, if gso failed, application will free it, otherwise
rte_gso_segmentwill free it (i.e. refcnt update -1 inrte_gso_segment), this change will change previous behavior. application will free it for both cases.
That's the point - with current implementation:
If ret == 1, then you shouldn't free input packet. Because in that case:input_pkt == output_pkt[0]
And if you'll free it, you can't use it after it.
In that particular case, you can't TX it.
Quoted 111 lines
Quoted 14 lines
app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1090
Quoted 9 lines
app/test-pmd/csumonly.c +0
-1if (ret >=0 ) nb_segments += ret;else {TESTPMD_LOG (DEBUG ,"Unable to segment packet" ); -rte_pktmbuf_free (pkts_burst[i]); } }About
drivers/net/tap/rte_eth_tap.c:
I think it has to be modified too, as here:Quoted 8 lines
/* free original mbuf */
rte_pktmbuf_free(mbuf_in); /* free tso mbufs */ if (num_tso_mbufs > 0) rte_pktmbuf_free_bulk(mbuf, num_tso_mbufs);if mbuf[0] ==
mbuf_in
Will have a doublefree()for the same mbuf.Here I'm not clear, is this code ok before I change? It looks like there is same issue there before.
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +0
-0
b/doc/guides/prog_guide/generic_segmentation_offload_lib.rstQuoted 6 lines
Quoted 6 lines
index 205cb8a..8577572 100644
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0@@ -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 unsupportedQuoted 8 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK applications to segment
Quoted 5 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +2
-2in 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()``.Probably worth to mention that if return code == 1, then
output mbuf will point to input mbuf and extra care withfree()is required.Ok.
Quoted 62 lines
Quoted 62 lines
The size
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +3
-0+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 calculationlib/librte_gso/rte_gso.c +1
-8@@ -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; }lib/librte_gso/rte_gso.h +5
-3@@ -89,8 +89,11 @@ struct rte_gso_ctx {* the GSO segments are sent to should support transmission of multi-segment * 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 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, -- 1.8.3.1
Quoted 72 lines · Konstantin
Quoted 68 lines
From:
yang_y_yi<[email protected]>
Sent: Friday, October 23, 2020 2:18 PM
To: Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re:RE: [PATCH v2] gso: fix free issue of mbuf gso segments attach toKonstantin, thank you so much for comments, my replies inline, please check them.
Quoted 8 lines · Konstantin
Quoted 8 lines
rte_gso_segmentdecreased 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.Quoted 8 lines
Quoted 4 lines
One correct way is application should call
rte_pktmbuf_freeafter callingrte_gso_segmentto free pkt explicitly.rte_gso_segmentmustn't handle it, this should be responsibility of application.Probably needs to be stated clearly:
It is a change in functional behaviour.
Without deprecation note in advance.Ok, I'll add such statement in next version.
Quoted 13 lines
TB members: please provide your opinion on that patch.
Quoted 11 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")Signed-off-by Yi Yang <mailto:[email protected]>---
Changelog:
v1->v2:
- update description ofrte_gso_segment().
- change code which callsrte_gso_segment()to fix free issue.Quoted 5 lines
Quoted 3 lines
--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++--I think release notes also have to be updated.
Ok, also will update it to reflect this change.
Quoted 5 lines
Quoted 5 lines
lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)Quoted 14 lines
app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1084
Quoted 10 lines
app/test-pmd/csumonly.c +2
-0@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);It doesn't look correct to me.
I think it should be:
If (ret > 1)rte_pktmbuf_free(pkts_burst[i]);Quoted 2 lines
No, in original implementation, if gso failed, application will free it, otherwise
rte_gso_segmentwill free it (i.e. refcnt update -1 inrte_gso_segment), this change will change previous behavior. application will free it for both cases.
Quoted 7 lines
That's the point - with current implementation:
If ret == 1, then you shouldn't free input packet. Because in that case:input_pkt== output_pkt[0]And if you'll free it, you can't use it after it.
In that particular case, you can't TX it.
I checked gso code again, there are two cases even if ret == 1, one case is it isn't segmented, the other is it is segmented but gso_do_segment returns 1, for case #1, we can handle it as you said, but for case #2, we can't handle it as you said because it has been segmented in fact. So I think we should return 0 foe case #1 and don't do assignment "pkts_out[0] = pkt;", we should handle case #2 as before, right?
Quoted 112 lines
Quoted 112 lines
Quoted 15 lines
app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1090
Quoted 10 lines
app/test-pmd/csumonly.c +0
-1if (ret >=0 ) nb_segments += ret;else {TESTPMD_LOG (DEBUG ,"Unable to segment packet" ); -rte_pktmbuf_free (pkts_burst[i]); } }About
drivers/net/tap/rte_eth_tap.c:
I think it has to be modified too, as here:Quoted 8 lines
/* free original mbuf */
rte_pktmbuf_free(mbuf_in); /* free tso mbufs */ if (num_tso_mbufs > 0) rte_pktmbuf_free_bulk(mbuf, num_tso_mbufs);if mbuf[0] ==
mbuf_in
Will have a doublefree()for the same mbuf.Here I'm not clear, is this code ok before I change? It looks like there is same issue there before.
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +0
-0
b/doc/guides/prog_guide/generic_segmentation_offload_lib.rstQuoted 6 lines
Quoted 6 lines
index 205cb8a..8577572 100644
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +0
-0@@ -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 unsupportedQuoted 8 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst Bearing that in mind, the GSO library enables DPDK applications to segment
Quoted 5 lines
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +2
-2in 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()``.Probably worth to mention that if return code == 1, then
output mbuf will point to input mbuf and extra care withfree()is required.Ok.
Quoted 62 lines
Quoted 62 lines
The size
doc/guides/prog_guide/generic_segmentation_offload_lib.rst +3
-0+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 calculationlib/librte_gso/rte_gso.c +1
-8@@ -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; }lib/librte_gso/rte_gso.h +5
-3@@ -89,8 +89,11 @@ struct rte_gso_ctx {* the GSO segments are sent to should support transmission of multi-segment * 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 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, -- 1.8.3.1
Quoted 80 lines · yang_y_yi
At 2020-10-23 22:46:42, "Ananyev, Konstantin" <[email protected]>
Quoted 77 lines · wrote:
Quoted 68 lines
From:
yang_y_yi<[email protected]>
Sent: Friday, October 23, 2020 2:18 PM
To: Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re:RE: [PATCH v2] gso: fix free issue of mbuf gso segments attach toKonstantin, thank you so much for comments, my replies inline, please check them.
Quoted 8 lines · Konstantin
Quoted 8 lines
rte_gso_segmentdecreased 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.Quoted 8 lines
Quoted 4 lines
One correct way is application should call
rte_pktmbuf_freeafter callingrte_gso_segmentto free pkt explicitly.rte_gso_segmentmustn't handle it, this should be responsibility of application.Probably needs to be stated clearly:
It is a change in functional behaviour.
Without deprecation note in advance.Ok, I'll add such statement in next version.
Quoted 13 lines
TB members: please provide your opinion on that patch.
Quoted 11 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")Signed-off-by Yi Yang <mailto:[email protected]>---
Changelog:
v1->v2:
- update description ofrte_gso_segment().
- change code which callsrte_gso_segment()to fix free issue.Quoted 5 lines
Quoted 3 lines
--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++--I think release notes also have to be updated.
Ok, also will update it to reflect this change.
Quoted 5 lines
Quoted 5 lines
lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)Quoted 14 lines
app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1084
Quoted 10 lines
app/test-pmd/csumonly.c +2
-0@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);It doesn't look correct to me.
I think it should be:
If (ret > 1)rte_pktmbuf_free(pkts_burst[i]);Quoted 2 lines
No, in original implementation, if gso failed, application will free it, otherwise
rte_gso_segmentwill free it (i.e. refcnt update -1 inrte_gso_segment), this change will change previous behavior. application will free it for both cases.That's the point - with current implementation:
If ret == 1, then you shouldn't free input packet. Because in that case:input_pkt== output_pkt[0]
Quoted 5 lines
Quoted 2 lines
And if you'll free it, you can't use it after it.
In that particular case, you can't TX it.I checked gso code again, there are two cases even if ret == 1, one case is it isn't segmented, the other is it is segmented but
gso_do_segmentreturns 1, for case #1, we can handle it as you said, but for case #2, we can't handle it as you said because it has been segmented in fact. So I think we should return 0 foe case #1 and don't do assignment "pkts_out[0] = pkt;", we should handle case #2 as before, right?
When will #2 case happen? In current implementation, ret of gso_do_segment() is > 1, when GSO happens; otherwise, ret is negative. It doesn't return 1. If you mean the case that pkt_len is smaller than gso_size, gso_do_segment() will not be called, since rte_gso_segment() will compare pkt_len and gso_size before.
Thanks,
Jiayu
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 94 lines · Jiayu Hu
Quoted 80 lines · yang_y_yi
At 2020-10-23 22:46:42, "Ananyev, Konstantin" <[email protected]>
Quoted 77 lines · wrote:
Quoted 68 lines
From:
yang_y_yi<[email protected]>
Sent: Friday, October 23, 2020 2:18 PM
To: Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re:RE: [PATCH v2] gso: fix free issue of mbuf gso segments attach toKonstantin, thank you so much for comments, my replies inline, please check them.
Quoted 8 lines · Konstantin
Quoted 8 lines
rte_gso_segmentdecreased 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.Quoted 8 lines
Quoted 4 lines
One correct way is application should call
rte_pktmbuf_freeafter callingrte_gso_segmentto free pkt explicitly.rte_gso_segmentmustn't handle it, this should be responsibility of application.Probably needs to be stated clearly:
It is a change in functional behaviour.
Without deprecation note in advance.Ok, I'll add such statement in next version.
Quoted 13 lines
TB members: please provide your opinion on that patch.
Quoted 11 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")Signed-off-by Yi Yang <mailto:[email protected]>---
Changelog:
v1->v2:
- update description ofrte_gso_segment().
- change code which callsrte_gso_segment()to fix free issue.Quoted 5 lines
Quoted 3 lines
--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++--I think release notes also have to be updated.
Ok, also will update it to reflect this change.
Quoted 5 lines
Quoted 5 lines
lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)Quoted 14 lines
app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1084
Quoted 10 lines
app/test-pmd/csumonly.c +2
-0@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);It doesn't look correct to me.
I think it should be:
If (ret > 1)rte_pktmbuf_free(pkts_burst[i]);Quoted 2 lines
No, in original implementation, if gso failed, application will free it, otherwise
rte_gso_segmentwill free it (i.e. refcnt update -1 inrte_gso_segment), this change will change previous behavior. application will free it for both cases.That's the point - with current implementation:
If ret == 1, then you shouldn't free input packet. Because in that case:input_pkt== output_pkt[0]Quoted 5 lines
Quoted 2 lines
And if you'll free it, you can't use it after it.
In that particular case, you can't TX it.I checked gso code again, there are two cases even if ret == 1, one case is it isn't segmented, the other is it is segmented but
gso_do_segmentreturns 1, for case #1, we can handle it as you said, but for case #2, we can't handle it as you said because it has been segmented in fact. So I think we should return 0 foe case #1 and don't do assignment "pkts_out[0] = pkt;", we should handle case #2 as before, right?When will #2 case happen? In current implementation, ret of
gso_do_segment()is > 1, when GSO happens; otherwise, ret is negative. It doesn't return 1. If you mean the case thatpkt_lenis smaller thangso_size,gso_do_segment()will not be called, sincerte_gso_segment()will comparepkt_lenandgso_sizebefore.
Quoted 2 lines
Thanks,
Jiayu
Got it, thanks Jiayu, I'll send out v3 to fix all the comments. Is "return 0 for the case ret == 1" ok? Before, this is still transmitted as a normal packet, but it is dropped/freed if ret <0.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 96 lines · yang_y_yi
Quoted 94 lines · Jiayu Hu
Quoted 80 lines · yang_y_yi
At 2020-10-23 22:46:42, "Ananyev, Konstantin" <[email protected]>
Quoted 77 lines · wrote:
Quoted 68 lines
From:
yang_y_yi<[email protected]>
Sent: Friday, October 23, 2020 2:18 PM
To: Ananyev, Konstantin <[email protected]>
Cc: [email protected]; Hu, Jiayu <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re:RE: [PATCH v2] gso: fix free issue of mbuf gso segments attach toKonstantin, thank you so much for comments, my replies inline, please check them.
Quoted 8 lines · Konstantin
Quoted 8 lines
rte_gso_segmentdecreased 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.Quoted 8 lines
Quoted 4 lines
One correct way is application should call
rte_pktmbuf_freeafter callingrte_gso_segmentto free pkt explicitly.rte_gso_segmentmustn't handle it, this should be responsibility of application.Probably needs to be stated clearly:
It is a change in functional behaviour.
Without deprecation note in advance.Ok, I'll add such statement in next version.
Quoted 13 lines
TB members: please provide your opinion on that patch.
Quoted 11 lines
Fixes 119583797b6a ("gso: support TCP/IPv4 GSO")Signed-off-by Yi Yang <mailto:[email protected]>---
Changelog:
v1->v2:
- update description ofrte_gso_segment().
- change code which callsrte_gso_segment()to fix free issue.Quoted 5 lines
Quoted 3 lines
--- app/test-pmd/csumonly.c | 3 ++- doc/guides/prog_guide/generic_segmentation_offload_lib.rst | 7 +++++--I think release notes also have to be updated.
Ok, also will update it to reflect this change.
Quoted 5 lines
Quoted 5 lines
lib/librte_gso/rte_gso.c | 9 +-------- lib/librte_gso/rte_gso.h | 7 +++++-- 4 files changed, 13 insertions(+), 13 deletions(-)Quoted 14 lines
app/test-pmd/csumonly.c struct simple_gre_hdr { · line 1084
Quoted 10 lines
app/test-pmd/csumonly.c +2
-0@@ -1080,11 +1080,12 @@ struct simple_gre_hdr { ret =rte_gso_segment (pkts_burst[i], gso_ctx, &gso_segments[nb_segments],GSO_MAX_PKT_BURST - nb_segments); +/* pkts_burst[i] can be freed safely here. */ +rte_pktmbuf_free (pkts_burst[i]);It doesn't look correct to me.
I think it should be:
If (ret > 1)rte_pktmbuf_free(pkts_burst[i]);Quoted 2 lines
No, in original implementation, if gso failed, application will free it, otherwise
rte_gso_segmentwill free it (i.e. refcnt update -1 inrte_gso_segment), this change will change previous behavior. application will free it for both cases.That's the point - with current implementation:
If ret == 1, then you shouldn't free input packet. Because in that case:input_pkt== output_pkt[0]Quoted 5 lines
Quoted 2 lines
And if you'll free it, you can't use it after it.
In that particular case, you can't TX it.I checked gso code again, there are two cases even if ret == 1, one case is it isn't segmented, the other is it is segmented but
gso_do_segmentreturns 1, for case #1, we can handle it as you said, but for case #2, we can't handle it as you said because it has been segmented in fact. So I think we should return 0 foe case #1 and don't do assignment "pkts_out[0] = pkt;", we should handle case #2 as before, right?When will #2 case happen? In current implementation, ret of
gso_do_segment()is > 1, when GSO happens; otherwise, ret is negative. It doesn't return 1. If you mean the case thatpkt_lenis smaller thangso_size,gso_do_segment()will not be called, sincerte_gso_segment()will comparepkt_lenandgso_sizebefore.
Quoted 4 lines
Quoted 2 lines
Thanks,
JiayuGot it, thanks Jiayu, I'll send out v3 to fix all the comments. Is "return 0 for the case ret == 1" ok? Before, this is still transmitted as a normal packet, but it is dropped/freed if ret <0.
When no GSO happens, return 0 and pkts_out[] doesn't store input pkt. This design is OK for me.
Thanks,
Jiayu
Quoted 14 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines