mac80211: properly setup mesh interface
authorDaniel Golle <daniel@makrotopia.org>
Sun, 13 May 2018 03:20:39 +0000 (05:20 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 14 May 2018 07:48:58 +0000 (09:48 +0200)
Setup wpa_supplicant for encrypted mesh or when using DFS channels and
adjust interface setup to pass fixed frequency for mesh mode.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
package/kernel/mac80211/Makefile
package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh

index dc198eb5426c4f778d47337e6ac98ef538eda2bb..499de2fd4edf833152873d0a07d192a99ea0f4fd 100644 (file)
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
 PKG_NAME:=mac80211
 
 PKG_VERSION:=2017-11-01
-PKG_RELEASE:=5
+PKG_RELEASE:=6
 PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
 PKG_HASH:=8437ab7886b988c8152e7a4db30b7f41009e49a3b2cb863edd05da1ecd7eb05a
 
index 16e32a91a482c86334cfb28f71e34f956a9684f6..dbe4aac7d78832fdd8005b539be6bb1af0eb915d 100644 (file)
@@ -518,7 +518,11 @@ 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}
 }
 
@@ -630,10 +634,10 @@ mac80211_setup_vif() {
        case "$mode" in
                mesh)
                        json_get_vars key
-                       if [ -n "$key" ]; then
+                       if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ] || chan_is_dfs "$phy" "$channel"; then
                                wireless_vif_parse_encryption
                                freq="$(get_freq "$phy" "$channel")"
-                               mac80211_setup_supplicant_noctl || failed=1
+                               mac80211_setup_supplicant || failed=1
                        else
                                json_get_vars mesh_id mcast_rate
 
@@ -710,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"