Morten Brørup, Oct 06, 2024 at 10:18:
This has been discussed before, but I want to double check...
If - sometime in the future - we want to add a union to offer a 2-byte
access variant and make the structure to 2-byte aligned (which is the
common case in Ethernet packets), it will break both API and ABI. This
seems unlikely to get accepted at a later time, so I think we are
- right now - in a situation where it's now or never:
struct rte_ipv6_addr {
__extension__
union {
unsigned char a[RTE_IPV6_ADDR_SIZE];
uint16_t w[RTE_IPV6_ADDR_SIZE / 2];
};
};
Unless some of the CPU folks want the 2-byte aligned variant, stick
with what you offered.
I was also thinking the same. I could have added an unnamed union which
only contains one field.
However, it does not make much sense if we never want to change the
default alignment.
Important note: DPDK is compiled with the following C flags:
-Wno-address-of-packed-member
Added in 2017 https://git.dpdk.org/dpdk/commit/?id=95cd37070af44
If we had struct rte_ipv6_addr aligned on 2 bytes (or more),
applications that do not silence that warning would have a hard time.
Example in grout:
../modules/ip6/datapath/ip6_input.c:99:54: error: taking address of packed
member of ‘struct rte_ipv6_hdr’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
99 | nh = ip6_route_lookup(iface->vrf_id, &ip->dst_addr);
| ^~~~~~~~~~~~~
I'd say that it is better to keep it simple :)