mac80211: do not try to setup hostapd-managed interfaces.
authorOldřich Jedlička <oldium.pro@gmail.com>
Mon, 16 Mar 2020 20:00:51 +0000 (21:00 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Fri, 20 Mar 2020 21:55:17 +0000 (21:55 +0000)
For virtual access points (when multiple SSIDs are used for one
physical AP), there exist one physical network interface and
multiple virtual interfaces, which are fully under control of
hostapd. When networking is setup, the script
`/lib/netifd/wireless/mac80211.sh` is called, which tries to bring
the interface up by a call to `ip link set dev <iface> up`. This
call might fail for virtual APs, because the virtual interface
might not have been created by hostapd yet. There are some artifical
delays in the script most probably to handle this, but when DFS
channel availability check on 5GHz band is issued, hostapd can
delay creating virtual interfaces by a minute.

In order to fix this (or work around it), do not try to bring the
interface up (this is responsibility of hostapd anyway) and
do not try to set txpower on the virtual interface.

Fixes FS#2698.

Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh

index f22730c..f59c498 100644 (file)
@@ -533,6 +533,7 @@ mac80211_prepare_vif() {
 
                        NEWAPLIST="${NEWAPLIST}$ifname "
                        [ -n "$hostapd_ctrl" ] || {
 
                        NEWAPLIST="${NEWAPLIST}$ifname "
                        [ -n "$hostapd_ctrl" ] || {
+                               ap_ifname="${ifname}"
                                hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd/$ifname}"
                        }
                ;;
                                hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd/$ifname}"
                        }
                ;;
@@ -753,13 +754,15 @@ mac80211_setup_vif() {
        json_get_var vif_enable enable 1
 
        [ "$vif_enable" = 1 ] || action=down
        json_get_var vif_enable enable 1
 
        [ "$vif_enable" = 1 ] || action=down
-       logger ip link set dev "$ifname" $action
-       ip link set dev "$ifname" "$action" || {
-               wireless_setup_vif_failed IFUP_ERROR
-               json_select ..
-               return
-       }
-       [ -z "$vif_txpower" ] || iw dev "$ifname" set txpower fixed "${vif_txpower%%.*}00"
+       if [ "$mode" != "ap" ] || [ "$ifname" = "$ap_ifname" ]; then
+               logger ip link set dev "$ifname" $action
+               ip link set dev "$ifname" "$action" || {
+                       wireless_setup_vif_failed IFUP_ERROR
+                       json_select ..
+                       return
+               }
+               [ -z "$vif_txpower" ] || iw dev "$ifname" set txpower fixed "${vif_txpower%%.*}00"
+       fi
 
        case "$mode" in
                mesh)
 
        case "$mode" in
                mesh)
@@ -924,6 +927,7 @@ drv_mac80211_setup() {
 
        has_ap=
        hostapd_ctrl=
 
        has_ap=
        hostapd_ctrl=
+       ap_ifname=
        hostapd_noscan=
        for_each_interface "ap" mac80211_check_ap
 
        hostapd_noscan=
        for_each_interface "ap" mac80211_check_ap