The packet buffer needs to be 32-bit aligned to ensure that the various
32-bit fields we pick out are naturally aligned.
The control message buffers needs to be naturally aligned for struct
cmsghdr.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
// Receive rounds
for (; len < 0 && (round_start < round_end);
round_start = odhcp6c_get_milli_time()) {
- uint8_t buf[1536], cmsg_buf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
+ uint8_t buf[1536];
+ uint8_t cmsg_buf[CMSG_SPACE(sizeof(struct in6_pktinfo))]
+ __aligned(__alignof__(struct cmsghdr));
struct iovec iov = {buf, sizeof(buf)};
struct sockaddr_in6 addr;
struct msghdr msg = {.msg_name = &addr, .msg_namelen = sizeof(addr),
#define _unused __attribute__((unused))
#define _packed __attribute__((packed))
+#define __aligned(n) __attribute__((aligned(n)))
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
{
bool found = false;
bool changed = false;
- uint8_t buf[1500], cmsg_buf[128];
+ uint8_t buf[1500] __aligned(4);
+ uint8_t cmsg_buf[128] __aligned(__alignof__(struct cmsghdr));
struct nd_router_advert *adv = (struct nd_router_advert*)buf;
struct odhcp6c_entry *entry = alloca(sizeof(*entry) + 256);
const struct in6_addr any = IN6ADDR_ANY_INIT;