0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-21 09:11:54 +00:00

Lib: Ensure that all net_addr structures have the same alignment

Also weaken the explicit alignment of net_addr to be u32, as VPN
is already u32-aligned.
This commit is contained in:
Ondrej Zajicek 2024-12-16 18:56:30 +01:00
parent 34b7d77e06
commit 161aef353a
3 changed files with 17 additions and 1 deletions

View File

@ -11,6 +11,7 @@
#include "lib/alloca.h"
#include <stdarg.h>
#include <stdalign.h>
/* Ugly structure offset handling macros */

View File

@ -75,6 +75,21 @@ STATIC_ASSERT(sizeof(net_addr_ip6_sadr) == 40);
STATIC_ASSERT(sizeof(net_addr_mpls) == 8);
STATIC_ASSERT(sizeof(net_addr_aspa) == 8);
/* Ensure that all net_addr structures have the same alignment */
STATIC_ASSERT(alignof(net_addr_ip4) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_ip6) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_vpn4) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_vpn6) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_roa4) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_roa6) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_flow4) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_flow6) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_flow4) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_flow6) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_ip6_sadr) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_mpls) == alignof(net_addr));
STATIC_ASSERT(alignof(net_addr_aspa) == alignof(net_addr));
int
rd_format(const vpn_rd rd_, char *buf, int buflen)

View File

@ -51,7 +51,7 @@ typedef struct net_addr {
u8 pxlen;
u16 length;
u8 data[20];
u64 align[0];
u32 align[0];
} net_addr;
typedef struct net_addr_ip4 {