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>
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({
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}`);