[PATCH] mesh: Make mesh ttl configurable

Thiyagarajan Pandiyan thiyagarajan at aerlync.com
Mon Apr 20 23:23:36 PDT 2026


Allow mesh_ttl (dot11MeshTTL) to be configurable, pass that to the
driver (only nl80211 implemented).

Signed-off-by: Thiyagarajan Pandiyan <thiyagarajan at aerlync.com>
---
 src/drivers/driver.h               | 2 ++
 src/drivers/driver_nl80211.c       | 4 ++++
 wpa_supplicant/config.c            | 2 ++
 wpa_supplicant/config.h            | 8 ++++++++
 wpa_supplicant/config_file.c       | 3 +++
 wpa_supplicant/wpa_supplicant.conf | 3 +++
 6 files changed, 22 insertions(+)

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 3807fc0f8..e71e1c86d 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1942,6 +1942,7 @@ struct wpa_driver_mesh_bss_params {
 #define WPA_DRIVER_MESH_CONF_FLAG_HT_OP_MODE		0x00000008
 #define WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD	0x00000010
 #define WPA_DRIVER_MESH_CONF_FLAG_FORWARDING		0x00000020
+#define WPA_DRIVER_MESH_CONF_FLAG_TTL			0x00000040
 	/*
 	 * TODO: Other mesh configuration parameters would go here.
 	 * See NL80211_MESHCONF_* for all the mesh config parameters.
@@ -1952,6 +1953,7 @@ struct wpa_driver_mesh_bss_params {
 	int max_peer_links;
 	int rssi_threshold;
 	int forwarding;
+	int mesh_ttl;
 	u16 ht_opmode;
 };
 
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index e87aecc58..5ed940c4b 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -12803,6 +12803,9 @@ static int nl80211_put_mesh_config(struct nl_msg *msg,
 	    ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS) &&
 	     nla_put_u16(msg, NL80211_MESHCONF_MAX_PEER_LINKS,
 			 params->max_peer_links)) ||
+	    ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_TTL) &&
+	     nla_put_u32(msg, NL80211_MESHCONF_TTL,
+			 params->mesh_ttl)) ||
 	    ((params->flags & WPA_DRIVER_MESH_CONF_FLAG_RSSI_THRESHOLD) &&
 	     nla_put_u32(msg, NL80211_MESHCONF_RSSI_THRESHOLD,
 			 params->rssi_threshold)))
@@ -12881,6 +12884,7 @@ static int nl80211_join_mesh(struct i802_bss *bss,
 	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_AUTO_PLINKS;
 	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_PEER_LINK_TIMEOUT;
 	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_MAX_PEER_LINKS;
+	params->conf.flags |= WPA_DRIVER_MESH_CONF_FLAG_TTL;
 	if (nl80211_put_mesh_config(msg, &params->conf) < 0)
 		goto fail;
 
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index e99036366..3e98f3794 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -4913,6 +4913,7 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
 	config->max_peer_links = DEFAULT_MAX_PEER_LINKS;
 	config->mesh_max_inactivity = DEFAULT_MESH_MAX_INACTIVITY;
 	config->mesh_fwding = DEFAULT_MESH_FWDING;
+	config->mesh_ttl = DEFAULT_MESH_TTL;
 	config->dot11RSNASAERetransPeriod =
 		DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD;
 	config->fast_reauth = DEFAULT_FAST_REAUTH;
@@ -5819,6 +5820,7 @@ static const struct global_parse_data global_fields[] = {
 	{ INT_RANGE(max_peer_links, 0, 255), 0 },
 	{ INT(mesh_max_inactivity), 0 },
 	{ INT_RANGE(mesh_fwding, 0, 1), 0 },
+	{ INT_RANGE(mesh_ttl, 1, 255), 0 },
 	{ INT(dot11RSNASAERetransPeriod), 0 },
 #endif /* CONFIG_MESH */
 	{ INT(disable_scan_offload), 0 },
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index b3f7cd062..e9cd418ff 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -19,6 +19,7 @@
 #define DEFAULT_MAX_PEER_LINKS 99
 #define DEFAULT_MESH_MAX_INACTIVITY 300
 #define DEFAULT_MESH_FWDING 1
+#define DEFAULT_MESH_TTL 31
 /*
  * The default dot11RSNASAERetransPeriod is defined as 40 ms in the standard,
  * but use 1000 ms in practice to avoid issues on low power CPUs.
@@ -1539,6 +1540,13 @@ struct wpa_config {
 	 */
 	int mesh_fwding;
 
+	/**
+	 * mesh_ttl - Mesh action frames Time-to-live
+	 *
+	 * Maximum number of hops that the mesh frames shall be forwarded
+	 */
+	int mesh_ttl;
+
 	/**
 	 * dot11RSNASAERetransPeriod - Timeout to retransmit SAE Auth frame
 	 *
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 81d92b7dd..40856c7a3 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -1690,6 +1690,9 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
 	if (config->mesh_fwding != DEFAULT_MESH_FWDING)
 		fprintf(f, "mesh_fwding=%d\n", config->mesh_fwding);
 
+	if (config->mesh_ttl != DEFAULT_MESH_TTL)
+		fprintf(f, "mesh_ttl=%d\n", config->mesh_ttl);
+
 	if (config->dot11RSNASAERetransPeriod !=
 	    DEFAULT_DOT11_RSNA_SAE_RETRANS_PERIOD)
 		fprintf(f, "dot11RSNASAERetransPeriod=%d\n",
diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf
index 56533cb17..1b9e4ac81 100644
--- a/wpa_supplicant/wpa_supplicant.conf
+++ b/wpa_supplicant/wpa_supplicant.conf
@@ -153,6 +153,9 @@ ap_scan=1
 # Enable 802.11s layer-2 routing and forwarding (dot11MeshForwarding)
 #mesh_fwding=1
 
+# Maximum number of hops that the mesh frames shall be forwarded
+#mesh_ttl=31
+
 # cert_in_cb - Whether to include a peer certificate dump in events
 # This controls whether peer certificates for authentication server and
 # its certificate chain are included in EAP peer certificate events. This is
-- 
2.43.0




More information about the Hostap mailing list