From: Florian Maurer Date: Sun, 31 May 2026 20:14:38 +0000 (+0000) Subject: wifi-scripts: ucode: only set antenna when config changes X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0d747a8edbc48a72066feedfd937048874b19169;p=thirdparty%2Fopenwrt.git wifi-scripts: ucode: only set antenna when config changes mac80211's ieee80211_set_antenna() rejects calls with -EOPNOTSUPP once the radio is started (local->started == true). The spurious failure triggers a wpa_supplicant invocation in the error path, producing both a "command failed: Not supported (-122)" message and (where wpa_supplicant is not installed) a "/bin/sh: wpa_supplicant: not found" message in the log on every wifi reconfiguration. In this code path, reset_config() tears down all interfaces before the antenna is touched, so local->started is false exactly when the antenna config has changed. Skip the iw phy set antenna call otherwise, matching the behaviour of mainline OpenWrt's bash mac80211.sh. The trade-off is that we no longer re-assert the antenna mask on warm reconf if it was cleared out-of-band (e.g. by a driver reload); in practice drivers do not clear it mid-life. Also split the antenna details out of the generic "Configuring '${phy}' distance: ..." log line so it isn't claimed when the call was skipped. Assisted-by: Claude:claude-sonnet-4-6 Signed-off-by: Florian Maurer Link: https://github.com/openwrt/openwrt/pull/23607 Signed-off-by: Jonas Jelonek --- diff --git a/package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh b/package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh index 6230f902876..6f80b30d59f 100755 --- a/package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh +++ b/package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh @@ -83,7 +83,9 @@ function setup_phy(phy, config, data) { if (config.rxantenna == 'all') config.rxantenna = 0xffffffff; - if (config.txantenna != data?.txantenna || config.rxantenna != data?.rxantenna) + let antenna_changed = (config.txantenna != data?.txantenna || config.rxantenna != data?.rxantenna); + + if (antenna_changed) reset_config(phy, config.radio); netifd.set_data({ @@ -98,8 +100,11 @@ function setup_phy(phy, config, data) { else config.txpower = 'auto'; - log(`Configuring '${phy}' txantenna: ${config.txantenna}, rxantenna: ${config.rxantenna} distance: ${config.distance}`); - system(`iw phy ${phy} set antenna ${config.txantenna} ${config.rxantenna}`); + log(`Configuring '${phy}' distance: ${config.distance}`); + if (antenna_changed) { + log(`Setting antenna for '${phy}' txantenna: ${config.txantenna}, rxantenna: ${config.rxantenna}`); + system(`iw phy ${phy} set antenna ${config.txantenna} ${config.rxantenna}`); + } system(`iw phy ${phy} set distance ${config.distance}`); system(`iw phy ${phy} set txpower ${config.txpower}`);