Revert "mac80211: pass hostapd control socket to mesh-mode supplicant"
[openwrt/openwrt.git] / package / kernel / mac80211 / files / lib / netifd / wireless / mac80211.sh
index cda6f9f438c89fb78a834c60251c13bd53a10eb6..bf9d52ae4203c294e25487f1678cfcd25e7a1dce 100644 (file)
@@ -429,6 +429,12 @@ mac80211_iw_interface_add() {
                rc="$?"
        }
 
+       [ "$rc" = 233 ] && {
+               # Device might not support virtual interfaces, so the interface never got deleted in the first place.
+               # Check if the interface already exists, and avoid failing in this case.
+               ip link show dev "$ifname" >/dev/null 2>/dev/null && rc=0
+       }
+
        [ "$rc" != 0 ] && wireless_setup_failed INTERFACE_CREATION_FAILED
        return $rc
 }
@@ -516,6 +522,12 @@ mac80211_setup_supplicant() {
        wpa_supplicant_run "$ifname" ${hostapd_ctrl:+-H $hostapd_ctrl}
 }
 
+mac80211_setup_supplicant_noctl() {
+       wpa_supplicant_prepare_interface "$ifname" nl80211 || return 1
+       wpa_supplicant_add_network "$ifname" "$freq" "$htmode"
+       wpa_supplicant_run "$ifname"
+}
+
 mac80211_setup_adhoc_htmode() {
        case "$htmode" in
                VHT20|HT20) ibss_htmode=HT20;;
@@ -617,16 +629,11 @@ mac80211_setup_vif() {
 
        case "$mode" in
                mesh)
-                       # authsae or wpa_supplicant
                        json_get_vars key
                        if [ -n "$key" ]; then
-                               if [ -e "/lib/wifi/authsae.sh" ]; then
-                                       . /lib/wifi/authsae.sh
-                                       authsae_start_interface || failed=1
-                               else
-                                       wireless_vif_parse_encryption
-                                       mac80211_setup_supplicant || failed=1
-                               fi
+                               wireless_vif_parse_encryption
+                               freq="$(get_freq "$phy" "$channel")"
+                               mac80211_setup_supplicant_noctl || failed=1
                        else
                                json_get_vars mesh_id mcast_rate
 
@@ -682,7 +689,8 @@ mac80211_setup_vif() {
                        wireless_vif_parse_encryption
                        mac80211_setup_adhoc_htmode
                        if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ]; then
-                               mac80211_setup_supplicant || failed=1
+                               freq="$(get_freq "$phy" "$channel")"
+                               mac80211_setup_supplicant_noctl || failed=1
                        else
                                mac80211_setup_adhoc
                        fi