DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: dev@dpdk.org, Thomas Monjalon <thomas@monjalon.net>
Cc: "Morten Brørup" <mb@smartsharesystems.com>,
	stable@dpdk.org, "Maxime Leroy" <maxime@leroys.fr>,
	"Stephen Hemminger" <stephen@networkplumber.org>
Subject: [PATCH v2] net: revert add IPv6 traffic class and flow label fields
Date: Tue, 29 Sep 2026 07:36:01 +0000	[thread overview]
Message-ID: <20260929073601.2971197-1-mb@smartsharesystems.com> (raw)
In-Reply-To: <20260922163640.1144749-1-mb@smartsharesystems.com>

The IPv6 header bitfields "version", "ds", "ecn", and "flow_label"
are not organized correctly on little endian architectures.
On little endian, a 32-bit bitfield is allocated from the least
significant bit of the host order word, but "vtc_flow" is stored in
network order. All four fields therefore read and write the wrong
bits. For example, setting "version" to 6 writes 0x60 into the last
byte of the word.

"ds" and "flow_label" are not contiguous in memory on little endian,
so no reordering of bitfields can express them.

Reverted the patch introducing these bitfields.

PS: There is a GCC attribute to fix this, but nothing similar is
offered by Clang or MSVC:
__attribute__((scalar_storage_order("big-endian")))

Bugzilla ID: 1679
Fixes: cba27998dc81 ("net: add IPv6 traffic class and flow label fields")
Cc: stable@dpdk.org

Reported-by: Maxime Leroy <maxime@leroys.fr>
Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2: Updated commit message and release notes. (AI advanced model)
---
 doc/guides/rel_notes/release_26_11.rst |  5 +++++
 lib/net/rte_ip6.h                      | 18 +-----------------
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 4b3e5d995c..52ccc8f787 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -79,6 +79,11 @@ Removed Items
     ``rte_rib6_is_equal``
   * table: ``RTE_LPM_IPV6_ADDR_SIZE``
 
+  * net: Removed ``version``, ``ds``, ``ecn`` and ``flow_label``
+    bitfields from ``struct rte_ipv6_hdr``. They accessed the wrong
+    bits on little endian. Use ``vtc_flow`` with the
+    ``RTE_IPV6_HDR_*_MASK`` and ``RTE_IPV6_HDR_*_SHIFT`` macros.
+
 
 API Changes
 -----------
diff --git a/lib/net/rte_ip6.h b/lib/net/rte_ip6.h
index d1abf1f5d5..25be328955 100644
--- a/lib/net/rte_ip6.h
+++ b/lib/net/rte_ip6.h
@@ -467,23 +467,7 @@ rte_ether_mcast_from_ipv6(struct rte_ether_addr *mac, const struct rte_ipv6_addr
  * IPv6 Header
  */
 struct __rte_aligned(2) __rte_packed_begin rte_ipv6_hdr {
-	union {
-		rte_be32_t vtc_flow;        /**< IP version, traffic class & flow label. */
-		__extension__
-		struct {
-#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
-			uint32_t flow_label:20; /**< Flow label */
-			uint32_t ecn:2;         /**< ECN */
-			uint32_t ds:6;          /**< Differentiated services */
-			uint32_t version:4;     /**< Version */
-#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
-			uint32_t version:4;     /**< Version */
-			uint32_t ds:6;          /**< Differentiated services */
-			uint32_t ecn:2;         /**< ECN */
-			uint32_t flow_label:20; /**< Flow label */
-#endif
-		};
-	};
+	rte_be32_t vtc_flow;	/**< IP version, traffic class & flow label. */
 	rte_be16_t payload_len;	/**< IP payload size, including ext. headers */
 	uint8_t  proto;		/**< Protocol, next header. */
 	uint8_t  hop_limits;	/**< Hop limits. */
-- 
2.43.0


      parent reply	other threads:[~2026-09-29  7:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 16:36 [PATCH] net: revert add IPv6 traffic class and flow label fields Morten Brørup
2026-09-22 18:14 ` Stephen Hemminger
2026-09-28 14:15   ` Thomas Monjalon
2026-09-28 14:20     ` Morten Brørup
2026-09-29  7:36 ` Morten Brørup [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260929073601.2971197-1-mb@smartsharesystems.com \
    --to=mb@smartsharesystems.com \
    --cc=dev@dpdk.org \
    --cc=maxime@leroys.fr \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox