ead1bcac90dc2b6235531ddb6463c154582bc5c2
[openwrt/openwrt.git] / package / network / services / hostapd / patches / 004-mesh-use-setup-completion-callback-to-complete-mesh-.patch
1 From c05ace7510ead96e72b97ce47b33f7b5865d6d36 Mon Sep 17 00:00:00 2001
2 From: Peter Oh <peter.oh@bowerswilkins.com>
3 Date: Mon, 27 Aug 2018 14:28:38 -0700
4 Subject: [PATCH 1/7] mesh: use setup completion callback to complete mesh join
5
6 mesh join function is the last function to be called during
7 mesh join process, but it's been called a bit earlier than
8 it's supposed to be, so that some mesh parameter values
9 such as VHT capabilities not applied correct when mesh join
10 is in process.
11 Moreover current design of mesh join that is called directly
12 after mesh initialization isn't suitable for DFS channels to use,
13 since mesh join process should be paused until DFS CAC is
14 done and resumed after it's done.
15 The callback will be called by hostapd_setup_interface_complete_sync.
16 There is possiblity that completing mesh init fails, so add error
17 handle codes.
18
19 Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
20 Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
21 ---
22 src/ap/hostapd.c | 11 ++++++++++-
23 wpa_supplicant/mesh.c | 13 +++++++------
24 2 files changed, 17 insertions(+), 7 deletions(-)
25
26 --- a/src/ap/hostapd.c
27 +++ b/src/ap/hostapd.c
28 @@ -414,6 +414,8 @@ static void hostapd_free_hapd_data(struc
29 #ifdef CONFIG_MESH
30 wpabuf_free(hapd->mesh_pending_auth);
31 hapd->mesh_pending_auth = NULL;
32 + /* handling setup failure is already done */
33 + hapd->setup_complete_cb = NULL;
34 #endif /* CONFIG_MESH */
35
36 hostapd_clean_rrm(hapd);
37 @@ -1980,6 +1982,13 @@ dfs_offload:
38 if (hapd->setup_complete_cb)
39 hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
40
41 +#ifdef CONFIG_MESH
42 + if (delay_apply_cfg && !iface->mconf) {
43 + wpa_printf(MSG_ERROR, "Error while completing mesh init");
44 + goto fail;
45 + }
46 +#endif /* CONFIG_MESH */
47 +
48 wpa_printf(MSG_DEBUG, "%s: Setup of interface done.",
49 iface->bss[0]->conf->iface);
50 if (iface->interfaces && iface->interfaces->terminate_on_error > 0)
51 @@ -2123,7 +2132,7 @@ int hostapd_setup_interface(struct hosta
52 ret = setup_interface(iface);
53 if (ret) {
54 wpa_printf(MSG_ERROR, "%s: Unable to setup interface.",
55 - iface->bss[0]->conf->iface);
56 + iface->conf ? iface->conf->bss[0]->iface : "N/A");
57 return -1;
58 }
59
60 --- a/wpa_supplicant/mesh.c
61 +++ b/wpa_supplicant/mesh.c
62 @@ -190,8 +190,9 @@ static int wpas_mesh_init_rsn(struct wpa
63 }
64
65
66 -static int wpas_mesh_complete(struct wpa_supplicant *wpa_s)
67 +static void wpas_mesh_complete_cb(void *ctx)
68 {
69 + struct wpa_supplicant *wpa_s = ctx;
70 struct hostapd_iface *ifmsh = wpa_s->ifmsh;
71 struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params;
72 struct wpa_ssid *ssid = wpa_s->current_ssid;
73 @@ -200,7 +201,7 @@ static int wpas_mesh_complete(struct wpa
74 if (!params || !ssid || !ifmsh) {
75 wpa_printf(MSG_ERROR, "mesh: %s called without active mesh",
76 __func__);
77 - return -1;
78 + return;
79 }
80
81 if (ifmsh->mconf->security != MESH_CONF_SEC_NONE &&
82 @@ -208,7 +209,7 @@ static int wpas_mesh_complete(struct wpa
83 wpa_printf(MSG_ERROR,
84 "mesh: RSN initialization failed - deinit mesh");
85 wpa_supplicant_mesh_deinit(wpa_s);
86 - return -1;
87 + return;
88 }
89
90 if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
91 @@ -234,8 +235,6 @@ static int wpas_mesh_complete(struct wpa
92
93 if (!ret)
94 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
95 -
96 - return ret;
97 }
98
99
100 @@ -262,6 +261,7 @@ static int wpa_supplicant_mesh_init(stru
101 if (!ifmsh)
102 return -ENOMEM;
103
104 + ifmsh->owner = wpa_s;
105 ifmsh->drv_flags = wpa_s->drv_flags;
106 ifmsh->num_bss = 1;
107 ifmsh->bss = os_calloc(wpa_s->ifmsh->num_bss,
108 @@ -279,6 +279,8 @@ static int wpa_supplicant_mesh_init(stru
109 bss->drv_priv = wpa_s->drv_priv;
110 bss->iface = ifmsh;
111 bss->mesh_sta_free_cb = mesh_mpm_free_sta;
112 + bss->setup_complete_cb = wpas_mesh_complete_cb;
113 + bss->setup_complete_cb_ctx = wpa_s;
114 frequency = ssid->frequency;
115 if (frequency != freq->freq &&
116 frequency == freq->freq + freq->sec_channel_offset * 20) {
117 @@ -517,7 +519,6 @@ int wpa_supplicant_join_mesh(struct wpa_
118 goto out;
119 }
120
121 - ret = wpas_mesh_complete(wpa_s);
122 out:
123 return ret;
124 }