@samitouri / QOSamiQemu / commits / 1161da52d2

net: mark struct ip6_header as QEMU_PACKED

The ip6_header is often used by network devices to examine structures in packet data, and it's not guaranteed to be aligned. This manifests as errors from the clang sanitizer like this one: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../hw/net/rocker/rocker_of_dpa.c:321:37 ../../hw/net/rocker/rocker_of_dpa.c:730:33: runtime error: member access within misaligned address 0x742970fe7ecd for type 'struct ip6_header', which requires 4 byte alignment 0x742970fe7ecd: note: pointer points here 00 00 02 81 00 60 00 00 00 00 38 3a ff fe 80 00 00 00 00 00 00 00 00 00 00 00 00 00 02 ff 02 00 ^ Fix this by marking the ip6_header struct as QEMU_PACKED, the way we have done to handle similar problems involving tcp_header, ip_header, etc. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Message-ID: <20260505201324.932323-1-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Peter Maydell committed May 5, 2026 at 21:13 UTC 1161da52d2666140c06eb4f6cff72472afcfdb5b
1 file changed +1 -1
include/net/eth.h
+1 -1
@@ -119,7 +119,7 @@ struct ip6_header {
119 } ip6_ctlun;
120 struct in6_address ip6_src; /* source address */
121 struct in6_address ip6_dst; /* destination address */
122 -};
122 +} QEMU_PACKED;
123
124 typedef struct ip6_pseudo_header {
125 struct in6_address ip6_src;