Skip to contentSkip to conversation

main.conf: Introduce MaxControllers

PATCH In review Luiz Augusto von Dentz 2 participants 4 messages Feb 17, 2022 – Feb 18, 2022 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 main.conf: Introduce MaxControllers

From: Luiz Augusto von Dentz <[email protected]>

This introduces MaxControllers which can be used to limit the number of adapters exposed in the system.

---
 src/adapter.c | 7 +++++++
 src/btd.h     | 1 +
 src/main.c    | 9 +++++++++
 src/main.conf | 4 ++++
 4 files changed, 21 insertions(+)
src/adapter.c +7 -0
index 2071cf8db..1551011a8 100644
@@ -10078,6 +10078,13 @@ static void index_added(uint16_t index, uint16_t length, const void *param,
 		return;
 	}
 
+	/* Check if at maximum adapters allowed in the system then ignore the
+	 * adapter.
+	 */
+	if (btd_opts.max_adapters &&
+			btd_opts.max_adapters == g_slist_length(adapters))
+		return;
+
 	reset_adv_monitors(index);
 
 	adapter = btd_adapter_new(index);
src/btd.h +1 -0
index a805a40d7..d13646889 100644
@@ -121,6 +121,7 @@ struct btd_opts {
 	uint16_t	did_version;
 
 	bt_mode_t	mode;
+	uint16_t	max_adapters;
 	bt_gatt_cache_t gatt_cache;
 	uint16_t	gatt_mtu;
 	uint8_t		gatt_channels;
src/main.c +9 -0
index 8cc2dfca6..bf9d398e4 100644
@@ -77,6 +77,7 @@ static const char *supported_options[] = {
 	"NameResolving",
 	"DebugKeys",
 	"ControllerMode",
+	"MaxControllers"
 	"MultiProfile",
 	"FastConnectable",
 	"Privacy",
@@ -779,6 +780,14 @@ static void parse_config(GKeyFile *config)
 		g_free(str);
 	}
 
+	val = g_key_file_get_integer(config, "General", "MaxControllers", &err);
+	if (err) {
+		g_clear_error(&err);
+	} else {
+		DBG("MaxControllers=%d", val);
+		btd_opts.max_adapters = val;
+	}
+
 	str = g_key_file_get_string(config, "General", "MultiProfile", &err);
 	if (err) {
 		g_clear_error(&err);
src/main.conf +4 -0
index 49b9e6755..401796235 100644
@@ -51,6 +51,10 @@
 # Possible values: "dual", "bredr", "le"
 #ControllerMode = dual
 
+# Maximum number of controllers allowed to be exposed to the system.
+# Default=0 (unlimited)
+#MaxControllers=0
+
 # Enables Multi Profile Specification support. This allows to specify if
 # system supports only Multiple Profiles Single Device (MPSD) configuration
 # or both Multiple Profiles Single Device (MPSD) and Multiple Profiles Multiple
Signature · 1 line
2.35.1
author maintainer
#1 lore raw

PATCH 2/2 adapter: Fix allowing multiple adapters with the same address

From: Luiz Augusto von Dentz <[email protected]>

The bdaddr of an adapter is used for its unique storage path so having multiple adapters with the same address would likely cause problems with its storage as they would be shared.

---
 src/adapter.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
src/adapter.c +10 -0
index 1551011a8..97ce26f8e 100644
@@ -9807,6 +9807,16 @@ static void read_info_complete(uint8_t status, uint16_t length,
 			goto failed;
 		}
 	} else {
+		struct btd_adapter *tmp;
+
+		tmp = adapter_find(&rp->bdaddr);
+		if (tmp) {
+			btd_error(adapter->dev_id,
+				"Bluetooth address for index %u match index %u",
+				adapter->dev_id, tmp->dev_id);
+			goto failed;
+		}
+
 		bacpy(&adapter->bdaddr, &rp->bdaddr);
 		if (!(adapter->supported_settings & MGMT_SETTING_LE))
 			adapter->bdaddr_type = BDADDR_BREDR;
Signature · 1 line
2.35.1
#2 lore raw
In reply to Luiz Augusto von Dentz

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=615589

---Test result---

Test Summary:

CheckPatch                    PASS      3.20 seconds
GitLint                       PASS      2.11 seconds
Prep - Setup ELL              PASS      51.36 seconds
Build - Prep                  PASS      0.78 seconds
Build - Configure             PASS      10.27 seconds
Build - Make                  PASS      1447.42 seconds
Make Check                    PASS      12.29 seconds
Make Check w/Valgrind         PASS      524.58 seconds
Make Distcheck                PASS      273.84 seconds
Build w/ext ELL - Configure   PASS      10.39 seconds
Build w/ext ELL - Make        PASS      1438.64 seconds
Incremental Build with patchesPASS      2933.71 seconds

---
Regards,
Linux Bluetooth

author maintainer
#3 lore raw

Hi,

Quoted 27 lines · On Thu, Feb 17, 2022 at 7:20 PM <[email protected]> wrote:

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=615589

---Test result---

Test Summary:

CheckPatch                    PASS      3.20 seconds
GitLint                       PASS      2.11 seconds
Prep - Setup ELL              PASS      51.36 seconds
Build - Prep                  PASS      0.78 seconds
Build - Configure             PASS      10.27 seconds
Build - Make                  PASS      1447.42 seconds
Make Check                    PASS      12.29 seconds
Make Check w/Valgrind         PASS      524.58 seconds
Make Distcheck                PASS      273.84 seconds
Build w/ext ELL - Configure   PASS      10.39 seconds
Build w/ext ELL - Make        PASS      1438.64 seconds
Incremental Build with patchesPASS      2933.71 seconds
Quoted 4 lines

---
Regards,
Linux Bluetooth

Pushed.

Signature · 1 line
Luiz Augusto von Dentz