net: ip: enforce alignment in struct cmsghdr
The alignment is needed when using CMSG_DATA() to access a uint64_t
when an object of type struct cmsghdr is allocated on the stack.
Also update the ALIGN_H and ALIGN_D macros to better match the
description in RFC 3542:
"The macros ALIGN_H() and ALIGN_D(), which are implementation
dependent, round their arguments up to the next even multiple of
whatever alignment is required for the start of the cmsghdr structure
and the data, respectively."
This commit makes the following test pass on qemu_leon3:
- net.socket.udp. It previously generated an unaligned data access
exception when a uint64_t value was accessed via CMSG_DATA().
Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
1 file changed