mac80211: fix applying tx/rx antenna changes afer hostapd reload change
authorFelix Fietkau <nbd@nbd.name>
Tue, 8 Aug 2023 18:12:11 +0000 (20:12 +0200)
committerFelix Fietkau <nbd@nbd.name>
Tue, 8 Aug 2023 18:12:13 +0000 (20:12 +0200)
Tear down all interfaces if the antenna settings change, so that the
capabilities can be recalculated properly

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh

index a2a7bdba2555901487b714fd4b12bf9cd8ccdf8c..d87a2c63122c3f59429eb06821519bd5b95c8001 100644 (file)
@@ -1089,14 +1089,18 @@ drv_mac80211_setup() {
        json_get_values scan_list scan_list
        json_select ..
 
+       json_select data && {
+               json_get_var prev_rxantenna rxantenna
+               json_get_var prev_txantenna txantenna
+               json_select ..
+       }
+
        find_phy || {
                echo "Could not find PHY for device '$1'"
                wireless_set_retry 0
                return 1
        }
 
-       wireless_set_data phy="$phy"
-
        local wdev
        local cwdev
        local found
@@ -1130,6 +1134,9 @@ drv_mac80211_setup() {
        [ "$txantenna" = "all" ] && txantenna=0xffffffff
        [ "$rxantenna" = "all" ] && rxantenna=0xffffffff
 
+       [ "$rxantenna" = "$prev_rxantenna" -a "$txantenna" = "$prev_txantenna" ] || mac80211_reset_config "$phy"
+       wireless_set_data phy="$phy" txantenna="$txantenna" rxantenna="$rxantenna"
+
        iw phy "$phy" set antenna $txantenna $rxantenna >/dev/null 2>&1
        iw phy "$phy" set antenna_gain $antenna_gain >/dev/null 2>&1
        iw phy "$phy" set distance "$distance" >/dev/null 2>&1