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