004-mesh-use-setup-completion-callback-to-complete-mesh-.patch 3.9 KB

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