hostapd: update mesh DFS patches and add mesh HE support
[openwrt/openwrt.git] / package / network / services / hostapd / patches / 014-mesh-fixes-for-mesh-init-deinit.patch
1 From 30bdefd7559d57eae8c3c7e6f721ecf7be929bf2 Mon Sep 17 00:00:00 2001
2 From: Markus Theil <markus.theil@tu-ilmenau.de>
3 Date: Tue, 30 Jun 2020 14:19:02 +0200
4 Subject: [PATCH 14/19] mesh: fixes for mesh init/deinit
5
6 Send mesh group started notification after join completion
7 callback is called.
8
9 Implement outstanding TODO, to leave the mesh network on deinit.
10
11 Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
12 ---
13 wpa_supplicant/mesh.c | 32 ++++++++++++++++++++------------
14 wpa_supplicant/mesh.h | 6 ++++--
15 wpa_supplicant/wpa_supplicant.c | 8 ++------
16 3 files changed, 26 insertions(+), 20 deletions(-)
17
18 --- a/wpa_supplicant/mesh.c
19 +++ b/wpa_supplicant/mesh.c
20 @@ -30,20 +30,20 @@
21
22 static void wpa_supplicant_mesh_deinit(struct wpa_supplicant *wpa_s)
23 {
24 - wpa_supplicant_mesh_iface_deinit(wpa_s, wpa_s->ifmsh);
25 + wpa_supplicant_mesh_iface_deinit(wpa_s, wpa_s->ifmsh, true);
26 wpa_s->ifmsh = NULL;
27 wpa_s->current_ssid = NULL;
28 os_free(wpa_s->mesh_rsn);
29 wpa_s->mesh_rsn = NULL;
30 os_free(wpa_s->mesh_params);
31 wpa_s->mesh_params = NULL;
32 - /* TODO: leave mesh (stop beacon). This will happen on link down
33 - * anyway, so it's not urgent */
34 + wpa_supplicant_leave_mesh(wpa_s, false);
35 }
36
37
38 void wpa_supplicant_mesh_iface_deinit(struct wpa_supplicant *wpa_s,
39 - struct hostapd_iface *ifmsh)
40 + struct hostapd_iface *ifmsh,
41 + bool also_clear_hostapd)
42 {
43 if (!ifmsh)
44 return;
45 @@ -64,8 +64,10 @@ void wpa_supplicant_mesh_iface_deinit(st
46 }
47
48 /* take care of shared data */
49 - hostapd_interface_deinit(ifmsh);
50 - hostapd_interface_free(ifmsh);
51 + if (also_clear_hostapd) {
52 + hostapd_interface_deinit(ifmsh);
53 + hostapd_interface_free(ifmsh);
54 + }
55 }
56
57
58 @@ -244,8 +246,7 @@ static int wpas_mesh_complete(struct wpa
59 wpas_mesh_init_rsn(wpa_s)) {
60 wpa_printf(MSG_ERROR,
61 "mesh: RSN initialization failed - deinit mesh");
62 - wpa_supplicant_mesh_deinit(wpa_s);
63 - wpa_drv_leave_mesh(wpa_s);
64 + wpa_supplicant_mesh_iface_deinit(wpa_s, wpa_s->ifmsh, false);
65 return -1;
66 }
67
68 @@ -270,9 +271,15 @@ static int wpas_mesh_complete(struct wpa
69 /* hostapd sets the interface down until we associate */
70 wpa_drv_set_operstate(wpa_s, 1);
71
72 - if (!ret)
73 + if (!ret) {
74 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
75
76 + wpa_msg(wpa_s, MSG_INFO, MESH_GROUP_STARTED "ssid=\"%s\" id=%d",
77 + wpa_ssid_txt(ssid->ssid, ssid->ssid_len),
78 + ssid->id);
79 + wpas_notify_mesh_group_started(wpa_s, ssid);
80 + }
81 +
82 return ret;
83 }
84
85 @@ -563,7 +570,7 @@ int wpa_supplicant_join_mesh(struct wpa_
86 wpa_s->mesh_params = params;
87 if (wpa_supplicant_mesh_init(wpa_s, ssid, &params->freq)) {
88 wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh");
89 - wpa_drv_leave_mesh(wpa_s);
90 + wpa_supplicant_leave_mesh(wpa_s, true);
91 ret = -1;
92 goto out;
93 }
94 @@ -573,14 +580,15 @@ out:
95 }
96
97
98 -int wpa_supplicant_leave_mesh(struct wpa_supplicant *wpa_s)
99 +int wpa_supplicant_leave_mesh(struct wpa_supplicant *wpa_s, bool need_deinit)
100 {
101 int ret = 0;
102
103 wpa_msg(wpa_s, MSG_INFO, "leaving mesh");
104
105 /* Need to send peering close messages first */
106 - wpa_supplicant_mesh_deinit(wpa_s);
107 + if (need_deinit)
108 + wpa_supplicant_mesh_deinit(wpa_s);
109
110 ret = wpa_drv_leave_mesh(wpa_s);
111 if (ret)
112 --- a/wpa_supplicant/mesh.h
113 +++ b/wpa_supplicant/mesh.h
114 @@ -11,9 +11,11 @@
115
116 int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
117 struct wpa_ssid *ssid);
118 -int wpa_supplicant_leave_mesh(struct wpa_supplicant *wpa_s);
119 +int wpa_supplicant_leave_mesh(struct wpa_supplicant *wpa_s,
120 + bool need_deinit);
121 void wpa_supplicant_mesh_iface_deinit(struct wpa_supplicant *wpa_s,
122 - struct hostapd_iface *ifmsh);
123 + struct hostapd_iface *ifmsh,
124 + bool also_clear_hostapd);
125 int wpas_mesh_scan_result_text(const u8 *ies, size_t ies_len, char *buf,
126 char *end);
127 int wpas_mesh_add_interface(struct wpa_supplicant *wpa_s, char *ifname,
128 --- a/wpa_supplicant/wpa_supplicant.c
129 +++ b/wpa_supplicant/wpa_supplicant.c
130 @@ -2225,10 +2225,6 @@ void wpa_supplicant_associate(struct wpa
131 return;
132 }
133 wpa_s->current_bss = bss;
134 - wpa_msg(wpa_s, MSG_INFO, MESH_GROUP_STARTED "ssid=\"%s\" id=%d",
135 - wpa_ssid_txt(ssid->ssid, ssid->ssid_len),
136 - ssid->id);
137 - wpas_notify_mesh_group_started(wpa_s, ssid);
138 #else /* CONFIG_MESH */
139 wpa_msg(wpa_s, MSG_ERROR,
140 "mesh mode support not included in the build");
141 @@ -3938,7 +3934,7 @@ void wpa_supplicant_deauthenticate(struc
142 wpa_s->ifname);
143 wpas_notify_mesh_group_removed(wpa_s, mconf->meshid,
144 mconf->meshid_len, reason_code);
145 - wpa_supplicant_leave_mesh(wpa_s);
146 + wpa_supplicant_leave_mesh(wpa_s, true);
147 }
148 #endif /* CONFIG_MESH */
149
150 @@ -6551,7 +6547,7 @@ static void wpa_supplicant_deinit_iface(
151
152 #ifdef CONFIG_MESH
153 if (wpa_s->ifmsh) {
154 - wpa_supplicant_mesh_iface_deinit(wpa_s, wpa_s->ifmsh);
155 + wpa_supplicant_mesh_iface_deinit(wpa_s, wpa_s->ifmsh, true);
156 wpa_s->ifmsh = NULL;
157 }
158 #endif /* CONFIG_MESH */