018-mesh-make-forwarding-configurable.patch 8.0 KB

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