[dpdk-dev] [PATCH] Fix loss of data stored in udata64 mbuf field

Michal Krawczyk mk at semihalf.com
Thu Feb 4 09:52:09 CET 2021

DPDK v20.11 removed udata64 field, and changed type of the dynfield1 to

Due to define:
  lib/common/pg_compat.h:#define udata64                 dynfield1[0]
the copy of udata64 was in fact copying only the first 32 bits.

Using udata64 as an address is ok, as it will point to the beginning of
the dynfield1 array.

Signed-off-by: Michal Krawczyk <mk at semihalf.com>
Reviewed-by: Igor Chauskin <igorch at amazon.com>
 lib/common/mbuf.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/common/mbuf.h b/lib/common/mbuf.h
index 2951454..07d97ad 100644
--- a/lib/common/mbuf.h
+++ b/lib/common/mbuf.h
@@ -30,7 +30,11 @@ pktmbuf_reset(struct rte_mbuf *m)
 	union pktgen_data d;
-	d.udata = m->udata64;	/* Save the original value */
+	/* Save the original value. As udata64 can be either single field or the
+	 * first value of the 32-bit elements array, the whole memory chunk must
+	 * be converted directly to 64-bit.
+	 */
+	d.udata = *(uint64_t *)(&m->udata64);

More information about the dev mailing list