mac80211: Re-enable encrypted 11s meshpoint
[openwrt/openwrt.git] / package / kernel / mac80211 / files / lib / netifd / wireless / mac80211.sh
index 703609b1475449c4c70a50fe305db2fbab4b21ce..70def756b2d5dc0f361a293f12dea5782ff8b6fe 100644 (file)
@@ -518,13 +518,17 @@ mac80211_prepare_vif() {
 
 mac80211_setup_supplicant() {
        wpa_supplicant_prepare_interface "$ifname" nl80211 || return 1
-       wpa_supplicant_add_network "$ifname"
+       if [ "$mode" = "sta" ]; then
+               wpa_supplicant_add_network "$ifname"
+       else
+               wpa_supplicant_add_network "$ifname" "$freq" "$htmode" "$noscan"
+       fi
        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"
+       wpa_supplicant_add_network "$ifname" "$freq" "$htmode" "$noscan"
        wpa_supplicant_run "$ifname"
 }
 
@@ -629,16 +633,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_noctl || failed=1
-                               fi
+                       wireless_vif_parse_encryption
+                       if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ] || chan_is_dfs "$phy" "$channel"; then
+                               freq="$(get_freq "$phy" "$channel")"
+                               mac80211_setup_supplicant || failed=1
                        else
                                json_get_vars mesh_id mcast_rate
 
@@ -694,6 +693,7 @@ mac80211_setup_vif() {
                        wireless_vif_parse_encryption
                        mac80211_setup_adhoc_htmode
                        if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ]; then
+                               freq="$(get_freq "$phy" "$channel")"
                                mac80211_setup_supplicant_noctl || failed=1
                        else
                                mac80211_setup_adhoc
@@ -714,6 +714,13 @@ get_freq() {
        iw "$phy" info | grep -E -m1 "(\* ${chan:-....} MHz${chan:+|\\[$chan\\]})" | grep MHz | awk '{print $2}'
 }
 
+chan_is_dfs() {
+       local phy="$1"
+       local chan="$2"
+       iw "$phy" info | grep -E -m1 "(\* ${chan:-....} MHz${chan:+|\\[$chan\\]})" | grep -q "MHz.*radar detection"
+       return $!
+}
+
 mac80211_interface_cleanup() {
        local phy="$1"