diff mbox series

[v2] hostapd: enable background scanning in wpa_supplicant_full

Message ID 20200909200032.3662-1-avalentin@marcant.net
State Changes Requested
Delegated to: Daniel Golle
Headers show
Series [v2] hostapd: enable background scanning in wpa_supplicant_full | expand

Commit Message

Andre Valentin Sept. 9, 2020, 8 p.m. UTC
Activation of autoscanning enables a a wifi client to select the best
accesspoint based on rssi.

This feature is useful in case you have multiple access points in your range
and you do not want to stick the client on the first one it connected to.
Especially when used with 802.11r this allows seamless transition to the
optimal accesspoints.

Setting the config value bgscan to -65 will tell wpa_supplicant to try to
connect to an access points with better rssi.

Example config:
config wifi-iface 'default_radio1'
	option device 'radio1'
	option mode 'sta'
	option ssid 'openwrt'
	option encryption 'psk2'
	option key 'mykey'
	option network 'wlan'
	option roam_rssi_threshold '-65'

The ipk sizes for mipsel_24kc change like this:
old:
wpad-openssl_2020-06-08-5a8b3662-4_mipsel_24kc.ipk 550133

new:
wpad-openssl_2020-06-08-5a8b3662-5_mipsel_24kc.ipk 551961

Signed-off-by: André Valentin <avalentin@marcant.net>
---
 package/network/services/hostapd/files/hostapd.sh          		| 7 +++++++
 package/network/services/hostapd/files/wpa_supplicant-full.config      | 6 +++---
 package/network/services/hostapd/Makefile				| 1 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

Comments

Andre Valentin Sept. 16, 2020, 6:41 p.m. UTC | #1
Hello!

Could someone please take care of this little snippet?

Kind regards,

André
Am 09.09.20 um 22:00 schrieb André Valentin:
> Activation of autoscanning enables a a wifi client to select the best
> accesspoint based on rssi.
> 
> This feature is useful in case you have multiple access points in your range
> and you do not want to stick the client on the first one it connected to.
> Especially when used with 802.11r this allows seamless transition to the
> optimal accesspoints.
> 
> Setting the config value bgscan to -65 will tell wpa_supplicant to try to
> connect to an access points with better rssi.
> 
> Example config:
> config wifi-iface 'default_radio1'
> 	option device 'radio1'
> 	option mode 'sta'
> 	option ssid 'openwrt'
> 	option encryption 'psk2'
> 	option key 'mykey'
> 	option network 'wlan'
> 	option roam_rssi_threshold '-65'
> 
> The ipk sizes for mipsel_24kc change like this:
> old:
> wpad-openssl_2020-06-08-5a8b3662-4_mipsel_24kc.ipk 550133
> 
> new:
> wpad-openssl_2020-06-08-5a8b3662-5_mipsel_24kc.ipk 551961
> 
> Signed-off-by: André Valentin <avalentin@marcant.net>
> ---
>  package/network/services/hostapd/files/hostapd.sh          		| 7 +++++++
>  package/network/services/hostapd/files/wpa_supplicant-full.config      | 6 +++---
>  package/network/services/hostapd/Makefile				| 1 +-
>  3 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
> index 88113cd7ce..85299234c2 100644
> --- a/package/network/services/hostapd/files/hostapd.sh
> +++ b/package/network/services/hostapd/files/hostapd.sh
> @@ -272,6 +272,8 @@ hostapd_common_add_bss_config() {
>  	config_add_array operator_icon
>  	config_add_array hs20_conn_capab
>  	config_add_string osu_ssid hs20_wan_metrics hs20_operating_class hs20_t_c_filename hs20_t_c_timestamp
> +
> +	config_add_string roam_rssi_threshold
>  }
>  
>  hostapd_set_vlan_file() {
> @@ -1178,6 +1180,11 @@ wpa_supplicant_add_network() {
>  	[ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
>  	[ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
>  
> +	[ -n "$roam_rssi_threshold" ] && {
> +		json_get_vars roam_rssi_threshold
> +		append network_data "bgscan=\"simple:120:${roam_rssi_threshold}:600\"" "$N$T"
> +	}
> +
>  	[ -n "$basic_rate" ] && {
>  		local br rate_list=
>  		for br in $basic_rate; do
> diff --git a/package/network/services/hostapd/files/wpa_supplicant-full.config b/package/network/services/hostapd/files/wpa_supplicant-full.config
> index 982f4d5534..d39ee74a8d 100644
> --- a/package/network/services/hostapd/files/wpa_supplicant-full.config
> +++ b/package/network/services/hostapd/files/wpa_supplicant-full.config
> @@ -527,9 +527,9 @@ CONFIG_WNM=y
>  #
>  # Enabling directly a module will enable autoscan support.
>  # For exponential module:
> -#CONFIG_AUTOSCAN_EXPONENTIAL=y
> +CONFIG_AUTOSCAN_EXPONENTIAL=y
>  # For periodic module:
> -#CONFIG_AUTOSCAN_PERIODIC=y
> +CONFIG_AUTOSCAN_PERIODIC=y
>  
>  # Password (and passphrase, etc.) backend for external storage
>  # These optional mechanisms can be used to add support for storing passwords
> @@ -600,7 +600,7 @@ CONFIG_IBSS_RSN=y
>  # operations for roaming within an ESS (same SSID). See the bgscan parameter in
>  # the wpa_supplicant.conf file for more details.
>  # Periodic background scans based on signal strength
> -#CONFIG_BGSCAN_SIMPLE=y
> +CONFIG_BGSCAN_SIMPLE=y
>  # Learn channels used by the network and try to avoid bgscans on other
>  # channels (experimental)
>  #CONFIG_BGSCAN_LEARN=y
> diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile
> index 8f94dce782..8c264854d7 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:=5
> +PKG_RELEASE:=6
>  
>  PKG_SOURCE_URL:=http://w1.fi/hostap.git
>  PKG_SOURCE_PROTO:=git
>
Daniel Golle Oct. 7, 2020, 12:24 a.m. UTC | #2
Hi Andre,

On Wed, Sep 16, 2020 at 08:41:03PM +0200, Andre Valentin wrote:
> Hello!
> 
> Could someone please take care of this little snippet?

Apart from this no longer applying due to other changes (trivial
to fix, I'd had it pulled in anyway), I also stumbled into an issue,
see below:

> 
> Kind regards,
> 
> André
> Am 09.09.20 um 22:00 schrieb André Valentin:
> > Activation of autoscanning enables a a wifi client to select the best
> > accesspoint based on rssi.
> > 
> > This feature is useful in case you have multiple access points in your range
> > and you do not want to stick the client on the first one it connected to.
> > Especially when used with 802.11r this allows seamless transition to the
> > optimal accesspoints.
> > 
> > Setting the config value bgscan to -65 will tell wpa_supplicant to try to
> > connect to an access points with better rssi.
> > 
> > Example config:
> > config wifi-iface 'default_radio1'
> > 	option device 'radio1'
> > 	option mode 'sta'
> > 	option ssid 'openwrt'
> > 	option encryption 'psk2'
> > 	option key 'mykey'
> > 	option network 'wlan'
> > 	option roam_rssi_threshold '-65'
> > 
> > The ipk sizes for mipsel_24kc change like this:
> > old:
> > wpad-openssl_2020-06-08-5a8b3662-4_mipsel_24kc.ipk 550133
> > 
> > new:
> > wpad-openssl_2020-06-08-5a8b3662-5_mipsel_24kc.ipk 551961
> > 
> > Signed-off-by: André Valentin <avalentin@marcant.net>
> > ---
> >  package/network/services/hostapd/files/hostapd.sh          		| 7 +++++++
> >  package/network/services/hostapd/files/wpa_supplicant-full.config      | 6 +++---
> >  package/network/services/hostapd/Makefile				| 1 +-
> >  3 files changed, 11 insertions(+), 4 deletions(-)
> > 
> > diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
> > index 88113cd7ce..85299234c2 100644
> > --- a/package/network/services/hostapd/files/hostapd.sh
> > +++ b/package/network/services/hostapd/files/hostapd.sh
> > @@ -272,6 +272,8 @@ hostapd_common_add_bss_config() {
> >  	config_add_array operator_icon
> >  	config_add_array hs20_conn_capab
> >  	config_add_string osu_ssid hs20_wan_metrics hs20_operating_class hs20_t_c_filename hs20_t_c_timestamp
> > +
> > +	config_add_string roam_rssi_threshold
> >  }
> >  
> >  hostapd_set_vlan_file() {
> > @@ -1178,6 +1180,11 @@ wpa_supplicant_add_network() {
> >  	[ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
> >  	[ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
> >  
> > +	[ -n "$roam_rssi_threshold" ] && {
> > +		json_get_vars roam_rssi_threshold
> > +		append network_data "bgscan=\"simple:120:${roam_rssi_threshold}:600\"" "$N$T"
> > +	}
> > +

This looks odd to me. You are checking the content of the variable and
then (re-?)loading it?

> >  	[ -n "$basic_rate" ] && {
> >  		local br rate_list=
> >  		for br in $basic_rate; do
> > diff --git a/package/network/services/hostapd/files/wpa_supplicant-full.config b/package/network/services/hostapd/files/wpa_supplicant-full.config
> > index 982f4d5534..d39ee74a8d 100644
> > --- a/package/network/services/hostapd/files/wpa_supplicant-full.config
> > +++ b/package/network/services/hostapd/files/wpa_supplicant-full.config
> > @@ -527,9 +527,9 @@ CONFIG_WNM=y
> >  #
> >  # Enabling directly a module will enable autoscan support.
> >  # For exponential module:
> > -#CONFIG_AUTOSCAN_EXPONENTIAL=y
> > +CONFIG_AUTOSCAN_EXPONENTIAL=y
> >  # For periodic module:
> > -#CONFIG_AUTOSCAN_PERIODIC=y
> > +CONFIG_AUTOSCAN_PERIODIC=y
> >  
> >  # Password (and passphrase, etc.) backend for external storage
> >  # These optional mechanisms can be used to add support for storing passwords
> > @@ -600,7 +600,7 @@ CONFIG_IBSS_RSN=y
> >  # operations for roaming within an ESS (same SSID). See the bgscan parameter in
> >  # the wpa_supplicant.conf file for more details.
> >  # Periodic background scans based on signal strength
> > -#CONFIG_BGSCAN_SIMPLE=y
> > +CONFIG_BGSCAN_SIMPLE=y
> >  # Learn channels used by the network and try to avoid bgscans on other
> >  # channels (experimental)
> >  #CONFIG_BGSCAN_LEARN=y
> > diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile
> > index 8f94dce782..8c264854d7 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:=5
> > +PKG_RELEASE:=6
> >  

Please update this apply cleanly on current master.
Andre Valentin Oct. 7, 2020, 6:45 a.m. UTC | #3
Hi Daniel!

Am 07.10.20 um 02:24 schrieb Daniel Golle:
> Hi Andre,
> 
> On Wed, Sep 16, 2020 at 08:41:03PM +0200, Andre Valentin wrote:
>> Hello!
>>
>> Could someone please take care of this little snippet?
> 
> Apart from this no longer applying due to other changes (trivial
> to fix, I'd had it pulled in anyway), I also stumbled into an issue,
> see below>
>>
>> Kind regards,
>>
>> André
>> Am 09.09.20 um 22:00 schrieb André Valentin:
>>> Activation of autoscanning enables a a wifi client to select the best
>>> accesspoint based on rssi.
>>>
>>> This feature is useful in case you have multiple access points in your range
>>> and you do not want to stick the client on the first one it connected to.
>>> Especially when used with 802.11r this allows seamless transition to the
>>> optimal accesspoints.
>>>
>>> Setting the config value bgscan to -65 will tell wpa_supplicant to try to
>>> connect to an access points with better rssi.
>>>
>>> Example config:
>>> config wifi-iface 'default_radio1'
>>> 	option device 'radio1'
>>> 	option mode 'sta'
>>> 	option ssid 'openwrt'
>>> 	option encryption 'psk2'
>>> 	option key 'mykey'
>>> 	option network 'wlan'
>>> 	option roam_rssi_threshold '-65'
>>>
>>> The ipk sizes for mipsel_24kc change like this:
>>> old:
>>> wpad-openssl_2020-06-08-5a8b3662-4_mipsel_24kc.ipk 550133
>>>
>>> new:
>>> wpad-openssl_2020-06-08-5a8b3662-5_mipsel_24kc.ipk 551961
>>>
>>> Signed-off-by: André Valentin <avalentin@marcant.net>
>>> ---
>>>  package/network/services/hostapd/files/hostapd.sh          		| 7 +++++++
>>>  package/network/services/hostapd/files/wpa_supplicant-full.config      | 6 +++---
>>>  package/network/services/hostapd/Makefile				| 1 +-
>>>  3 files changed, 11 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
>>> index 88113cd7ce..85299234c2 100644
>>> --- a/package/network/services/hostapd/files/hostapd.sh
>>> +++ b/package/network/services/hostapd/files/hostapd.sh
>>> @@ -272,6 +272,8 @@ hostapd_common_add_bss_config() {
>>>  	config_add_array operator_icon
>>>  	config_add_array hs20_conn_capab
>>>  	config_add_string osu_ssid hs20_wan_metrics hs20_operating_class hs20_t_c_filename hs20_t_c_timestamp
>>> +
>>> +	config_add_string roam_rssi_threshold
>>>  }
>>>  
>>>  hostapd_set_vlan_file() {
>>> @@ -1178,6 +1180,11 @@ wpa_supplicant_add_network() {
>>>  	[ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
>>>  	[ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
>>>  
>>> +	[ -n "$roam_rssi_threshold" ] && {
>>> +		json_get_vars roam_rssi_threshold
>>> +		append network_data "bgscan=\"simple:120:${roam_rssi_threshold}:600\"" "$N$T"
>>> +	}
>>> +
> 
> This looks odd to me. You are checking the content of the variable and
> then (re-?)loading it?
Don't ask. I noticed this also yesterday. Remember: do not change this seconds before publishing.
I will provide a v3 at the weekend,

> 
>>>  	[ -n "$basic_rate" ] && {
>>>  		local br rate_list=
>>>  		for br in $basic_rate; do
>>> diff --git a/package/network/services/hostapd/files/wpa_supplicant-full.config b/package/network/services/hostapd/files/wpa_supplicant-full.config
>>> index 982f4d5534..d39ee74a8d 100644
>>> --- a/package/network/services/hostapd/files/wpa_supplicant-full.config
>>> +++ b/package/network/services/hostapd/files/wpa_supplicant-full.config
>>> @@ -527,9 +527,9 @@ CONFIG_WNM=y
>>>  #
>>>  # Enabling directly a module will enable autoscan support.
>>>  # For exponential module:
>>> -#CONFIG_AUTOSCAN_EXPONENTIAL=y
>>> +CONFIG_AUTOSCAN_EXPONENTIAL=y
>>>  # For periodic module:
>>> -#CONFIG_AUTOSCAN_PERIODIC=y
>>> +CONFIG_AUTOSCAN_PERIODIC=y
>>>  
>>>  # Password (and passphrase, etc.) backend for external storage
>>>  # These optional mechanisms can be used to add support for storing passwords
>>> @@ -600,7 +600,7 @@ CONFIG_IBSS_RSN=y
>>>  # operations for roaming within an ESS (same SSID). See the bgscan parameter in
>>>  # the wpa_supplicant.conf file for more details.
>>>  # Periodic background scans based on signal strength
>>> -#CONFIG_BGSCAN_SIMPLE=y
>>> +CONFIG_BGSCAN_SIMPLE=y
>>>  # Learn channels used by the network and try to avoid bgscans on other
>>>  # channels (experimental)
>>>  #CONFIG_BGSCAN_LEARN=y
>>> diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile
>>> index 8f94dce782..8c264854d7 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:=5
>>> +PKG_RELEASE:=6
>>>  
> 
> Please update this apply cleanly on current master.
> 
Thank you very much for taking a look!

Kind regards,

André
diff mbox series

Patch

diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
index 88113cd7ce..85299234c2 100644
--- a/package/network/services/hostapd/files/hostapd.sh
+++ b/package/network/services/hostapd/files/hostapd.sh
@@ -272,6 +272,8 @@  hostapd_common_add_bss_config() {
 	config_add_array operator_icon
 	config_add_array hs20_conn_capab
 	config_add_string osu_ssid hs20_wan_metrics hs20_operating_class hs20_t_c_filename hs20_t_c_timestamp
+
+	config_add_string roam_rssi_threshold
 }
 
 hostapd_set_vlan_file() {
@@ -1178,6 +1180,11 @@  wpa_supplicant_add_network() {
 	[ -n "$bssid_blacklist" ] && append network_data "bssid_blacklist=$bssid_blacklist" "$N$T"
 	[ -n "$bssid_whitelist" ] && append network_data "bssid_whitelist=$bssid_whitelist" "$N$T"
 
+	[ -n "$roam_rssi_threshold" ] && {
+		json_get_vars roam_rssi_threshold
+		append network_data "bgscan=\"simple:120:${roam_rssi_threshold}:600\"" "$N$T"
+	}
+
 	[ -n "$basic_rate" ] && {
 		local br rate_list=
 		for br in $basic_rate; do
diff --git a/package/network/services/hostapd/files/wpa_supplicant-full.config b/package/network/services/hostapd/files/wpa_supplicant-full.config
index 982f4d5534..d39ee74a8d 100644
--- a/package/network/services/hostapd/files/wpa_supplicant-full.config
+++ b/package/network/services/hostapd/files/wpa_supplicant-full.config
@@ -527,9 +527,9 @@  CONFIG_WNM=y
 #
 # Enabling directly a module will enable autoscan support.
 # For exponential module:
-#CONFIG_AUTOSCAN_EXPONENTIAL=y
+CONFIG_AUTOSCAN_EXPONENTIAL=y
 # For periodic module:
-#CONFIG_AUTOSCAN_PERIODIC=y
+CONFIG_AUTOSCAN_PERIODIC=y
 
 # Password (and passphrase, etc.) backend for external storage
 # These optional mechanisms can be used to add support for storing passwords
@@ -600,7 +600,7 @@  CONFIG_IBSS_RSN=y
 # operations for roaming within an ESS (same SSID). See the bgscan parameter in
 # the wpa_supplicant.conf file for more details.
 # Periodic background scans based on signal strength
-#CONFIG_BGSCAN_SIMPLE=y
+CONFIG_BGSCAN_SIMPLE=y
 # Learn channels used by the network and try to avoid bgscans on other
 # channels (experimental)
 #CONFIG_BGSCAN_LEARN=y
diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile
index 8f94dce782..8c264854d7 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:=5
+PKG_RELEASE:=6
 
 PKG_SOURCE_URL:=http://w1.fi/hostap.git
 PKG_SOURCE_PROTO:=git