hostapd: fix mesh+AP
[openwrt/staging/chunkeey.git] / package / network / services / hostapd / patches / 021-mesh-make-forwarding-configurable.patch
1 From d11881c1ad0d6a102962d1a040a398f597256ae0 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Wed, 18 Apr 2018 19:24:31 +0200
4 Subject: [PATCH] mesh: make forwarding configurable
5 To: hostap@lists.infradead.org
6 Cc: Jouni Malinen <j@w1.fi>,
7 Johannes Berg <johannes.berg@intel.com>
8
9 Allow mesh_fwding to be specified in a mesh bss config, pass that
10 to the driver (only nl80211 implemented for now) and announce
11 forwarding capability accordingly.
12
13 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
14 ---
15 src/ap/ap_config.h | 2 ++
16 src/drivers/driver.h | 2 ++
17 src/drivers/driver_nl80211.c | 3 +++
18 wpa_supplicant/config.c | 4 ++++
19 wpa_supplicant/config.h | 3 +++
20 wpa_supplicant/config_file.c | 4 ++++
21 wpa_supplicant/config_ssid.h | 5 +++++
22 wpa_supplicant/mesh.c | 6 ++++++
23 wpa_supplicant/mesh_mpm.c | 4 ++--
24 wpa_supplicant/wpa_supplicant.conf | 6 ++++++
25 10 files changed, 37 insertions(+), 2 deletions(-)
26
27 --- a/src/ap/ap_config.h
28 +++ b/src/ap/ap_config.h
29 @@ -49,6 +49,7 @@ struct mesh_conf {
30 int dot11MeshRetryTimeout; /* msec */
31 int dot11MeshConfirmTimeout; /* msec */
32 int dot11MeshHoldingTimeout; /* msec */
33 + int mesh_fwding;
34 };
35
36 #define MAX_STA_COUNT 2007
37 @@ -612,6 +613,7 @@ struct hostapd_bss_config {
38
39 #define MESH_ENABLED BIT(0)
40 int mesh;
41 + int mesh_fwding;
42
43 u8 radio_measurements[RRM_CAPABILITIES_IE_LEN];
44
45 --- a/src/drivers/driver.h
46 +++ b/src/drivers/driver.h
47 @@ -1363,6 +1363,7 @@ struct wpa_driver_mesh_bss_params {
48 #define WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS 0x00000004
49 #define WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE 0x00000008
50 #define WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD 0x00000010
51 +#define WPA_DRIVER_MESH_CONF_FLAG_FORWARDING 0x00000020
52 /*
53 * TODO: Other mesh configuration parameters would go here.
54 * See NL80211_MESHCONF_* for all the mesh config parameters.
55 @@ -1372,6 +1373,7 @@ struct wpa_driver_mesh_bss_params {
56 int peer_link_timeout;
57 int max_peer_links;
58 int rssi_threshold;
59 + int forwarding;
60 u16 ht_opmode;
61 };
62
63 --- a/src/drivers/driver_nl80211.c
64 +++ b/src/drivers/driver_nl80211.c
65 @@ -9197,6 +9197,9 @@ static int nl80211_put_mesh_config(struc
66 if (((params->flags & WPA_DRIVER_MESH_CONF_FLAG_AUTO_PLINKS) &&
67 nla_put_u8(msg, NL80211_MESHCONF_AUTO_OPEN_PLINKS,
68 params->auto_plinks)) ||
69 + ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_FORWARDING) &&
70 + nla_put_u8(msg, NL80211_MESHCONF_FORWARDING,
71 + params->forwarding)) ||
72 ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS) &&
73 nla_put_u16(msg, NL80211_MESHCONF_MAX_PEER_LINKS,
74 params->max_peer_links)) ||
75 --- a/wpa_supplicant/config.c
76 +++ b/wpa_supplicant/config.c
77 @@ -2211,6 +2211,7 @@ static const struct parse_data ssid_fiel
78 #ifdef CONFIG_MESH
79 { INT_RANGE(mode, 0, 5) },
80 { INT_RANGE(no_auto_peer, 0, 1) },
81 + { INT_RANGE(mesh_fwding, 0, 1) },
82 { INT_RANGE(mesh_rssi_threshold, -255, 1) },
83 #else /* CONFIG_MESH */
84 { INT_RANGE(mode, 0, 4) },
85 @@ -2757,6 +2758,7 @@ void wpa_config_set_network_defaults(str
86 ssid->dot11MeshRetryTimeout = DEFAULT_MESH_RETRY_TIMEOUT;
87 ssid->dot11MeshConfirmTimeout = DEFAULT_MESH_CONFIRM_TIMEOUT;
88 ssid->dot11MeshHoldingTimeout = DEFAULT_MESH_HOLDING_TIMEOUT;
89 + ssid->mesh_fwding = DEFAULT_MESH_FWDING;
90 ssid->mesh_rssi_threshold = DEFAULT_MESH_RSSI_THRESHOLD;
91 #endif /* CONFIG_MESH */
92 #ifdef CONFIG_HT_OVERRIDES
93 @@ -3886,6 +3888,7 @@ struct wpa_config * wpa_config_alloc_emp
94 config->user_mpm = DEFAULT_USER_MPM;
95 config->max_peer_links = DEFAULT_MAX_PEER_LINKS;
96 config->mesh_max_inactivity = DEFAULT_MESH_MAX_INACTIVITY;
97 + config->mesh_fwding = DEFAULT_MESH_FWDING;
98 config->dot11RSNASAERetransPeriod =
99 DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD;
100 config->fast_reauth = DEFAULT_FAST_REAUTH;
101 @@ -4508,6 +4511,7 @@ static const struct global_parse_data gl
102 { INT(user_mpm), 0 },
103 { INT_RANGE(max_peer_links, 0, 255), 0 },
104 { INT(mesh_max_inactivity), 0 },
105 + { INT_RANGE(mesh_fwding, 0, 1), 0 },
106 { INT(dot11RSNASAERetransPeriod), 0 },
107 #endif /* CONFIG_MESH */
108 { INT(disable_scan_offload), 0 },
109 --- a/wpa_supplicant/config.h
110 +++ b/wpa_supplicant/config.h
111 @@ -18,6 +18,7 @@
112 #define DEFAULT_USER_MPM 1
113 #define DEFAULT_MAX_PEER_LINKS 99
114 #define DEFAULT_MESH_MAX_INACTIVITY 300
115 +#define DEFAULT_MESH_FWDING 1
116 /*
117 * The default dot11RSNASAERetransPeriod is defined as 40 ms in the standard,
118 * but use 1000 ms in practice to avoid issues on low power CPUs.
119 @@ -1269,6 +1270,8 @@ struct wpa_config {
120 */
121 int mesh_max_inactivity;
122
123 + int mesh_fwding;
124 +
125 /**
126 * dot11RSNASAERetransPeriod - Timeout to retransmit SAE Auth frame
127 *
128 --- a/wpa_supplicant/config_file.c
129 +++ b/wpa_supplicant/config_file.c
130 @@ -816,6 +816,7 @@ static void wpa_config_write_network(FIL
131 #endif /* IEEE8021X_EAPOL */
132 INT(mode);
133 INT(no_auto_peer);
134 + INT(mesh_fwding);
135 INT(frequency);
136 INT(fixed_freq);
137 #ifdef CONFIG_ACS
138 @@ -1433,6 +1434,9 @@ static void wpa_config_write_global(FILE
139 fprintf(f, "mesh_max_inactivity=%d\n",
140 config->mesh_max_inactivity);
141
142 + if (config->mesh_fwding != DEFAULT_MESH_FWDING)
143 + fprintf(f, "mesh_fwding=%d\n", config->mesh_fwding);
144 +
145 if (config->dot11RSNASAERetransPeriod !=
146 DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD)
147 fprintf(f, "dot11RSNASAERetransPeriod=%d\n",
148 --- a/wpa_supplicant/config_ssid.h
149 +++ b/wpa_supplicant/config_ssid.h
150 @@ -492,6 +492,11 @@ struct wpa_ssid {
151 int dot11MeshConfirmTimeout; /* msec */
152 int dot11MeshHoldingTimeout; /* msec */
153
154 + /**
155 + * Mesh network layer-2 forwarding
156 + */
157 + int mesh_fwding;
158 +
159 int ht;
160 int ht40;
161
162 --- a/wpa_supplicant/mesh.c
163 +++ b/wpa_supplicant/mesh.c
164 @@ -121,6 +121,7 @@ static struct mesh_conf * mesh_config_cr
165 conf->mesh_cc_id = 0;
166 conf->mesh_sp_id = MESH_SYNC_METHOD_NEIGHBOR_OFFSET;
167 conf->mesh_auth_id = (conf->security & MESH_CONF_SEC_AUTH) ? 1 : 0;
168 + conf->mesh_fwding = ssid->mesh_fwding;
169 conf->dot11MeshMaxRetries = ssid->dot11MeshMaxRetries;
170 conf->dot11MeshRetryTimeout = ssid->dot11MeshRetryTimeout;
171 conf->dot11MeshConfirmTimeout = ssid->dot11MeshConfirmTimeout;
172 @@ -256,6 +257,7 @@ static int wpa_supplicant_mesh_init(stru
173 bss->conf->start_disabled = 1;
174 bss->conf->mesh = MESH_ENABLED;
175 bss->conf->ap_max_inactivity = wpa_s->conf->mesh_max_inactivity;
176 + bss->conf->mesh_fwding = wpa_s->conf->mesh_fwding;
177
178 if (ieee80211_is_dfs(ssid->frequency) && wpa_s->conf->country[0]) {
179 conf->ieee80211h = 1;
180 @@ -508,6 +510,10 @@ int wpa_supplicant_join_mesh(struct wpa_
181 }
182 params->conf.peer_link_timeout = wpa_s->conf->mesh_max_inactivity;
183
184 + /* always explicitely set forwarding to on or off for now */
185 + params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_FORWARDING;
186 + params->conf.forwarding = ssid->mesh_fwding;
187 +
188 wpa_s->mesh_params = params;
189 if (wpa_supplicant_mesh_init(wpa_s, ssid, &params->freq)) {
190 wpa_msg(wpa_s, MSG_ERROR, "Failed to init mesh");
191 --- a/wpa_supplicant/mesh_mpm.c
192 +++ b/wpa_supplicant/mesh_mpm.c
193 @@ -288,9 +288,9 @@ static void mesh_mpm_send_plink_action(s
194 info = (bss->num_plinks > 63 ? 63 : bss->num_plinks) << 1;
195 /* TODO: Add Connected to Mesh Gate/AS subfields */
196 wpabuf_put_u8(buf, info);
197 - /* always forwarding & accepting plinks for now */
198 + /* set forwarding & always accepting plinks for now */
199 wpabuf_put_u8(buf, MESH_CAP_ACCEPT_ADDITIONAL_PEER |
200 - MESH_CAP_FORWARDING);
201 + (conf->mesh_fwding ? MESH_CAP_FORWARDING : 0));
202 } else { /* Peer closing frame */
203 /* IE: Mesh ID */
204 wpabuf_put_u8(buf, WLAN_EID_MESH_ID);
205 --- a/wpa_supplicant/wpa_supplicant.conf
206 +++ b/wpa_supplicant/wpa_supplicant.conf
207 @@ -153,6 +153,12 @@ ap_scan=1
208 # This timeout value is used in mesh STA to clean up inactive stations.
209 #mesh_max_inactivity=300
210
211 +# Enable 802.11s layer-2 routing and forwarding
212 +#mesh_fwding=1
213 +
214 +# Accept additional peer links
215 +#mesh_auto_open_plinks=1
216 +
217 # cert_in_cb - Whether to include a peer certificate dump in events
218 # This controls whether peer certificates for authentication server and
219 # its certificate chain are included in EAP peer certificate events. This is