[PATCH 08/12] mesh: Make plink params configurable
Masashi Honma
masashi.honma
Mon Nov 3 21:36:49 PST 2014
This patch makes four MIBs for plink configurable.
You can configure dot11MeshMaxRetries, dot11MeshRetryTimeout,
dot11MeshConfirmTimeout and dot11MeshHoldingTimeout by config file like this
mesh_plink_params=1 2 3 4
or wpa_cli command like this.
set_network 0 mesh_plink_params 1 2 3 4
And this patch sets correct default value based on spec to the MIBs.
Signed-off-by: Masashi Honma <masashi.honma at gmail.com>
---
src/ap/ap_config.h | 4 ++++
wpa_supplicant/config.c | 34 ++++++++++++++++++++++++++
wpa_supplicant/config_file.c | 1 +
wpa_supplicant/config_ssid.h | 6 +++++
wpa_supplicant/mesh.c | 11 +++++++++
wpa_supplicant/mesh_mpm.c | 57 ++++++++++++++++++++++++++------------------
6 files changed, 90 insertions(+), 23 deletions(-)
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 18538c9..593dd99 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -37,6 +37,10 @@ struct mesh_conf {
#define MESH_CONF_SEC_AUTH BIT(1)
#define MESH_CONF_SEC_AMPE BIT(2)
unsigned int security;
+ int dot11MeshMaxRetries;
+ int dot11MeshRetryTimeout; /* msec */
+ int dot11MeshConfirmTimeout; /* msec */
+ int dot11MeshHoldingTimeout; /* msec */
};
#define MAX_STA_COUNT 2007
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index 5cefbf1..73e8110 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -1628,6 +1628,31 @@ static int wpa_config_parse_mesh_basic_rates(const struct parse_data *data,
}
+static int wpa_config_parse_mesh_plink_params(const struct parse_data *data,
+ struct wpa_ssid *ssid, int line,
+ const char *value)
+{
+ int *params = wpa_config_parse_int_array(value);
+
+ if (params == NULL) {
+ wpa_printf(MSG_ERROR, "Line %d: Invalid mesh_plink_params '%s'",
+ line, value);
+ return -1;
+ }
+ if (params[0] == 0 || params[1] == 0 || params[2] == 0 ||
+ params[3] == 0) {
+ wpa_printf(MSG_ERROR, "Line %d: mesh_plink_params requires "
+ "four arguments '%s'", line, value);
+ os_free(params);
+ return -1;
+ }
+
+ os_free(ssid->mesh_plink_params);
+ ssid->mesh_plink_params = params;
+
+ return 0;
+}
+
#ifndef NO_CONFIG_WRITE
static char * wpa_config_write_mesh_ht_mode(const struct parse_data *data,
@@ -1662,6 +1687,13 @@ static char * wpa_config_write_mesh_basic_rates(const struct parse_data *data,
return wpa_config_write_freqs(data, ssid->mesh_basic_rates);
}
+
+static char * wpa_config_write_mesh_plink_params(const struct parse_data *data,
+ struct wpa_ssid *ssid)
+{
+ return wpa_config_write_freqs(data, ssid->mesh_plink_params);
+}
+
#endif /* NO_CONFIG_WRITE */
#endif /* CONFIG_MESH */
@@ -1839,6 +1871,7 @@ static const struct parse_data ssid_fields[] = {
#ifdef CONFIG_MESH
{ FUNC(mesh_ht_mode) },
{ FUNC(mesh_basic_rates) },
+ { FUNC(mesh_plink_params) },
#endif /* CONFIG_MESH */
{ INT(wpa_ptk_rekey) },
{ STR(bgscan) },
@@ -2071,6 +2104,7 @@ void wpa_config_free_ssid(struct wpa_ssid *ssid)
#endif /* CONFIG_HT_OVERRIDES */
#ifdef CONFIG_MESH
os_free(ssid->mesh_basic_rates);
+ os_free(ssid->mesh_plink_params);
#endif /* CONFIG_MESH */
while ((psk = dl_list_first(&ssid->psk_list, struct psk_list_entry,
list))) {
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 664745b..917dd2c 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -754,6 +754,7 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
#ifdef CONFIG_MESH
STR(mesh_ht_mode);
STR(mesh_basic_rates);
+ STR(mesh_plink_params);
#endif /* CONFIG_MESH */
#undef STR
diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h
index b1c2fd8..4d02155 100644
--- a/wpa_supplicant/config_ssid.h
+++ b/wpa_supplicant/config_ssid.h
@@ -419,6 +419,12 @@ struct wpa_ssid {
*/
int *mesh_basic_rates;
+ /**
+ * mesh_plink_params - Mesh network plink parameters
+ *
+ */
+ int *mesh_plink_params;
+
int ht40;
int vht;
diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c
index 5382430..8e8fd0e 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -89,6 +89,17 @@ static struct mesh_conf * mesh_config_create(struct wpa_ssid *ssid)
conf->mesh_cc_id = 0;
conf->mesh_sp_id = MESH_SYNC_METHOD_NEIGHBOR_OFFSET;
conf->mesh_auth_id = (conf->security & MESH_CONF_SEC_AUTH) ? 1 : 0;
+ if (ssid->mesh_plink_params == NULL) {
+ conf->dot11MeshMaxRetries = 2;
+ conf->dot11MeshRetryTimeout = 40;
+ conf->dot11MeshConfirmTimeout = 40;
+ conf->dot11MeshHoldingTimeout = 40;
+ } else {
+ conf->dot11MeshMaxRetries = ssid->mesh_plink_params[0];
+ conf->dot11MeshRetryTimeout = ssid->mesh_plink_params[1];
+ conf->dot11MeshConfirmTimeout = ssid->mesh_plink_params[2];
+ conf->dot11MeshHoldingTimeout = ssid->mesh_plink_params[3];
+ }
return conf;
}
diff --git a/wpa_supplicant/mesh_mpm.c b/wpa_supplicant/mesh_mpm.c
index 913ec45..32c73a6 100644
--- a/wpa_supplicant/mesh_mpm.c
+++ b/wpa_supplicant/mesh_mpm.c
@@ -19,12 +19,6 @@
#include "mesh_mpm.h"
#include "mesh_rsn.h"
-/* TODO make configurable */
-#define dot11MeshMaxRetries 10
-#define dot11MeshRetryTimeout 1
-#define dot11MeshConfirmTimeout 1
-#define dot11MeshHoldingTimeout 1
-
struct mesh_peer_mgmt_ie {
const u8 *proto_id;
const u8 *llid;
@@ -395,14 +389,17 @@ static void plink_timer(void *eloop_ctx, void *user_data)
struct wpa_supplicant *wpa_s = eloop_ctx;
struct sta_info *sta = user_data;
u16 reason = 0;
+ struct mesh_conf *conf = wpa_s->ifmsh->mconf;
switch (sta->plink_state) {
case PLINK_OPEN_RCVD:
case PLINK_OPEN_SENT:
/* retry timer */
- if (sta->mpm_retries < dot11MeshMaxRetries) {
- eloop_register_timeout(dot11MeshRetryTimeout, 0,
- plink_timer, wpa_s, sta);
+ if (sta->mpm_retries < conf->dot11MeshMaxRetries) {
+ eloop_register_timeout(
+ conf->dot11MeshRetryTimeout / 1000,
+ (conf->dot11MeshRetryTimeout % 1000) * 1000,
+ plink_timer, wpa_s, sta);
mesh_mpm_send_plink_action(wpa_s, sta, PLINK_OPEN, 0);
sta->mpm_retries++;
break;
@@ -415,8 +412,9 @@ static void plink_timer(void *eloop_ctx, void *user_data)
if (!reason)
reason = WLAN_REASON_MESH_CONFIRM_TIMEOUT;
sta->plink_state = PLINK_HOLDING;
- eloop_register_timeout(dot11MeshHoldingTimeout, 0,
- plink_timer, wpa_s, sta);
+ eloop_register_timeout(conf->dot11MeshHoldingTimeout / 1000,
+ (conf->dot11MeshHoldingTimeout % 1000) * 1000,
+ plink_timer, wpa_s, sta);
mesh_mpm_send_plink_action(wpa_s, sta, PLINK_CLOSE, reason);
break;
case PLINK_HOLDING:
@@ -434,9 +432,12 @@ static void
mesh_mpm_plink_open(struct wpa_supplicant *wpa_s, struct sta_info *sta,
enum mesh_plink_state next_state)
{
+ struct mesh_conf *conf = wpa_s->ifmsh->mconf;
+
eloop_cancel_timeout(plink_timer, wpa_s, sta);
- eloop_register_timeout(dot11MeshRetryTimeout, 0, plink_timer,
- wpa_s, sta);
+ eloop_register_timeout(conf->dot11MeshRetryTimeout / 1000,
+ (conf->dot11MeshRetryTimeout % 1000) * 1000, plink_timer, wpa_s,
+ sta);
mesh_mpm_send_plink_action(wpa_s, sta, PLINK_OPEN, 0);
wpa_mesh_set_plink_state(wpa_s, sta, next_state);
}
@@ -673,8 +674,10 @@ static void mesh_mpm_fsm(struct wpa_supplicant *wpa_s, struct sta_info *sta,
reason = WLAN_REASON_MESH_CLOSE_RCVD;
eloop_cancel_timeout_one(plink_timer, wpa_s, sta,
&remaining);
- eloop_register_timeout(dot11MeshHoldingTimeout, 0,
- plink_timer, wpa_s, sta);
+ eloop_register_timeout(
+ conf->dot11MeshHoldingTimeout / 1000,
+ (conf->dot11MeshHoldingTimeout % 1000) * 1000,
+ plink_timer, wpa_s, sta);
mesh_mpm_send_plink_action(wpa_s, sta,
PLINK_CLOSE, reason);
break;
@@ -688,8 +691,10 @@ static void mesh_mpm_fsm(struct wpa_supplicant *wpa_s, struct sta_info *sta,
wpa_mesh_set_plink_state(wpa_s, sta, PLINK_CNF_RCVD);
eloop_cancel_timeout_one(plink_timer, wpa_s, sta,
&remaining);
- eloop_register_timeout(dot11MeshConfirmTimeout, 0,
- plink_timer, wpa_s, sta);
+ eloop_register_timeout(
+ conf->dot11MeshConfirmTimeout / 1000,
+ (conf->dot11MeshConfirmTimeout % 1000) * 1000,
+ plink_timer, wpa_s, sta);
break;
default:
break;
@@ -707,8 +712,10 @@ static void mesh_mpm_fsm(struct wpa_supplicant *wpa_s, struct sta_info *sta,
reason = WLAN_REASON_MESH_CLOSE_RCVD;
eloop_cancel_timeout_one(plink_timer, wpa_s, sta,
&remaining);
- eloop_register_timeout(dot11MeshHoldingTimeout, 0,
- plink_timer, wpa_s, sta);
+ eloop_register_timeout(
+ conf->dot11MeshHoldingTimeout / 1000,
+ (conf->dot11MeshHoldingTimeout % 1000) * 1000,
+ plink_timer, wpa_s, sta);
sta->mpm_close_reason = reason;
mesh_mpm_send_plink_action(wpa_s, sta,
PLINK_CLOSE, reason);
@@ -738,8 +745,10 @@ static void mesh_mpm_fsm(struct wpa_supplicant *wpa_s, struct sta_info *sta,
reason = WLAN_REASON_MESH_CLOSE_RCVD;
eloop_cancel_timeout_one(plink_timer, wpa_s, sta,
&remaining);
- eloop_register_timeout(dot11MeshHoldingTimeout, 0,
- plink_timer, wpa_s, sta);
+ eloop_register_timeout(
+ conf->dot11MeshHoldingTimeout / 1000,
+ (conf->dot11MeshHoldingTimeout % 1000) * 1000,
+ plink_timer, wpa_s, sta);
sta->mpm_close_reason = reason;
mesh_mpm_send_plink_action(wpa_s, sta,
PLINK_CLOSE, reason);
@@ -761,8 +770,10 @@ static void mesh_mpm_fsm(struct wpa_supplicant *wpa_s, struct sta_info *sta,
eloop_cancel_timeout_one(plink_timer, wpa_s, sta,
&remaining);
- eloop_register_timeout(dot11MeshHoldingTimeout, 0,
- plink_timer, wpa_s, sta);
+ eloop_register_timeout(
+ conf->dot11MeshHoldingTimeout / 1000,
+ (conf->dot11MeshHoldingTimeout % 1000) * 1000,
+ plink_timer, wpa_s, sta);
sta->mpm_close_reason = reason;
wpa_msg(wpa_s, MSG_INFO, "mesh plink with " MACSTR
--
1.9.1
More information about the Hostap
mailing list