[PATCH v2 BlueZ 3/3] src: make att max le mtu configurable in main.conf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/device.c  |  2 +-
 src/hcid.h    |  1 +
 src/main.c    | 16 ++++++++++++++++
 src/main.conf |  5 +++++
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/device.c b/src/device.c
index 4f1af7012..75340cabe 100644
--- a/src/device.c
+++ b/src/device.c
@@ -4986,7 +4986,7 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io)
 		}
 	}
 
-	dev->att_mtu = MIN(mtu, BT_ATT_MAX_LE_MTU);
+	dev->att_mtu = MIN(mtu, main_opts.gatt_max_le_mtu);
 	attrib = g_attrib_new(io,
 			cid == ATT_CID ? BT_ATT_DEFAULT_LE_MTU : dev->att_mtu,
 			false);
diff --git a/src/hcid.h b/src/hcid.h
index 2c2b89d9c..bcb077dde 100644
--- a/src/hcid.h
+++ b/src/hcid.h
@@ -54,6 +54,7 @@ struct main_opts {
 
 	bt_mode_t	mode;
 	bt_gatt_cache_t gatt_cache;
+	uint16_t	gatt_max_le_mtu;
 
 	uint8_t		min_enc_key_size;
 };
diff --git a/src/main.c b/src/main.c
index 7e6af42cd..5e19d68b3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,6 +50,7 @@
 #include "log.h"
 #include "backtrace.h"
 
+#include "shared/att-types.h"
 #include "lib/uuid.h"
 #include "hcid.h"
 #include "sdpd.h"
@@ -104,6 +105,7 @@ static const char *policy_options[] = {
 static const char *gatt_options[] = {
 	"Cache",
 	"MinEncKeySize",
+	"MaxLeMtu",
 	NULL
 };
 
@@ -419,6 +421,18 @@ static void parse_config(GKeyFile *config)
 		if (val >=7 && val <= 16)
 			main_opts.min_enc_key_size = val;
 	}
+
+	val = g_key_file_get_integer(config, "GATT",
+						"MaxLeMtu", &err);
+	if (err) {
+		g_clear_error(&err);
+	} else {
+		/* Ensure the mtu is within a valid range. */
+		val = MIN(val, BT_ATT_MAX_LE_MTU);
+		val = MAX(val, BT_ATT_DEFAULT_LE_MTU);
+		DBG("gatt_max_le_mtu=%d", val);
+		main_opts.gatt_max_le_mtu = val;
+	}
 }
 
 static void init_defaults(void)
@@ -442,6 +456,8 @@ static void init_defaults(void)
 	main_opts.did_vendor = 0x1d6b;		/* Linux Foundation */
 	main_opts.did_product = 0x0246;		/* BlueZ */
 	main_opts.did_version = (major << 8 | minor);
+
+	main_opts.gatt_max_le_mtu = BT_ATT_MAX_LE_MTU;
 }
 
 static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
diff --git a/src/main.conf b/src/main.conf
index cbae32ec5..a22d685b2 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -82,6 +82,11 @@
 # Defaults to 0
 # MinEncKeySize = 0
 
+# Maximum MTU size.
+# Possible values: 23-517
+# Defaults to 517
+# MaxLeMtu = 517
+
 [Policy]
 #
 # The ReconnectUUIDs defines the set of remote services that should try
--
2.18.0

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux