Skip to content

Commit d5aa32c

Browse files
bird2: replace gcc flag workaround with patch fixing alignment issues
Previously, we used the -mno-unaligned-access flag to instruct GCC to forbid unaligned memory access on arm processors. This was a workaround for alignment issues that caused crashes. This commit imports a patch from the BIRD mailing list discussion [0] that resolves the alignment issue by modifying the net_addr structure, removing the need for the GCC flag. The patch addresses the alignment problem more efficiently and avoids the performance, code size, and hardware optimization drawbacks of the flag. [0] - http://trubka.network.cz/pipermail/bird-users/2024-December/017957.html Signed-off-by: Nick Hainke <[email protected]>
1 parent 478626b commit d5aa32c

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From b4e8108cb2995f45d63105f6b179d8e4a155eab5 Mon Sep 17 00:00:00 2001
2+
From: Nick Hainke <[email protected]>
3+
Date: Tue, 17 Dec 2024 23:38:45 +0100
4+
Subject: [PATCH] Fix net_addr alignment for armv7
5+
6+
The patch originates from the mailing list discussion [0].
7+
8+
On armv7 platforms, the `net_addr` structure caused alignment issues due
9+
to the use of `u64 align[0]`, which requires 8-byte alignment. This led
10+
to crashes on systems with stricter alignment rules.
11+
12+
This patch changes the alignment to `u32 align[0]`, which resolves the
13+
crashes. However, this change may still cause issues with VPN network types
14+
that rely on stricter alignment.
15+
16+
Previously, we used a workaround with `-mno-unaligned-access` [1,2],
17+
which prevents unaligned memory crashes but comes at the cost of reduced
18+
performance, larger code size, and missed hardware optimizations. Applying
19+
this patch is a better solution, even if VPN network types may still face
20+
problems. Alignment issues are expected to be properly resolved in the
21+
upcoming BIRD 3 release, so this patch will not be merged into upstream BIRD
22+
since it also originates from the BIRD mailing list discussion.
23+
24+
[0] - http://trubka.network.cz/pipermail/bird-users/2024-December/017957.html
25+
[1] - https://github.com/freifunk-berlin/falter-packages/commit/fcce390fc57b44593fe969f1063c6ba711fc7f9b
26+
[2] - https://github.com/openwrt/routing/commit/0209a1f3be5d0d227c34c7e73ff779ef7dcc533e
27+
28+
Signed-off-by: Nick Hainke <[email protected]>
29+
---
30+
---
31+
lib/net.h | 2 +-
32+
1 file changed, 1 insertion(+), 1 deletion(-)
33+
34+
--- a/lib/net.h
35+
+++ b/lib/net.h
36+
@@ -51,7 +51,7 @@ typedef struct net_addr {
37+
u8 pxlen;
38+
u16 length;
39+
u8 data[20];
40+
- u64 align[0];
41+
+ u32 align[0];
42+
} net_addr;
43+
44+
typedef struct net_addr_ip4 {

0 commit comments

Comments
 (0)