netifd: fix start_disabled 'sh: bad number' in mac80211 setup (bug #19345)
[openwrt.git] / package / kernel / mac80211 / files / lib / netifd / wireless / mac80211.sh
index c7935b5..ec0966e 100644 (file)
@@ -42,6 +42,7 @@ drv_mac80211_init_device_config() {
                greenfield \
                short_gi_20 \
                short_gi_40 \
+               max_amsdu \
                dsss_cck_40
 }
 
@@ -54,6 +55,7 @@ drv_mac80211_init_iface_config() {
        config_add_int maxassoc
        config_add_int max_listen_int
        config_add_int dtim_period
+       config_add_int start_disabled
 
        # mesh
        config_add_string mesh_id
@@ -132,6 +134,7 @@ mac80211_hostapd_setup_base() {
                        short_gi_40:1 \
                        tx_stbc:1 \
                        rx_stbc:3 \
+                       max_amsdu:1 \
                        dsss_cck_40:1
 
                ht_cap_mask=0
@@ -152,6 +155,7 @@ mac80211_hostapd_setup_base() {
                        RX-STBC1:0x300:0x100:1 \
                        RX-STBC12:0x300:0x200:1 \
                        RX-STBC123:0x300:0x300:1 \
+                       MAX-AMSDU-7935:0x800::$max_amsdu \
                        DSSS_CCK-40:0x1000::$dsss_cck_40
 
                ht_capab="$ht_capab$ht_capab_flags"
@@ -311,12 +315,13 @@ mac80211_hostapd_setup_bss() {
        append hostapd_cfg "$type=$ifname" "$N"
 
        hostapd_set_bss_options hostapd_cfg "$vif" || return 1
-       json_get_vars wds dtim_period max_listen_int
+       json_get_vars wds dtim_period max_listen_int start_disabled
 
        set_default wds 0
+       set_default start_disabled 0
 
        [ "$wds" -gt 0 ] && append hostapd_cfg "wds_sta=1" "$N"
-       [ "$staidx" -gt 0 ] && append hostapd_cfg "start_disabled=1" "$N"
+       [ "$staidx" -gt 0 -o "$start_disabled" -eq 1 ] && append hostapd_cfg "start_disabled=1" "$N"
 
        cat >> /var/run/hostapd-$phy.conf <<EOF
 $hostapd_cfg
@@ -490,6 +495,38 @@ mac80211_setup_supplicant() {
        wpa_supplicant_run "$ifname" ${hostapd_ctrl:+-H $hostapd_ctrl}
 }
 
+mac80211_setup_adhoc_htmode() {
+       case "$htmode" in
+               VHT20|HT20) ibss_htmode=HT20;;
+               HT40*|VHT40|VHT80|VHT160)
+                       case "$hwmode" in
+                               a)
+                                       case "$(( ($channel / 4) % 2 ))" in
+                                               1) ibss_htmode="HT40+" ;;
+                                               0) ibss_htmode="HT40-";;
+                                       esac
+                               ;;
+                               *)
+                                       case "$htmode" in
+                                               HT40+) ibss_htmode="HT40+";;
+                                               HT40-) ibss_htmode="HT40-";;
+                                               *)
+                                                       if [ "$channel" -lt 7 ]; then
+                                                               ibss_htmode="HT40+"
+                                                       else
+                                                               ibss_htmode="HT40-"
+                                                       fi
+                                               ;;
+                                       esac
+                               ;;
+                       esac
+                       [ "$auto_channel" -gt 0 ] && ibss_htmode="HT40+"
+               ;;
+               *) ibss_htmode="" ;;
+       esac
+
+}
+
 mac80211_setup_adhoc() {
        json_get_vars bssid ssid key mcast_rate
 
@@ -523,35 +560,6 @@ mac80211_setup_adhoc() {
        mcval=
        [ -n "$mcast_rate" ] && wpa_supplicant_add_rate mcval "$mcast_rate"
 
-       case "$htmode" in
-               VHT20|HT20) ibss_htmode=HT20;;
-               HT40*|VHT40|VHT80|VHT160)
-                       case "$hwmode" in
-                               a)
-                                       case "$(( ($channel / 4) % 2 ))" in
-                                               1) ibss_htmode="HT40+" ;;
-                                               0) ibss_htmode="HT40-";;
-                                       esac
-                               ;;
-                               *)
-                                       case "$htmode" in
-                                               HT40+) ibss_htmode="HT40+";;
-                                               HT40-) ibss_htmode="HT40-";;
-                                               *)
-                                                       if [ "$channel" -lt 7 ]; then
-                                                               ibss_htmode="HT40+"
-                                                       else
-                                                               ibss_htmode="HT40-"
-                                                       fi
-                                               ;;
-                                       esac
-                               ;;
-                       esac
-                       [ "$auto_channel" -gt 0 ] && ibss_htmode="HT40+"
-               ;;
-               *) ibss_htmode="" ;;
-       esac
-
        iw dev "$ifname" ibss join "$ssid" $freq $ibss_htmode fixed-freq $bssid \
                ${beacon_int:+beacon-interval $beacon_int} \
                ${brstr:+basic-rates $brstr} \
@@ -602,6 +610,7 @@ mac80211_setup_vif() {
                ;;
                adhoc)
                        wireless_vif_parse_encryption
+                       mac80211_setup_adhoc_htmode
                        if [ "$wpa" -gt 0 -o "$auto_channel" -gt 0 ]; then
                                mac80211_setup_supplicant || failed=1
                        else