021-mesh-make-forwarding-configurable.patch 7.9 KB

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