Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bird2: replace gcc flag workaround with patch fixing alignment issues #1097

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions bird2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ protocols, telling BIRD to show various information, telling it to show
a routing table filtered by a filter, or asking BIRD to reconfigure.
endef

ifeq ($(ARCH),arm)
TARGET_CFLAGS+=-mno-unaligned-access
endif

CONFIGURE_ARGS += --disable-libssh

define Package/bird2/conffiles
Expand Down
44 changes: 44 additions & 0 deletions bird2/patches/001-fix-net_addr-alignment-for-armv7.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From b4e8108cb2995f45d63105f6b179d8e4a155eab5 Mon Sep 17 00:00:00 2001
From: Nick Hainke <[email protected]>
Date: Tue, 17 Dec 2024 23:38:45 +0100
Subject: [PATCH] Fix net_addr alignment for armv7

The patch originates from the mailing list discussion [0].

On armv7 platforms, the `net_addr` structure caused alignment issues due
to the use of `u64 align[0]`, which requires 8-byte alignment. This led
to crashes on systems with stricter alignment rules.

This patch changes the alignment to `u32 align[0]`, which resolves the
crashes. However, this change may still cause issues with VPN network types
that rely on stricter alignment.

Previously, we used a workaround with `-mno-unaligned-access` [1,2],
which prevents unaligned memory crashes but comes at the cost of reduced
performance, larger code size, and missed hardware optimizations. Applying
this patch is a better solution, even if VPN network types may still face
problems. Alignment issues are expected to be properly resolved in the
upcoming BIRD 3 release, so this patch will not be merged into upstream BIRD
since it also originates from the BIRD mailing list discussion.

[0] - http://trubka.network.cz/pipermail/bird-users/2024-December/017957.html
[1] - https://github.com/freifunk-berlin/falter-packages/commit/fcce390fc57b44593fe969f1063c6ba711fc7f9b
[2] - https://github.com/openwrt/routing/commit/0209a1f3be5d0d227c34c7e73ff779ef7dcc533e

Signed-off-by: Nick Hainke <[email protected]>
---
---
lib/net.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/lib/net.h
+++ b/lib/net.h
@@ -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 {
Loading