[2/2] mesh: Make NL80211_MESHCONF_RSSI_THRESHOLD configurable

Submitted by Masashi Honma on March 16, 2017, 1:59 a.m.

Details

Message ID 1489629581-7900-2-git-send-email-masashi.honma@gmail.com
State Changes Requested
Headers show

Commit Message

Masashi Honma March 16, 2017, 1:59 a.m.
On some practical cases, it is useful to suppress joining to node in the
distance. The new field mesh_rssi_threshold could be used as RSSI
threshold for joining. This patch requires kernel modification patch
provided by us.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 src/drivers/driver.h         | 2 ++
 src/drivers/driver_nl80211.c | 6 +++++-
 wpa_supplicant/config.c      | 2 ++
 wpa_supplicant/config_file.c | 1 +
 wpa_supplicant/config_ssid.h | 8 ++++++++
 wpa_supplicant/mesh.c        | 1 +
 wpa_supplicant/wpa_cli.c     | 2 +-
 7 files changed, 20 insertions(+), 2 deletions(-)

Comments

Jouni Malinen March 27, 2017, 2:24 p.m.
On Thu, Mar 16, 2017 at 10:59:41AM +0900, Masashi Honma wrote:
> On some practical cases, it is useful to suppress joining to node in the
> distance. The new field mesh_rssi_threshold could be used as RSSI
> threshold for joining. This patch requires kernel modification patch
> provided by us.

Is that referring to the pending "mac80211: Use rssi_threshold even
though user_mpm=1" patch? Could you please clarify what happens if that
patch is not included in the kernel? Does this wpa_supplicant change
need to wait for the mac80211 change to be applied first?
Masashi Honma March 27, 2017, 8:02 p.m.
On 2017/03/27 23:24, Jouni Malinen wrote:
> Is that referring to the pending "mac80211: Use rssi_threshold even
> though user_mpm=1" patch? Could you please clarify what happens if that
> patch is not included in the kernel? Does this wpa_supplicant change
> need to wait for the mac80211 change to be applied first?

This patch could be merged without the pending patch.
Because NL80211_MESHCONF_RSSI_THRESHOLD API already exists.

Masashi Honma.
Jouni Malinen March 29, 2017, 12:02 p.m.
On Thu, Mar 16, 2017 at 10:59:41AM +0900, Masashi Honma wrote:
> On some practical cases, it is useful to suppress joining to node in the
> distance. The new field mesh_rssi_threshold could be used as RSSI
> threshold for joining. This patch requires kernel modification patch
> provided by us.

> diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
> index bceeba2..cd1b5b9 100644
> --- a/src/drivers/driver_nl80211.c
> +++ b/src/drivers/driver_nl80211.c
> @@ -8774,7 +8774,10 @@ static int nl80211_put_mesh_config(struct nl_msg *msg,
>  			 params->auto_plinks)) ||
>  	    ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS) &&
>  	     nla_put_u16(msg, NL80211_MESHCONF_MAX_PEER_LINKS,
> -			 params->max_peer_links)))
> +			 params->max_peer_links)) ||
> +	    ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD) &&
> +	     nla_put_s32(msg, NL80211_MESHCONF_RSSI_THRESHOLD,
> +			 params->rssi_threshold)))
>  		return -1;

nla_put_s32() is a recent addition to libnl and this would break builds
with most released versions.. Can we use nla_put_u32 instead()? Or add a
backwards compatibility wrapper for this?

> @@ -8847,6 +8850,7 @@ static int nl80211_join_mesh(struct i802_bss *bss,
>  	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_AUTO_PLINKS;
>  	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_PEER_LINK_TIMEOUT;
>  	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS;
> +	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
>  	if (nl80211_put_mesh_config(msg, &params->conf) < 0)

Would it be better to add WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD only
if the configuration value is actually set? This would leave the current
behavior of kernel using its default value (which may happen to be the
same as the default in wpa_supplicant) more consistent rather than
moving this to be enforced by whatever the wpa_supplicant default value
is.

Patch hide | download patch | download mbox

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index fc2593e..2c82f5e 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1288,6 +1288,7 @@  struct wpa_driver_mesh_bss_params {
 #define WPA_DRIVER_MESH_CONF_FLAG_PEER_LINK_TIMEOUT	0x00000002
 #define WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS	0x00000004
 #define WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE		0x00000008
+#define WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD	0x00000010
 	/*
 	 * TODO: Other mesh configuration parameters would go here.
 	 * See NL80211_MESHCONF_* for all the mesh config parameters.
@@ -1296,6 +1297,7 @@  struct wpa_driver_mesh_bss_params {
 	int auto_plinks;
 	int peer_link_timeout;
 	int max_peer_links;
+	int rssi_threshold;
 	u16 ht_opmode;
 };
 
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index bceeba2..cd1b5b9 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -8774,7 +8774,10 @@  static int nl80211_put_mesh_config(struct nl_msg *msg,
 			 params->auto_plinks)) ||
 	    ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS) &&
 	     nla_put_u16(msg, NL80211_MESHCONF_MAX_PEER_LINKS,
-			 params->max_peer_links)))
+			 params->max_peer_links)) ||
+	    ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD) &&
+	     nla_put_s32(msg, NL80211_MESHCONF_RSSI_THRESHOLD,
+			 params->rssi_threshold)))
 		return -1;
 
 	/*
@@ -8847,6 +8850,7 @@  static int nl80211_join_mesh(struct i802_bss *bss,
 	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_AUTO_PLINKS;
 	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_PEER_LINK_TIMEOUT;
 	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS;
+	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
 	if (nl80211_put_mesh_config(msg, &params->conf) < 0)
 		goto fail;
 
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 8bfb6a1..a0b8861 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -2066,6 +2066,7 @@  static const struct parse_data ssid_fields[] = {
 #ifdef CONFIG_MESH
 	{ INT_RANGE(mode, 0, 5) },
 	{ INT_RANGE(no_auto_peer, 0, 1) },
+	{ INT_RANGE(mesh_rssi_threshold, -255, 0) },
 #else /* CONFIG_MESH */
 	{ INT_RANGE(mode, 0, 4) },
 #endif /* CONFIG_MESH */
@@ -2598,6 +2599,7 @@  void wpa_config_set_network_defaults(struct wpa_ssid *ssid)
 	ssid->dot11MeshRetryTimeout = DEFAULT_MESH_RETRY_TIMEOUT;
 	ssid->dot11MeshConfirmTimeout = DEFAULT_MESH_CONFIRM_TIMEOUT;
 	ssid->dot11MeshHoldingTimeout = DEFAULT_MESH_HOLDING_TIMEOUT;
+	ssid->mesh_rssi_threshold = DEFAULT_MESH_RSSI_THRESHOLD;
 #endif /* CONFIG_MESH */
 #ifdef CONFIG_HT_OVERRIDES
 	ssid->disable_ht = DEFAULT_DISABLE_HT;
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index e8f1149..f6732e4 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -783,6 +783,7 @@  static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
 #endif /* IEEE8021X_EAPOL */
 	INT(mode);
 	INT(no_auto_peer);
+	INT(mesh_rssi_threshold);
 	INT(frequency);
 	INT(fixed_freq);
 #ifdef CONFIG_ACS
diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
index 869165c..04a0a9a 100644
--- a/wpa_supplicant/config_ssid.h
+++ b/wpa_supplicant/config_ssid.h
@@ -28,6 +28,7 @@ 
 #define DEFAULT_MESH_RETRY_TIMEOUT 40
 #define DEFAULT_MESH_CONFIRM_TIMEOUT 40
 #define DEFAULT_MESH_HOLDING_TIMEOUT 40
+#define DEFAULT_MESH_RSSI_THRESHOLD 0
 #define DEFAULT_DISABLE_HT 0
 #define DEFAULT_DISABLE_HT40 0
 #define DEFAULT_DISABLE_SGI 0
@@ -807,6 +808,13 @@  struct wpa_ssid {
 	 */
 	int no_auto_peer;
 
+#ifdef CONFIG_MESH
+	/**
+	 * mesh_rssi_threshold - Set mesh parameter mesh_rssi_threshold(dBm)
+	 */
+	int mesh_rssi_threshold;
+#endif /* CONFIG_MESH */
+
 	/**
 	 * wps_disabled - WPS disabled in AP mode
 	 *
diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c
index 01b657e..0619599 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -413,6 +413,7 @@  int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
 	else if (wpa_s->conf->dtim_period > 0)
 		params.dtim_period = wpa_s->conf->dtim_period;
 	params.conf.max_peer_links = wpa_s->conf->max_peer_links;
+	params.conf.rssi_threshold = ssid->mesh_rssi_threshold;
 
 	if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
 		params.flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index c5091b5..8278bd2 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -1392,7 +1392,7 @@  static const char *network_fields[] = {
 	"eap_workaround", "pac_file", "fragment_size", "ocsp",
 #endif /* IEEE8021X_EAPOL */
 #ifdef CONFIG_MESH
-	"mode", "no_auto_peer",
+	"mode", "no_auto_peer", "mesh_rssi_threshold",
 #else /* CONFIG_MESH */
 	"mode",
 #endif /* CONFIG_MESH */