Skip to content

Commit d4fb70b

Browse files
committed
fix(compat): version-aware systemd-networkd config key generation
Runtime detection of systemd version via networkctl --version. No new environment variables — detection happens on the running system at startup. - systemd >= 256: uses IPv4Forwarding=/IPv6Forwarding= (new keys) - systemd < 256: uses IPForward=yes (255 and earlier) - OtherInformation= is correct for all versions (OtherConfig was never a valid systemd key) Shipped .network templates use IPForward=yes for maximum compatibility (works on 255, deprecated-but-functional on 256+). Dynamic configs from rxnm-config-builder.sh use the runtime- detected constants.
1 parent 8dc5aba commit d4fb70b

5 files changed

Lines changed: 33 additions & 7 deletions

File tree

lib/rxnm-config-builder.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ build_network_config() {
121121

122122
printf "MulticastDNS=%s\nLLMNR=%s\n" "${mdns}" "${llmnr}"
123123
printf "LinkLocalAddressing=yes\nIPv6AcceptRA=yes\nConfigureWithoutCarrier=yes\n"
124-
printf "IPForward=yes\n"
124+
# shellcheck disable=SC2059
125+
printf "${RXNM_NETWORKD_KEY_IPFORWARD}\n"
125126

126127
if [ -n "$ipv6_privacy" ]; then
127128
printf "IPv6PrivacyExtensions=%s\n" "${ipv6_privacy}"
@@ -268,13 +269,15 @@ build_gateway_config() {
268269

269270
if [ "$share" = "true" ]; then
270271
# v255.8 Compliant Forwarding (NAT is handled externally by rxnm-system)
271-
printf "IPForward=yes\nIPv6SendRA=yes\n"
272+
# shellcheck disable=SC2059
273+
printf "${RXNM_NETWORKD_KEY_IPFORWARD}\nIPv6SendRA=yes\n"
272274
if [ "$ipv6_pd" != "no" ]; then printf "DHCPPrefixDelegation=yes\n"; fi
273275

274276
printf "Address=fd00:cafe:feed::a7ca:de/64\n"
275277

276278
printf "DHCPServer=yes\n\n[DHCPServer]\nPoolOffset=100\nEmitDNS=yes\nEmitRouter=yes\n"
277-
printf "[IPv6SendRA]\nManaged=no\nOtherConfig=no\n"
279+
# shellcheck disable=SC2059
280+
printf "[IPv6SendRA]\nManaged=no\n${RXNM_NETWORKD_KEY_RA_OTHER}=no\n"
278281
else
279282
printf "Address=fd00:cafe:feed::a7ca:de/64\n"
280283
printf "IPv6AcceptRA=no\nDHCPServer=yes\n\n[DHCPServer]\nEmitDNS=yes\nEmitRouter=no\n"

lib/rxnm-constants.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,25 @@ fi
9292

9393
: "${IWD_DBUS_MAX_KB:=512}"
9494

95+
# --- systemd-networkd Version-Aware Config Keys ---
96+
# IPForward= was deprecated in systemd 256, replaced by IPv4Forwarding=/IPv6Forwarding=.
97+
# Detect the running networkd version and emit the correct key for dynamic configs.
98+
# Shipped .network templates use IPForward= (works on all versions, deprecated warning on 256+).
99+
if [ -z "${RXNM_NETWORKD_KEY_IPFORWARD:-}" ]; then
100+
_sd_ver=""
101+
if command -v networkctl >/dev/null 2>&1; then
102+
_sd_ver=$(networkctl --version 2>/dev/null | awk '/^systemd / {print $2; exit}')
103+
fi
104+
_sd_ver="${_sd_ver:-255}"
105+
if [ "$_sd_ver" -ge 256 ] 2>/dev/null; then
106+
RXNM_NETWORKD_KEY_IPFORWARD="IPv4Forwarding=yes\nIPv6Forwarding=yes"
107+
else
108+
RXNM_NETWORKD_KEY_IPFORWARD="IPForward=yes"
109+
fi
110+
fi
111+
# OtherInformation= is correct for all systemd versions (OtherConfig was never valid)
112+
: "${RXNM_NETWORKD_KEY_RA_OTHER:=OtherInformation}"
113+
95114
# --- FD Reservations ---
96115
RXNM_FD_GLOBAL_LOCK=8
97116
RXNM_FD_IFACE_LOCK=9

usr/lib/systemd/network/69-wifi-p2p-go.network

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Description=Rocknix Wi-Fi P2P Group Owner
88
# Standard P2P subnet (Commonly used in Android/Linux P2P)
99
Address=192.168.49.1/24
1010
DHCPServer=yes
11-
# IP Forwarding (v255.8 compliant). NAT is handled externally by rxnm-system.
11+
# IP Forwarding. NAT is handled externally by rxnm-system.
12+
# Uses IPForward= for systemd 255 (ROCKNIX) compatibility.
1213
IPForward=yes
1314
# Ensure local name resolution works for the group
1415
MulticastDNS=no

usr/lib/systemd/network/70-bluetooth-pan.network

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Name=bnep*
66
Description=Rocknix Bluetooth PAN Host
77
Address=192.168.44.1/24
88
DHCPServer=yes
9-
# IP Forwarding (v255.8 compliant). NAT is handled externally by rxnm-system.
9+
# IP Forwarding. NAT is handled externally by rxnm-system.
10+
# Uses IPForward= for systemd 255 (ROCKNIX) compatibility.
11+
# systemd 256+ deprecates this in favour of IPv4Forwarding=/IPv6Forwarding=
1012
IPForward=yes
1113
# Disabled to avoid conflict with Avahi
1214
MulticastDNS=no

usr/lib/systemd/network/70-wifi-ap-share.network

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ LinkLocalAddressing=yes
1313
# ULA for local IPv6
1414
Address=fd00:a7c:ade:50::1/64
1515
IPv6SendRA=yes
16-
# IP Forwarding (v255.8 compliant). NAT is handled externally by rxnm-system.
16+
# IP Forwarding. NAT is handled externally by rxnm-system.
17+
# Uses IPForward= for systemd 255 (ROCKNIX) compatibility.
1718
IPForward=yes
1819
# Multicast handled by Avahi
1920
MulticastDNS=no
@@ -27,4 +28,4 @@ EmitRouter=yes
2728

2829
[IPv6SendRA]
2930
Managed=no
30-
OtherConfig=no
31+
OtherInformation=no

0 commit comments

Comments
 (0)