mbuf: fix API to copy mbuf dynamic fields

Message ID 20240626120802.19333-1-sthotton@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series mbuf: fix API to copy mbuf dynamic fields |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Shijith Thotton June 26, 2024, 12:08 p.m. UTC
Fixed rte_mbuf_dynfield_copy() API to copy dynamic fields from one mbuf
to another. When RTE_IOVA_AS_PA is not defined during the build, an
additional dynamic field (dynfield2) becomes available. This field
should be conditionally copied to ensure the complete duplication of
dynamic fields between mbufs. This patch fixes the same.

see https://bugs.dpdk.org/show_bug.cgi?id=1472

Bugzilla ID: 1472
Fixes: 03b57eb7ab9a ("mbuf: add second dynamic field member")
Cc: stable@dpdk.org

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 lib/mbuf/rte_mbuf.h | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Morten Brørup June 26, 2024, 12:23 p.m. UTC | #1
> From: Shijith Thotton [mailto:sthotton@marvell.com]
> Sent: Wednesday, 26 June 2024 14.08
> 
> Fixed rte_mbuf_dynfield_copy() API to copy dynamic fields from one mbuf
> to another. When RTE_IOVA_AS_PA is not defined during the build, an
> additional dynamic field (dynfield2) becomes available. This field
> should be conditionally copied to ensure the complete duplication of
> dynamic fields between mbufs. This patch fixes the same.
> 
> see https://bugs.dpdk.org/show_bug.cgi?id=1472
> 
> Bugzilla ID: 1472
> Fixes: 03b57eb7ab9a ("mbuf: add second dynamic field member")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>

Thank you for fixing this bug.

> ---
>  lib/mbuf/rte_mbuf.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
> index 4c4722e002..dc6d1237ac 100644
> --- a/lib/mbuf/rte_mbuf.h
> +++ b/lib/mbuf/rte_mbuf.h
> @@ -1120,6 +1120,9 @@ static inline void
>  rte_mbuf_dynfield_copy(struct rte_mbuf *mdst, const struct rte_mbuf *msrc)
>  {
>  	memcpy(&mdst->dynfield1, msrc->dynfield1, sizeof(mdst->dynfield1));
> +#if !RTE_IOVA_IN_MBUF
> +	mdst->dynfield2 = msrc->dynfield2;
> +#endif

dynfield2 is located before dynfield1 in the mbuf struct; suggest copy dynfield2 before dynfield1.

>  }
> 
>  /* internal */
> --
> 2.25.1

With or without suggested change,

Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
  
Stephen Hemminger June 26, 2024, 3 p.m. UTC | #2
On Wed, 26 Jun 2024 17:38:02 +0530
Shijith Thotton <sthotton@marvell.com> wrote:

> Fixed rte_mbuf_dynfield_copy() API to copy dynamic fields from one mbuf
> to another. When RTE_IOVA_AS_PA is not defined during the build, an
> additional dynamic field (dynfield2) becomes available. This field
> should be conditionally copied to ensure the complete duplication of
> dynamic fields between mbufs. This patch fixes the same.
> 
> see https://bugs.dpdk.org/show_bug.cgi?id=1472
> 
> Bugzilla ID: 1472
> Fixes: 03b57eb7ab9a ("mbuf: add second dynamic field member")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Shijith Thotton <sthotton@marvell.com>

Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  

Patch

diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h
index 4c4722e002..dc6d1237ac 100644
--- a/lib/mbuf/rte_mbuf.h
+++ b/lib/mbuf/rte_mbuf.h
@@ -1120,6 +1120,9 @@  static inline void
 rte_mbuf_dynfield_copy(struct rte_mbuf *mdst, const struct rte_mbuf *msrc)
 {
 	memcpy(&mdst->dynfield1, msrc->dynfield1, sizeof(mdst->dynfield1));
+#if !RTE_IOVA_IN_MBUF
+	mdst->dynfield2 = msrc->dynfield2;
+#endif
 }
 
 /* internal */