From: Daniel Golle Date: Fri, 20 Apr 2018 05:41:03 +0000 (+0200) Subject: hostapd: fix encrypted mesh channel settings X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a4322eba2b129adde45e3f7ac6c3805889623dd5;p=librecmc%2Flibrecmc.git hostapd: fix encrypted mesh channel settings Import two patches from Peter Oh to allow setting channel bandwidth in the way it already works for managed interfaces. This fixes mesh interfaces on 802.11ac devices always coming up in VHT80 mode. Add a patch to allow HT40 also on 2.4GHz if noscan option is set, which also skips secondary channel scan just like noscan works in AP mode. This time also make sure to add all files to the patch before committing it... Signed-off-by: Daniel Golle --- diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile index 1dbad344e7..fef0fa8e57 100644 --- a/package/network/services/hostapd/Makefile +++ b/package/network/services/hostapd/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=hostapd -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE_URL:=http://w1.fi/hostap.git PKG_SOURCE_PROTO:=git diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh index c3640689da..d3633a2a55 100644 --- a/package/network/services/hostapd/files/hostapd.sh +++ b/package/network/services/hostapd/files/hostapd.sh @@ -647,6 +647,7 @@ wpa_supplicant_add_network() { local ifname="$1" local freq="$2" local htmode="$3" + local noscan="$4" _wpa_supplicant_common "$1" wireless_vif_parse_encryption @@ -682,6 +683,7 @@ wpa_supplicant_add_network() { append network_data "mode=5" "$N$T" [ -n "$mesh_fwding" ] && append network_data "mesh_fwding=${mesh_fwding}" "$N$T" [ -n "$channel" ] && wpa_supplicant_set_fixed_freq "$freq" "$htmode" + [ "$noscan" = "1" ] && append network_data "noscan=1" "$N$T" append wpa_key_mgmt "SAE" scan_ssid="" } diff --git a/package/network/services/hostapd/patches/031-mesh-add-VHT_CHANWIDTH_USE_HT-to-max_oper_chwidth.patch b/package/network/services/hostapd/patches/031-mesh-add-VHT_CHANWIDTH_USE_HT-to-max_oper_chwidth.patch new file mode 100644 index 0000000000..30003116e9 --- /dev/null +++ b/package/network/services/hostapd/patches/031-mesh-add-VHT_CHANWIDTH_USE_HT-to-max_oper_chwidth.patch @@ -0,0 +1,58 @@ +From 838225f2319348e430b553fd9bb3680bd7434ae3 Mon Sep 17 00:00:00 2001 +From: Peter Oh +Date: Wed, 18 Apr 2018 14:14:18 -0700 +Subject: [PATCH 1/2] mesh: add VHT_CHANWIDTH_USE_HT to max_oper_chwidth + +Channel width in VHT mode refers HT capability when +the width goes down to below 80MHz, hence add checking +HT channel width to its max operation channel width. +So that mesh has capable to select bandwidth below 80Mhz. + +Signed-off-by: Peter Oh +--- + wpa_supplicant/config.c | 1 + + wpa_supplicant/config_ssid.h | 1 + + wpa_supplicant/wpa_supplicant.c | 3 +++ + 3 files changed, 5 insertions(+) + +diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c +index f65bbb02f..7e8f014cc 100644 +--- a/wpa_supplicant/config.c ++++ b/wpa_supplicant/config.c +@@ -2798,6 +2798,7 @@ void wpa_config_set_network_defaults(struct wpa_ssid *ssid) + ssid->mka_priority = DEFAULT_PRIO_NOT_KEY_SERVER; + #endif /* CONFIG_MACSEC */ + ssid->mac_addr = -1; ++ ssid->max_oper_chwidth = (u8)DEFAULT_MAX_OPER_CHWIDTH; + } + + +diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h +index 9fd56c32f..2ddb777b2 100644 +--- a/wpa_supplicant/config_ssid.h ++++ b/wpa_supplicant/config_ssid.h +@@ -37,6 +37,7 @@ + #define DEFAULT_AMPDU_FACTOR -1 /* no change */ + #define DEFAULT_AMPDU_DENSITY -1 /* no change */ + #define DEFAULT_USER_SELECTED_SIM 1 ++#define DEFAULT_MAX_OPER_CHWIDTH -1 + + struct psk_list_entry { + struct dl_list list; +diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c +index dcd787bec..ca893f942 100644 +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -2293,6 +2293,9 @@ void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, + vht_caps |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; + seg0 = 114; + } ++ } else if (ssid->max_oper_chwidth == VHT_CHANWIDTH_USE_HT) { ++ chwidth = VHT_CHANWIDTH_USE_HT; ++ seg0 = vht80[j] + 2; + } + + if (hostapd_set_freq_params(&vht_freq, mode->mode, freq->freq, +-- +2.17.0 + diff --git a/package/network/services/hostapd/patches/032-mesh-implement-use-of-VHT20-config-in-mesh-mode.patch b/package/network/services/hostapd/patches/032-mesh-implement-use-of-VHT20-config-in-mesh-mode.patch new file mode 100644 index 0000000000..3bd6eaf340 --- /dev/null +++ b/package/network/services/hostapd/patches/032-mesh-implement-use-of-VHT20-config-in-mesh-mode.patch @@ -0,0 +1,87 @@ +From 24fc73b2470ff79cd8c92e029ca785c8e95a204c Mon Sep 17 00:00:00 2001 +From: Peter Oh +Date: Wed, 18 Apr 2018 14:14:19 -0700 +Subject: [PATCH 2/2] mesh: implement use of VHT20 config in mesh mode + +mesh in VHT mode is supposed to be able to use any bandwidth +that 11ac supports, but we don't have a way to set VHT20 +although there are parameters that are supposed to be used. +This patch along with the patch of +"mesh: add VHT_CHANWIDTH_USE_HT to max_oper_chwidth" makes mesh +available to use of any bandwidth using combination of +existing parameters like below shown. + +VHT80: + default + do not set any parameters +VHT40: + max_oper_chwidth = 0 +VHT20: + max_oper_chwidth=0 + disable_ht40=1 +HT40: + disable_vht = 1 +HT20: + disable_ht40 = 1 +disable HT: + disable_ht = 1 + +Signed-off-by: Peter Oh +--- + wpa_supplicant/wpa_supplicant.c | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c +index ca893f942..8429cfd43 100644 +--- a/wpa_supplicant/wpa_supplicant.c ++++ b/wpa_supplicant/wpa_supplicant.c +@@ -2132,9 +2132,15 @@ void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, + if (pri_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR)) + return; + ++ freq->channel = pri_chan->chan; ++ + #ifdef CONFIG_HT_OVERRIDES +- if (ssid->disable_ht40) +- return; ++ if (ssid->disable_ht40) { ++ if (ssid->disable_vht) ++ return; ++ else ++ goto skip_ht40; ++ } + #endif /* CONFIG_HT_OVERRIDES */ + + /* Check/setup HT40+/HT40- */ +@@ -2159,8 +2165,6 @@ void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, + if (sec_chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_NO_IR)) + return; + +- freq->channel = pri_chan->chan; +- + if (ht40 == -1) { + if (!(pri_chan->flag & HOSTAPD_CHAN_HT40MINUS)) + return; +@@ -2204,6 +2208,7 @@ void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, + wpa_scan_results_free(scan_res); + } + ++skip_ht40: + wpa_printf(MSG_DEBUG, + "IBSS/mesh: setup freq channel %d, sec_channel_offset %d", + freq->channel, freq->sec_channel_offset); +@@ -2295,7 +2300,10 @@ void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s, + } + } else if (ssid->max_oper_chwidth == VHT_CHANWIDTH_USE_HT) { + chwidth = VHT_CHANWIDTH_USE_HT; +- seg0 = vht80[j] + 2; ++ if (ssid->disable_ht40) ++ seg0 = 0; ++ else ++ seg0 = vht80[j] + 2; + } + + if (hostapd_set_freq_params(&vht_freq, mode->mode, freq->freq, +-- +2.17.0 + diff --git a/package/network/services/hostapd/patches/301-mesh-noscan.patch b/package/network/services/hostapd/patches/301-mesh-noscan.patch new file mode 100644 index 0000000000..09b67a392b --- /dev/null +++ b/package/network/services/hostapd/patches/301-mesh-noscan.patch @@ -0,0 +1,78 @@ +Index: hostapd-2018-04-09-fa617ee6/wpa_supplicant/config.c +=================================================================== +--- hostapd-2018-04-09-fa617ee6.orig/wpa_supplicant/config.c ++++ hostapd-2018-04-09-fa617ee6/wpa_supplicant/config.c +@@ -2216,6 +2216,7 @@ static const struct parse_data ssid_fiel + #else /* CONFIG_MESH */ + { INT_RANGE(mode, 0, 4) }, + #endif /* CONFIG_MESH */ ++ { INT_RANGE(noscan, 0, 1) }, + { INT_RANGE(proactive_key_caching, 0, 1) }, + { INT_RANGE(disabled, 0, 2) }, + { STR(id_str) }, +Index: hostapd-2018-04-09-fa617ee6/wpa_supplicant/config_file.c +=================================================================== +--- hostapd-2018-04-09-fa617ee6.orig/wpa_supplicant/config_file.c ++++ hostapd-2018-04-09-fa617ee6/wpa_supplicant/config_file.c +@@ -816,6 +816,7 @@ static void wpa_config_write_network(FIL + #endif /* IEEE8021X_EAPOL */ + INT(mode); + INT(no_auto_peer); ++ INT(noscan); + INT(mesh_fwding); + INT(frequency); + INT(fixed_freq); +Index: hostapd-2018-04-09-fa617ee6/wpa_supplicant/mesh.c +=================================================================== +--- hostapd-2018-04-09-fa617ee6.orig/wpa_supplicant/mesh.c ++++ hostapd-2018-04-09-fa617ee6/wpa_supplicant/mesh.c +@@ -287,6 +287,8 @@ static int wpa_supplicant_mesh_init(stru + frequency); + goto out_free; + } ++ if (ssid->noscan) ++ conf->noscan = 1; + if (ssid->ht40) + conf->secondary_channel = ssid->ht40; + if (conf->hw_mode == HOSTAPD_MODE_IEEE80211A && ssid->vht) { +Index: hostapd-2018-04-09-fa617ee6/wpa_supplicant/wpa_supplicant.c +=================================================================== +--- hostapd-2018-04-09-fa617ee6.orig/wpa_supplicant/wpa_supplicant.c ++++ hostapd-2018-04-09-fa617ee6/wpa_supplicant/wpa_supplicant.c +@@ -2024,12 +2024,12 @@ void ibss_mesh_setup_freq(struct wpa_sup + { + enum hostapd_hw_mode hw_mode; + struct hostapd_hw_modes *mode = NULL; +- int ht40plus[] = { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, ++ int ht40plus[] = { 1, 2, 3, 4, 5, 6, 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, + 184, 192 }; + int vht80[] = { 36, 52, 100, 116, 132, 149 }; + struct hostapd_channel_data *pri_chan = NULL, *sec_chan = NULL; + u8 channel; +- int i, chan_idx, ht40 = -1, res, obss_scan = 1; ++ int i, chan_idx, ht40 = -1, res, obss_scan = !(ssid->noscan); + unsigned int j, k; + struct hostapd_freq_params vht_freq; + int chwidth, seg0, seg1; +@@ -2099,7 +2099,7 @@ void ibss_mesh_setup_freq(struct wpa_sup + return; + + /* Setup higher BW only for 5 GHz */ +- if (mode->mode != HOSTAPD_MODE_IEEE80211A) ++ if (mode->mode != HOSTAPD_MODE_IEEE80211A && !(ssid->noscan)) + return; + + for (chan_idx = 0; chan_idx < mode->num_channels; chan_idx++) { +Index: hostapd-2018-04-09-fa617ee6/wpa_supplicant/config_ssid.h +=================================================================== +--- hostapd-2018-04-09-fa617ee6.orig/wpa_supplicant/config_ssid.h ++++ hostapd-2018-04-09-fa617ee6/wpa_supplicant/config_ssid.h +@@ -835,6 +835,8 @@ struct wpa_ssid { + */ + int no_auto_peer; + ++ int noscan; ++ + /** + * mesh_rssi_threshold - Set mesh parameter mesh_rssi_threshold (dBm) + *