0102-mesh-factor-out-rsn-initialization.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. From 04ebcadc059a6cfd45cd8ec06e6321b69bdb68b8 Mon Sep 17 00:00:00 2001
  2. From: Peter Oh <[email protected]>
  3. Date: Thu, 12 Apr 2018 02:48:59 -0700
  4. Subject: [PATCH 02/15] mesh: factor out rsn initialization
  5. RSN initialization can be used in different phases
  6. if mesh initialization and mesh join don't happen
  7. in sequence such as DFS CAC is done in between,
  8. hence factor it out to help convering the case.
  9. Signed-off-by: Peter Oh <[email protected]>
  10. ---
  11. wpa_supplicant/mesh.c | 73 ++++++++++++++++++++++++++-----------------
  12. wpa_supplicant/mesh.h | 1 +
  13. 2 files changed, 45 insertions(+), 29 deletions(-)
  14. --- a/wpa_supplicant/mesh.c
  15. +++ b/wpa_supplicant/mesh.c
  16. @@ -147,6 +147,48 @@ static void wpas_mesh_copy_groups(struct
  17. groups_size);
  18. }
  19. +int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s)
  20. +{
  21. + struct hostapd_iface *ifmsh = wpa_s->ifmsh;
  22. + struct mesh_conf *mconf = wpa_s->ifmsh->mconf;
  23. + struct wpa_ssid *ssid = wpa_s->current_ssid;
  24. + struct hostapd_data *bss = ifmsh->bss[0];
  25. + static int default_groups[] = { 19, 20, 21, 25, 26, -1 };
  26. + size_t len;
  27. +
  28. + if (mconf->security != MESH_CONF_SEC_NONE) {
  29. + if (ssid->passphrase == NULL) {
  30. + wpa_printf(MSG_ERROR,
  31. + "mesh: Passphrase for SAE not configured");
  32. + return -1;
  33. + }
  34. +
  35. + bss->conf->wpa = ssid->proto;
  36. + bss->conf->wpa_key_mgmt = ssid->key_mgmt;
  37. +
  38. + if (wpa_s->conf->sae_groups &&
  39. + wpa_s->conf->sae_groups[0] > 0) {
  40. + wpas_mesh_copy_groups(bss, wpa_s);
  41. + } else {
  42. + bss->conf->sae_groups =
  43. + os_memdup(default_groups,
  44. + sizeof(default_groups));
  45. + if (!bss->conf->sae_groups)
  46. + return -1;
  47. + }
  48. +
  49. + len = os_strlen(ssid->passphrase);
  50. + bss->conf->ssid.wpa_passphrase =
  51. + dup_binstr(ssid->passphrase, len);
  52. +
  53. + wpa_s->mesh_rsn = mesh_rsn_auth_init(wpa_s, mconf);
  54. + if (!wpa_s->mesh_rsn)
  55. + return -1;
  56. + }
  57. +
  58. + return 0;
  59. +}
  60. +
  61. static int wpa_supplicant_mesh_init(struct wpa_supplicant *wpa_s,
  62. struct wpa_ssid *ssid,
  63. @@ -291,35 +333,8 @@ static int wpa_supplicant_mesh_init(stru
  64. return -1;
  65. }
  66. - if (mconf->security != MESH_CONF_SEC_NONE) {
  67. - if (ssid->passphrase == NULL) {
  68. - wpa_printf(MSG_ERROR,
  69. - "mesh: Passphrase for SAE not configured");
  70. - goto out_free;
  71. - }
  72. -
  73. - bss->conf->wpa = ssid->proto;
  74. - bss->conf->wpa_key_mgmt = ssid->key_mgmt;
  75. -
  76. - if (wpa_s->conf->sae_groups &&
  77. - wpa_s->conf->sae_groups[0] > 0) {
  78. - wpas_mesh_copy_groups(bss, wpa_s);
  79. - } else {
  80. - bss->conf->sae_groups =
  81. - os_memdup(default_groups,
  82. - sizeof(default_groups));
  83. - if (!bss->conf->sae_groups)
  84. - goto out_free;
  85. - }
  86. -
  87. - len = os_strlen(ssid->passphrase);
  88. - bss->conf->ssid.wpa_passphrase =
  89. - dup_binstr(ssid->passphrase, len);
  90. -
  91. - wpa_s->mesh_rsn = mesh_rsn_auth_init(wpa_s, mconf);
  92. - if (!wpa_s->mesh_rsn)
  93. - goto out_free;
  94. - }
  95. + if (wpas_mesh_init_rsn(wpa_s))
  96. + goto out_free;
  97. wpa_supplicant_conf_ap_ht(wpa_s, ssid, conf);
  98. --- a/wpa_supplicant/mesh.h
  99. +++ b/wpa_supplicant/mesh.h
  100. @@ -22,6 +22,7 @@ int wpas_mesh_peer_remove(struct wpa_sup
  101. int wpas_mesh_peer_add(struct wpa_supplicant *wpa_s, const u8 *addr,
  102. int duration);
  103. void wpas_join_mesh(struct wpa_supplicant *wpa_s);
  104. +int wpas_mesh_init_rsn(struct wpa_supplicant *wpa_s);
  105. #ifdef CONFIG_MESH