net: enforce 2-bytes alignment on IPv6 headers
PATCH 1/1 net: enforce 2-bytes alignment on IPv6 headers
IPv6 headers are always aligned on a 2-bytes grid. Reflect this in the structure definition.
--- lib/net/rte_ip6.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/net/rte_ip6.h +3 -3
@@ -460,7 +460,7 @@ rte_ether_mcast_from_ipv6(struct rte_ether_addr *mac, const struct rte_ipv6_addr/** * IPv6 Header */ -struct rte_ipv6_hdr { +struct __rte_aligned(2) rte_ipv6_hdr {union {rte_be32_t vtc_flow;/**< IP version, traffic class & flow label. */ __extension__
@@ -507,7 +507,7 @@ static inline int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip)/** * IPv6 Routing Extension Header */ -struct rte_ipv6_routing_ext { +struct __rte_aligned(2) rte_ipv6_routing_ext {uint8_t next_hdr;/**< Protocol, next header. */ uint8_t hdr_len;/**< Header length. */ uint8_t type;/**< Extension header type. */
@@ -751,7 +751,7 @@ rte_ipv6_udptcp_cksum_mbuf_verify(const struct rte_mbuf *m,#define RTE_IPV6_SET_FRAG_DATA (fo, mf) \ (((fo) & RTE_IPV6_EHDR_FO_MASK) | ((mf) & RTE_IPV6_EHDR_MF_MASK)) -struct rte_ipv6_fragment_ext { +struct __rte_aligned(2) rte_ipv6_fragment_ext {uint8_t next_header;/**< Next header type */ uint8_t reserved;/**< Reserved */ rte_be16_t frag_data;/**< All fragmentation data */
Signature · 1 line
2.47.0
Quoted 46 lines
From: Robin Jarry [mailto:[email protected]]
Sent: Tuesday, 5 November 2024 13.25IPv6 headers are always aligned on a 2-bytes grid. Reflect this in the structure definition.
Signed-off-by Robin Jarry <[email protected]>--- lib/net/rte_ip6.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/net/rte_ip6.h +1
-1@@ -460,7 +460,7 @@ rte_ether_mcast_from_ipv6(struct rte_ether_addr *mac, const struct rte_ipv6_addr/** * IPv6 Header */ -struct rte_ipv6_hdr { +struct __rte_aligned(2) rte_ipv6_hdr { union { rte_be32_t vtc_flow; /**< IP version, traffic class& flow label. */
lib/net/rte_ip6.h +1
-1__extension__@@ -507,7 +507,7 @@ static inline int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip)/** * IPv6 Routing Extension Header */ -struct rte_ipv6_routing_ext { +struct __rte_aligned(2) rte_ipv6_routing_ext {uint8_t next_hdr;/**< Protocol, next header. */ uint8_t hdr_len;/**< Header length. */
uint8_ttype; /**< Extension header type.
*/lib/net/rte_ip6.h +1
-1@@ -751,7 +751,7 @@ rte_ipv6_udptcp_cksum_mbuf_verify(const structrte_mbuf *m, #define RTE_IPV6_SET_FRAG_DATA(fo, mf) \ (((fo) & RTE_IPV6_EHDR_FO_MASK) | ((mf) & RTE_IPV6_EHDR_MF_MASK)) -struct rte_ipv6_fragment_ext { +struct __rte_aligned(2) rte_ipv6_fragment_ext { uint8_t next_header; /**< Next header type */uint8_t reserved;/**< Reserved */
Quoted 3 lines
rte_be16_tfrag_data; /**< All fragmentation data */
--
2.47.0
Quoted 46 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Tuesday, 5 November 2024 13.28Quoted 4 lines
From: Robin Jarry [mailto:[email protected]]
Sent: Tuesday, 5 November 2024 13.25IPv6 headers are always aligned on a 2-bytes grid. Reflect this in
the
Quoted 38 lines
structure definition.
Signed-off-by Robin Jarry <[email protected]>--- lib/net/rte_ip6.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)lib/net/rte_ip6.h +1
-1@@ -460,7 +460,7 @@ rte_ether_mcast_from_ipv6(struct rte_ether_addr *mac, const struct rte_ipv6_addr/** * IPv6 Header */ -struct rte_ipv6_hdr { +struct __rte_aligned(2) rte_ipv6_hdr { union { rte_be32_t vtc_flow; /**< IP version, traffic class& flow label. */
lib/net/rte_ip6.h +1
-1__extension__@@ -507,7 +507,7 @@ static inline int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip)/** * IPv6 Routing Extension Header */ -struct rte_ipv6_routing_ext { +struct __rte_aligned(2) rte_ipv6_routing_ext {uint8_t next_hdr;/**< Protocol, next header. */ uint8_t hdr_len;/**< Header length. */
uint8_ttype; /**< Extension header type.
*/lib/net/rte_ip6.h +0
-0@@ -751,7 +751,7 @@ rte_ipv6_udptcp_cksum_mbuf_verify(const structrte_mbuf *m, #define RTE_IPV6_SET_FRAG_DATA(fo, mf) \ (((fo) & RTE_IPV6_EHDR_FO_MASK) | ((mf) & RTE_IPV6_EHDR_MF_MASK))
Quoted 9 lines
Quoted 7 lines
lib/net/rte_ip6.h +1
-1-struct rte_ipv6_fragment_ext { +struct __rte_aligned(2) rte_ipv6_fragment_ext {uint8_t next_header;/**< Next header type */ uint8_t reserved;/**< Reserved */
rte_be16_tfrag_data; /**< All fragmentation data */
--
2.47.0Reviewed-by Morten Brørup <[email protected]>
Too trigger happy, I am.
Please also update the release notes like the IPv4 patch. Suggest:
+++ b/doc/guides/rel_notes/release_24_11.rst
@@ -291,6 +291,8 @@ API Changes
releases: it handles key=value and only-key cases.
* Both ``rte_kvargs_process`` and ``rte_kvargs_process_opt`` reject a NULL ``kvlist`` parameter.
* net: The IPv4 header structure ``rte_ipv4_hdr`` has been marked as two bytes aligned.
+* net: The IPv6 header and extension structures ``rte_ipv6_hdr``, ``rte_ipv6_routing_ext`` and ``rte_ipv6_fragment_ext`` have been marked as two bytes aligned. +
* net: The ICMP message types ``RTE_IP_ICMP_ECHO_REPLY`` and ``RTE_IP_ICMP_ECHO_REQUEST``
are marked as deprecated, and are replaced
by ``RTE_ICMP_TYPE_ECHO_REPLY`` and ``RTE_ICMP_TYPE_ECHO_REQUEST``.
PATCH v2 1/1 net: enforce 2-bytes alignment on IPv6 headers
In reply to Robin JarryIPv6 headers are always aligned on a 2-bytes grid. Reflect this in the structure definition.
---
Notes:
v2: added changelog entry
doc/guides/rel_notes/release_24_11.rst | 6 ++++++ lib/net/rte_ip6.h | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-)
doc/guides/rel_notes/release_24_11.rst +6 -0
@@ -295,6 +295,12 @@ API Changes are marked as deprecated, and are replaced by ``RTE_ICMP_TYPE_ECHO_REPLY`` and ``RTE_ICMP_TYPE_ECHO_REQUEST``. +* net: The IPv6 header and extension structures have been marked as two bytes aligned: + + - ``struct rte_ipv6_hdr`` + - ``struct rte_ipv6_routing_ext`` + - ``struct rte_ipv6_fragment_ext`` + * net: A new IPv6 address structure was introduced to replace ad-hoc ``uint8_t[16]`` arrays. The following libraries and symbols were modified:
lib/net/rte_ip6.h +3 -3
@@ -460,7 +460,7 @@ rte_ether_mcast_from_ipv6(struct rte_ether_addr *mac, const struct rte_ipv6_addr/** * IPv6 Header */ -struct rte_ipv6_hdr { +struct __rte_aligned(2) rte_ipv6_hdr {union {rte_be32_t vtc_flow;/**< IP version, traffic class & flow label. */ __extension__
@@ -507,7 +507,7 @@ static inline int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip)/** * IPv6 Routing Extension Header */ -struct rte_ipv6_routing_ext { +struct __rte_aligned(2) rte_ipv6_routing_ext {uint8_t next_hdr;/**< Protocol, next header. */ uint8_t hdr_len;/**< Header length. */ uint8_t type;/**< Extension header type. */
@@ -751,7 +751,7 @@ rte_ipv6_udptcp_cksum_mbuf_verify(const struct rte_mbuf *m,#define RTE_IPV6_SET_FRAG_DATA (fo, mf) \ (((fo) & RTE_IPV6_EHDR_FO_MASK) | ((mf) & RTE_IPV6_EHDR_MF_MASK)) -struct rte_ipv6_fragment_ext { +struct __rte_aligned(2) rte_ipv6_fragment_ext {uint8_t next_header;/**< Next header type */ uint8_t reserved;/**< Reserved */ rte_be16_t frag_data;/**< All fragmentation data */
Signature · 1 line
2.47.0
Quoted 7 lines
From: Robin Jarry [mailto:[email protected]]
Sent: Tuesday, 5 November 2024 15.13IPv6 headers are always aligned on a 2-bytes grid. Reflect this in the structure definition.
Signed-off-by Robin Jarry <[email protected]>
Quoted 8 lines
---
Notes:
v2: added changelog entrydoc/guides/rel_notes/release_24_11.rst | 6 ++++++ lib/net/rte_ip6.h | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-)
Thank you, Robin.
Note for other reviewers:
This patch provides consistency with the IPv4 header alignment patch,
https://patchwork.dpdk.org/project/dpdk/patch/[email protected]/
David Marchand
AppliedQuoted 9 lines · Morten Brørup
Quoted 8 lines
From: Robin Jarry [mailto:[email protected]]
Sent: Tuesday, 5 November 2024 15.13IPv6 headers are always aligned on a 2-bytes grid. Reflect this in the structure definition.
Signed-off-by Robin Jarry <[email protected]>Reviewed-by Morten Brørup <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand