diff mbox series

[v8,05/16] mesh: use setup completion callback to complete mesh join

Message ID 7753a01a155f29529c5c5e5fe8c237418ddb9bb2.1535403927.git.peter.oh@bowerswilkins.com
State Changes Requested
Headers show
Series mesh: enable DFS channels in mesh mode | expand

Commit Message

Peter Oh Aug. 27, 2018, 9:28 p.m. UTC
From: Peter Oh <peter.oh@bowerswilkins.com>

mesh join function is the last function to be called during
mesh join process, but it's been called a bit earlier than
it's supposed to be, so that some mesh parameter values
such as VHT capabilities not applied correct when mesh join
is in process.
Moreover current design of mesh join that is called directly
after mesh initialization isn't suitable for DFS channels to use,
since mesh join process should be paused until DFS CAC is
done and resumed after it's done.
The callback will be called by hostapd_setup_interface_complete_sync.
There is possiblity that completing mesh init fails, so add error
handle codes.

Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
---
 src/ap/hostapd.c      | 11 ++++++++++-
 wpa_supplicant/mesh.c |  4 +++-
 2 files changed, 13 insertions(+), 2 deletions(-)

Comments

Jouni Malinen Jan. 3, 2019, 1:17 p.m. UTC | #1
On Mon, Aug 27, 2018 at 02:28:38PM -0700, peter.oh@bowerswilkins.com wrote:
> mesh join function is the last function to be called during
> mesh join process, but it's been called a bit earlier than
> it's supposed to be, so that some mesh parameter values
> such as VHT capabilities not applied correct when mesh join
> is in process.
> Moreover current design of mesh join that is called directly
> after mesh initialization isn't suitable for DFS channels to use,
> since mesh join process should be paused until DFS CAC is
> done and resumed after it's done.
> The callback will be called by hostapd_setup_interface_complete_sync.
> There is possiblity that completing mesh init fails, so add error
> handle codes.

This breaks channel configuration and number of hwsim test cases, so I
cannot apply this as-is. Patch 15/16 (do not allow pri/sec channel
switch) would be needed to make the test cases pass, but I don't think I
can apply it.

This is what this patch looked like in my pending branch while I was
testing and reviewing it (i.e., some updates needed due to rebasing):

[PATCH 08/16] mesh: Use hostapd setup completion callback to complete mesh join

Mesh join function is the last function to be called during mesh join
process, but it's been called a bit earlier than it's supposed to be, so
that some mesh parameter values such as VHT capabilities are not applied
correctly when mesh join is in process. Moreover the current design of
mesh join that is called directly after mesh initialization isn't
suitable for DFS channels to use, since mesh join process should be
paused until DFS CAC is done and resumed after it's done.

The callback will be called by hostapd_setup_interface_complete_sync().
There is possiblity that completing mesh init fails, so add error
handling for that.

Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
---
 src/ap/hostapd.c      | 11 ++++++++++-
 wpa_supplicant/mesh.c | 13 +++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 342585f..f89e88e 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -413,6 +413,8 @@ static void hostapd_free_hapd_data(struct hostapd_data *hapd)
 #ifdef CONFIG_MESH
 	wpabuf_free(hapd->mesh_pending_auth);
 	hapd->mesh_pending_auth = NULL;
+	/* handling setup failure is already done */
+	hapd->setup_complete_cb = NULL;
 #endif /* CONFIG_MESH */
 
 	hostapd_clean_rrm(hapd);
@@ -1958,6 +1960,13 @@ dfs_offload:
 	if (hapd->setup_complete_cb)
 		hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
 
+#ifdef CONFIG_MESH
+	if (delay_apply_cfg && !iface->mconf) {
+		wpa_printf(MSG_ERROR, "Error while completing mesh init");
+		goto fail;
+	}
+#endif /* CONFIG_MESH */
+
 	wpa_printf(MSG_DEBUG, "%s: Setup of interface done.",
 		   iface->bss[0]->conf->iface);
 	if (iface->interfaces && iface->interfaces->terminate_on_error > 0)
@@ -2101,7 +2110,7 @@ int hostapd_setup_interface(struct hostapd_iface *iface)
 	ret = setup_interface(iface);
 	if (ret) {
 		wpa_printf(MSG_ERROR, "%s: Unable to setup interface.",
-			   iface->bss[0]->conf->iface);
+			   iface->conf ? iface->conf->bss[0]->iface : "N/A");
 		return -1;
 	}
 
diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c
index 6cac664..bc9fbd8 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -190,8 +190,9 @@ static int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s)
 }
 
 
-static int wpas_mesh_complete(struct wpa_supplicant *wpa_s)
+static void wpas_mesh_complete_cb(void *ctx)
 {
+	struct wpa_supplicant *wpa_s = ctx;
 	struct hostapd_iface *ifmsh = wpa_s->ifmsh;
 	struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params;
 	struct wpa_ssid *ssid = wpa_s->current_ssid;
@@ -200,7 +201,7 @@ static int wpas_mesh_complete(struct wpa_supplicant *wpa_s)
 	if (!params || !ssid) {
 		wpa_printf(MSG_ERROR, "mesh: %s called without active mesh",
 			   __func__);
-		return -1;
+		return;
 	}
 
 	if (ifmsh->mconf->security != MESH_CONF_SEC_NONE &&
@@ -208,7 +209,7 @@ static int wpas_mesh_complete(struct wpa_supplicant *wpa_s)
 		wpa_printf(MSG_ERROR,
 			   "mesh: RSN initialization failed - deinit mesh");
 		wpa_supplicant_mesh_deinit(wpa_s);
-		return -1;
+		return;
 	}
 
 	if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
@@ -236,8 +237,6 @@ static int wpas_mesh_complete(struct wpa_supplicant *wpa_s)
 
 	if (!ret)
 		wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
-
-	return ret;
 }
 
 
@@ -264,6 +263,7 @@ static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
 	if (!ifmsh)
 		return -ENOMEM;
 
+	ifmsh->owner = wpa_s;
 	ifmsh->drv_flags = wpa_s->drv_flags;
 	ifmsh->num_bss = 1;
 	ifmsh->bss = os_calloc(wpa_s->ifmsh->num_bss,
@@ -281,6 +281,8 @@ static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
 	bss->drv_priv = wpa_s->drv_priv;
 	bss->iface = ifmsh;
 	bss->mesh_sta_free_cb = mesh_mpm_free_sta;
+	bss->setup_complete_cb = wpas_mesh_complete_cb;
+	bss->setup_complete_cb_ctx = wpa_s;
 	frequency = ssid->frequency;
 	if (frequency != freq->freq &&
 	    frequency == freq->freq + freq->sec_channel_offset * 20) {
@@ -508,7 +510,6 @@ int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
 		goto out;
 	}
 
-	ret = wpas_mesh_complete(wpa_s);
 out:
 	return ret;
 }
diff mbox series

Patch

diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 23d2720..243a576 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -365,6 +365,8 @@  static void hostapd_free_hapd_data(struct hostapd_data *hapd)
 #ifdef CONFIG_MESH
 	wpabuf_free(hapd->mesh_pending_auth);
 	hapd->mesh_pending_auth = NULL;
+	/* handling setup failure is already done */
+	hapd->setup_complete_cb = NULL;
 #endif /* CONFIG_MESH */
 
 	hostapd_clean_rrm(hapd);
@@ -2031,6 +2033,13 @@  dfs_offload:
 	if (hapd->setup_complete_cb)
 		hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
 
+#ifdef CONFIG_MESH
+	if (delay_apply_cfg && iface->mconf == NULL) {
+		wpa_printf(MSG_ERROR, "Error while completing mesh init");
+		goto fail;
+	}
+#endif /* CONFIG_MESH */
+
 	wpa_printf(MSG_DEBUG, "%s: Setup of interface done.",
 		   iface->bss[0]->conf->iface);
 	if (iface->interfaces && iface->interfaces->terminate_on_error > 0)
@@ -2174,7 +2183,7 @@  int hostapd_setup_interface(struct hostapd_iface *iface)
 	ret = setup_interface(iface);
 	if (ret) {
 		wpa_printf(MSG_ERROR, "%s: Unable to setup interface.",
-			   iface->bss[0]->conf->iface);
+			iface->conf ? iface->conf->bss[0]->iface : "N/A");
 		return -1;
 	}
 
diff --git a/wpa_supplicant/mesh.c b/wpa_supplicant/mesh.c
index 0740dc7..7b014b7 100644
--- a/wpa_supplicant/mesh.c
+++ b/wpa_supplicant/mesh.c
@@ -260,6 +260,7 @@  static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
 	if (!ifmsh)
 		return -ENOMEM;
 
+	ifmsh->owner = wpa_s;
 	ifmsh->drv_flags = wpa_s->drv_flags;
 	ifmsh->num_bss = 1;
 	ifmsh->bss = os_calloc(wpa_s->ifmsh->num_bss,
@@ -277,6 +278,8 @@  static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
 	bss->drv_priv = wpa_s->drv_priv;
 	bss->iface = ifmsh;
 	bss->mesh_sta_free_cb = mesh_mpm_free_sta;
+	bss->setup_complete_cb = wpas_mesh_complete_cb;
+	bss->setup_complete_cb_ctx = wpa_s;
 	frequency = ssid->frequency;
 	if (frequency != freq->freq &&
 	    frequency == freq->freq + freq->sec_channel_offset * 20) {
@@ -503,7 +506,6 @@  int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
 		goto out;
 	}
 
-	wpas_mesh_complete_cb(wpa_s);
 out:
 	return ret;
 }