0101-mesh-factor-out-mesh-join-function.patch 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. From 91c0f3f6a9ecae3c9106bef8a8606fab0792dd28 Mon Sep 17 00:00:00 2001
  2. From: Peter Oh <[email protected]>
  3. Date: Thu, 12 Apr 2018 02:48:58 -0700
  4. Subject: [PATCH 01/15] mesh: factor out mesh join function
  5. mesh join function consitss of 2 parts which are preparing
  6. configurations and sending join event to driver.
  7. Since physical mesh join event could happen either right
  8. after mesh configuration is done or after CAC is done
  9. in case of DFS channel is used, factor out the function
  10. into 2 parts to reduce redundant calls.
  11. Signed-off-by: Peter Oh <[email protected]>
  12. ---
  13. wpa_supplicant/mesh.c | 120 ++++++++++++++++--------------
  14. wpa_supplicant/mesh.h | 1 +
  15. wpa_supplicant/wpa_supplicant_i.h | 1 +
  16. 3 files changed, 68 insertions(+), 54 deletions(-)
  17. --- a/wpa_supplicant/mesh.c
  18. +++ b/wpa_supplicant/mesh.c
  19. @@ -25,6 +25,7 @@
  20. #include "mesh_mpm.h"
  21. #include "mesh_rsn.h"
  22. #include "mesh.h"
  23. +#include "drivers/driver_nl80211.h"
  24. static void wpa_supplicant_mesh_deinit(struct wpa_supplicant *wpa_s)
  25. @@ -359,13 +360,48 @@ void wpa_supplicant_mesh_add_scan_ie(str
  26. }
  27. +void wpas_join_mesh(struct wpa_supplicant *wpa_s)
  28. +{
  29. + struct wpa_driver_mesh_join_params *params = wpa_s->mesh_params;
  30. + struct wpa_ssid *ssid = wpa_s->current_ssid;
  31. + int ret = 0;
  32. +
  33. + if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
  34. + wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
  35. + wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
  36. + wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
  37. + }
  38. +
  39. + if (wpa_s->ifmsh) {
  40. + params->ies = wpa_s->ifmsh->mconf->rsn_ie;
  41. + params->ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
  42. + params->basic_rates = wpa_s->ifmsh->basic_rates;
  43. + params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
  44. + params->conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
  45. + }
  46. +
  47. + ret = wpa_drv_join_mesh(wpa_s, params);
  48. + if (ret)
  49. + wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d\n", ret);
  50. +
  51. + /* hostapd sets the interface down until we associate */
  52. + wpa_drv_set_operstate(wpa_s, 1);
  53. +
  54. + if (!ret)
  55. + wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
  56. +
  57. + return;
  58. +}
  59. +
  60. +
  61. int wpa_supplicant_join_mesh(struct wpa_supplicant *wpa_s,
  62. struct wpa_ssid *ssid)
  63. {
  64. - struct wpa_driver_mesh_join_params params;
  65. + struct wpa_driver_mesh_join_params *params =
  66. + os_zalloc(sizeof(struct wpa_driver_mesh_join_params));
  67. int ret = 0;
  68. - if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency) {
  69. + if (!ssid || !ssid->ssid || !ssid->ssid_len || !ssid->frequency || !params) {
  70. ret = -ENOENT;
  71. goto out;
  72. }
  73. @@ -376,22 +412,22 @@ int wpa_supplicant_join_mesh(struct wpa_
  74. wpa_s->group_cipher = WPA_CIPHER_NONE;
  75. wpa_s->mgmt_group_cipher = 0;
  76. - os_memset(&params, 0, sizeof(params));
  77. - params.meshid = ssid->ssid;
  78. - params.meshid_len = ssid->ssid_len;
  79. - ibss_mesh_setup_freq(wpa_s, ssid, &params.freq);
  80. - wpa_s->mesh_ht_enabled = !!params.freq.ht_enabled;
  81. - wpa_s->mesh_vht_enabled = !!params.freq.vht_enabled;
  82. - if (params.freq.ht_enabled && params.freq.sec_channel_offset)
  83. - ssid->ht40 = params.freq.sec_channel_offset;
  84. + params->meshid = ssid->ssid;
  85. + params->meshid_len = ssid->ssid_len;
  86. + ibss_mesh_setup_freq(wpa_s, ssid, &params->freq);
  87. + wpa_s->mesh_ht_enabled = !!params->freq.ht_enabled;
  88. + wpa_s->mesh_vht_enabled = !!params->freq.vht_enabled;
  89. + if (params->freq.ht_enabled && params->freq.sec_channel_offset)
  90. + ssid->ht40 = params->freq.sec_channel_offset;
  91. +
  92. if (wpa_s->mesh_vht_enabled) {
  93. ssid->vht = 1;
  94. - switch (params.freq.bandwidth) {
  95. + switch (params->freq.bandwidth) {
  96. case 80:
  97. - if (params.freq.center_freq2) {
  98. + if (params->freq.center_freq2) {
  99. ssid->max_oper_chwidth = VHT_CHANWIDTH_80P80MHZ;
  100. ssid->vht_center_freq2 =
  101. - params.freq.center_freq2;
  102. + params->freq.center_freq2;
  103. } else {
  104. ssid->max_oper_chwidth = VHT_CHANWIDTH_80MHZ;
  105. }
  106. @@ -405,67 +441,43 @@ int wpa_supplicant_join_mesh(struct wpa_
  107. }
  108. }
  109. if (ssid->beacon_int > 0)
  110. - params.beacon_int = ssid->beacon_int;
  111. + params->beacon_int = ssid->beacon_int;
  112. else if (wpa_s->conf->beacon_int > 0)
  113. - params.beacon_int = wpa_s->conf->beacon_int;
  114. + params->beacon_int = wpa_s->conf->beacon_int;
  115. if (ssid->dtim_period > 0)
  116. - params.dtim_period = ssid->dtim_period;
  117. + params->dtim_period = ssid->dtim_period;
  118. else if (wpa_s->conf->dtim_period > 0)
  119. - params.dtim_period = wpa_s->conf->dtim_period;
  120. - params.conf.max_peer_links = wpa_s->conf->max_peer_links;
  121. + params->dtim_period = wpa_s->conf->dtim_period;
  122. + params->conf.max_peer_links = wpa_s->conf->max_peer_links;
  123. if (ssid->mesh_rssi_threshold < DEFAULT_MESH_RSSI_THRESHOLD) {
  124. - params.conf.rssi_threshold = ssid->mesh_rssi_threshold;
  125. - params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
  126. + params->conf.rssi_threshold = ssid->mesh_rssi_threshold;
  127. + params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD;
  128. }
  129. if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
  130. - params.flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
  131. - params.flags |= WPA_DRIVER_MESH_FLAG_AMPE;
  132. + params->flags |= WPA_DRIVER_MESH_FLAG_SAE_AUTH;
  133. + params->flags |= WPA_DRIVER_MESH_FLAG_AMPE;
  134. wpa_s->conf->user_mpm = 1;
  135. }
  136. if (wpa_s->conf->user_mpm) {
  137. - params.flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
  138. - params.conf.auto_plinks = 0;
  139. + params->flags |= WPA_DRIVER_MESH_FLAG_USER_MPM;
  140. + params->conf.auto_plinks = 0;
  141. } else {
  142. - params.flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
  143. - params.conf.auto_plinks = 1;
  144. + params->flags |= WPA_DRIVER_MESH_FLAG_DRIVER_MPM;
  145. + params->conf.auto_plinks = 1;
  146. }
  147. - params.conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
  148. + params->conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
  149. - if (wpa_supplicant_mesh_init(wpa_s, ssid, &params.freq)) {
  150. + wpa_s->mesh_params = params;
  151. + if (wpa_supplicant_mesh_init(wpa_s, ssid, &params->freq)) {
  152. wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh");
  153. wpa_drv_leave_mesh(wpa_s);
  154. ret = -1;
  155. goto out;
  156. }
  157. - if (ssid->key_mgmt & WPA_KEY_MGMT_SAE) {
  158. - wpa_s->pairwise_cipher = wpa_s->mesh_rsn->pairwise_cipher;
  159. - wpa_s->group_cipher = wpa_s->mesh_rsn->group_cipher;
  160. - wpa_s->mgmt_group_cipher = wpa_s->mesh_rsn->mgmt_group_cipher;
  161. - }
  162. -
  163. - if (wpa_s->ifmsh) {
  164. - params.ies = wpa_s->ifmsh->mconf->rsn_ie;
  165. - params.ie_len = wpa_s->ifmsh->mconf->rsn_ie_len;
  166. - params.basic_rates = wpa_s->ifmsh->basic_rates;
  167. - params.conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE;
  168. - params.conf.ht_opmode = wpa_s->ifmsh->bss[0]->iface->ht_op_mode;
  169. - }
  170. -
  171. - wpa_msg(wpa_s, MSG_INFO, "joining mesh %s",
  172. - wpa_ssid_txt(ssid->ssid, ssid->ssid_len));
  173. - ret = wpa_drv_join_mesh(wpa_s, &params);
  174. - if (ret)
  175. - wpa_msg(wpa_s, MSG_ERROR, "mesh join error=%d", ret);
  176. -
  177. - /* hostapd sets the interface down until we associate */
  178. - wpa_drv_set_operstate(wpa_s, 1);
  179. -
  180. - if (!ret)
  181. - wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
  182. -
  183. + wpas_join_mesh(wpa_s);
  184. out:
  185. return ret;
  186. }
  187. --- a/wpa_supplicant/mesh.h
  188. +++ b/wpa_supplicant/mesh.h
  189. @@ -21,6 +21,7 @@ int wpas_mesh_add_interface(struct wpa_s
  190. int wpas_mesh_peer_remove(struct wpa_supplicant *wpa_s, const u8 *addr);
  191. int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
  192. int duration);
  193. +void wpas_join_mesh(struct wpa_supplicant *wpa_s);
  194. #ifdef CONFIG_MESH
  195. --- a/wpa_supplicant/wpa_supplicant_i.h
  196. +++ b/wpa_supplicant/wpa_supplicant_i.h
  197. @@ -810,6 +810,7 @@ struct wpa_supplicant {
  198. unsigned int mesh_if_created:1;
  199. unsigned int mesh_ht_enabled:1;
  200. unsigned int mesh_vht_enabled:1;
  201. + struct wpa_driver_mesh_join_params *mesh_params;
  202. #ifdef CONFIG_PMKSA_CACHE_EXTERNAL
  203. /* struct external_pmksa_cache::list */
  204. struct dl_list mesh_external_pmksa_cache;