]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
wifi-scripts: ucode: only set antenna when config changes
authorFlorian Maurer <fmaurer@disroot.org>
Sun, 31 May 2026 20:14:38 +0000 (20:14 +0000)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Mon, 29 Jun 2026 07:26:56 +0000 (09:26 +0200)
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 <fmaurer@disroot.org>
Link: https://github.com/openwrt/openwrt/pull/23607
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
package/network/config/wifi-scripts/files-ucode/lib/netifd/wireless/mac80211.sh

index 6230f9028768e788a4fe5faa7ab6ba217621b517..6f80b30d59fc09cadb0efe07245ddf572123ea18 100755 (executable)
@@ -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}`);