[1/9] hostapd: Force setting reg domain before hostapd starts

Message ID 20260429194934.863108-1-michael.tremer@ipfire.org
State New
Headers
Series [1/9] hostapd: Force setting reg domain before hostapd starts |

Commit Message

Michael Tremer 29 Apr 2026, 7:49 p.m. UTC
When the system boots up, it could happen that hostapd didn't come up
the first time:

Apr 28 15:18:10 ipfire-test hostapd: green0: interface state UNINITIALIZED->COUNTRY_UPDATE
Apr 28 15:18:10 ipfire-test hostapd: ACS: Automatic channel selection started, this may take a bit
Apr 28 15:18:10 ipfire-test hostapd: ACS: No available channels found
Apr 28 15:18:10 ipfire-test hostapd: green0: IEEE 802.11 Configured channel (0) or frequency (0) (secondary_channel=1) not found from the channel list of the current mode (2) IEEE 802.11a
Apr 28 15:18:10 ipfire-test hostapd: green0: IEEE 802.11 Hardware does not support configured channel
Apr 28 15:18:10 ipfire-test hostapd: Could not select hw_mode and channel. (-3)
Apr 28 15:18:10 ipfire-test hostapd: green0: interface state COUNTRY_UPDATE->DISABLED
Apr 28 15:18:10 ipfire-test hostapd: green0: AP-DISABLED
Apr 28 15:18:10 ipfire-test hostapd: green0: interface state DISABLED->DISABLED
Apr 28 15:18:10 ipfire-test hostapd: green0: AP-DISABLED
Apr 28 15:18:10 ipfire-test hostapd: green0: CTRL-EVENT-TERMINATING
Apr 28 15:18:10 ipfire-test hostapd: hostapd_free_hapd_data: Interface green0 wasn't started
Apr 28 15:18:10 ipfire-test hostapd: nl80211: deinit ifname=green0 disabled_11b_rates=0

A second start always was successful. By explicitely setting the reg
domain this problem is being worked around.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 src/initscripts/packages/hostapd | 5 +++++
 1 file changed, 5 insertions(+)
  

Patch

diff --git a/src/initscripts/packages/hostapd b/src/initscripts/packages/hostapd
index 93ddae72f..583a8eba4 100644
--- a/src/initscripts/packages/hostapd
+++ b/src/initscripts/packages/hostapd
@@ -685,6 +685,11 @@  case "${1}" in
 			exit 1
 		fi
 
+		# Force setting the regulatory domain
+		if [ -n "${CONFIG["COUNTRY"]}" ]; then
+			iw reg set "${CONFIG["COUNTRY"]}" &>/dev/null
+		fi
+
 		# Compose the command line
 		args=(
 			/usr/bin/hostapd