001-mesh-factor-out-mesh-join-function.patch 7.3 KB

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