[PATCH v3] net: add bit fields to IPv6 header definition
Morten Brørup
mb at smartsharesystems.com
Tue Jun 18 12:47:55 CEST 2024
> struct rte_ipv6_hdr {
> - rte_be32_t vtc_flow; /**< IP version, traffic class & flow label.
> */
> + union {
> + rte_be32_t vtc_flow; /**< IP version, traffic class & flow
> label. */
> + __extension__
> + struct {
> +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
> + rte_be32_t flow_label:20; /**< flow label */
I played around with this in Godbolt, and __attribute__((__packed__)) only packs bytes, not bits, so the packed structure grows from 4 to 5 bytes, because the compiler adds 4 bits of padding here, to byte align the union holding "tc".
Please revert to v2.
Sorry about the noise. ;-)
> + union {
> + rte_be32_t tc:8;
> + struct {
> + rte_be32_t ecn:2; /**< ECN */
> + rte_be32_t ds:6; /**< differentiated
> services */
> + };
> + };
More information about the dev
mailing list