* [Bluez PATCH v1 1/2] plugins/admin: add adapter_remove handler
@ 2021-09-06 3:40 Howard Chung
2021-09-06 3:40 ` [Bluez PATCH v1 2/2] plugins/admin: create admin_policy_settings if not exists Howard Chung
2021-09-06 3:55 ` [Bluez,v1,1/2] plugins/admin: add adapter_remove handler bluez.test.bot
0 siblings, 2 replies; 3+ messages in thread
From: Howard Chung @ 2021-09-06 3:40 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz; +Cc: Yun-Hao Chung, Shyh-In Hwang, Miao-chen Chou
From: Yun-Hao Chung <howardchung@chromium.org>
Currently admin doesn't handle adapter removed callbacks, which causes
interfaces AdminPolicySet1 and AdminPolicyStatus1 not being
unregistered, which in turns causes these interfaces can not be
re-registered once adapter is back.
This adds handler for adapter_remove.
Reviewed-by: Shyh-In Hwang <josephsih@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
---
tested with following steps
1. rmmod btusb
2. modprobe btusb
3. read allowlist via bluetoothctl
plugins/admin.c | 37 ++++++++++++++++++++++++++++++-------
1 file changed, 30 insertions(+), 7 deletions(-)
diff --git a/plugins/admin.c b/plugins/admin.c
index 02fec04568ba..9440581409fa 100644
--- a/plugins/admin.c
+++ b/plugins/admin.c
@@ -85,6 +85,19 @@ static void admin_policy_free(void *data)
g_free(admin_policy);
}
+static void admin_policy_destroy(struct btd_admin_policy *admin_policy)
+{
+ char *path = adapter_get_path(admin_policy->adapter);
+
+ g_dbus_unregister_interface(dbus_conn, path,
+ ADMIN_POLICY_SET_INTERFACE);
+ g_dbus_unregister_interface(dbus_conn, path,
+ ADMIN_POLICY_STATUS_INTERFACE);
+ g_dbus_unregister_interface(dbus_conn, path,
+ MOCK_ADMIN_POLICY_INTERFACE);
+ admin_policy_free(admin_policy);
+}
+
static bool uuid_match(const void *data, const void *match_data)
{
const bt_uuid_t *uuid = data;
@@ -492,7 +505,7 @@ static int admin_policy_adapter_probe(struct btd_adapter *adapter)
if (!g_dbus_register_interface(dbus_conn, adapter_path,
ADMIN_POLICY_SET_INTERFACE,
admin_policy_adapter_methods, NULL,
- NULL, policy_data, admin_policy_free)) {
+ NULL, policy_data, NULL)) {
btd_error(policy_data->adapter_id,
"Admin Policy Set interface init failed on path %s",
adapter_path);
@@ -506,7 +519,7 @@ static int admin_policy_adapter_probe(struct btd_adapter *adapter)
ADMIN_POLICY_STATUS_INTERFACE,
NULL, NULL,
admin_policy_adapter_properties,
- policy_data, admin_policy_free)) {
+ policy_data, NULL)) {
btd_error(policy_data->adapter_id,
"Admin Policy Status interface init failed on path %s",
adapter_path);
@@ -574,10 +587,24 @@ static void admin_policy_device_removed(struct btd_adapter *adapter,
unregister_device_data(data, NULL);
}
+static void admin_policy_remove(void)
+{
+ DBG("");
+
+ queue_foreach(devices, unregister_device_data, NULL);
+ queue_destroy(devices, g_free);
+
+ if (policy_data) {
+ admin_policy_destroy(policy_data);
+ policy_data = NULL;
+ }
+}
+
static struct btd_adapter_driver admin_policy_driver = {
.name = "admin_policy",
.probe = admin_policy_adapter_probe,
.resume = NULL,
+ .remove = admin_policy_remove,
.device_resolved = admin_policy_device_added,
.device_removed = admin_policy_device_removed
};
@@ -597,11 +624,7 @@ static void admin_exit(void)
DBG("");
btd_unregister_adapter_driver(&admin_policy_driver);
- queue_foreach(devices, unregister_device_data, NULL);
- queue_destroy(devices, g_free);
-
- if (policy_data)
- admin_policy_free(policy_data);
+ admin_policy_remove();
}
BLUETOOTH_PLUGIN_DEFINE(admin, VERSION,
--
2.33.0.153.gba50c8fa24-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Bluez PATCH v1 2/2] plugins/admin: create admin_policy_settings if not exists
2021-09-06 3:40 [Bluez PATCH v1 1/2] plugins/admin: add adapter_remove handler Howard Chung
@ 2021-09-06 3:40 ` Howard Chung
2021-09-06 3:55 ` [Bluez,v1,1/2] plugins/admin: add adapter_remove handler bluez.test.bot
1 sibling, 0 replies; 3+ messages in thread
From: Howard Chung @ 2021-09-06 3:40 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz; +Cc: Yun-Hao Chung, Shyh-In Hwang, Miao-chen Chou
From: Yun-Hao Chung <howardchung@chromium.org>
If admin_policy_settings is not found when loading, we should create one
instead of printing error.
Reviewed-by: Shyh-In Hwang <josephsih@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
---
This patch has been tested with following steps:
rm /var/lib/bluetooth/admin_policy_settings and restart bluetoothd.
Check if the file is created.
plugins/admin.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/plugins/admin.c b/plugins/admin.c
index 9440581409fa..fe1d71acbb8f 100644
--- a/plugins/admin.c
+++ b/plugins/admin.c
@@ -67,7 +67,7 @@ static struct btd_admin_policy *admin_policy_new(struct btd_adapter *adapter)
admin_policy->adapter = adapter;
admin_policy->adapter_id = btd_adapter_get_index(adapter);
- admin_policy->service_allowlist = NULL;
+ admin_policy->service_allowlist = queue_new();
return admin_policy;
}
@@ -337,12 +337,8 @@ static void load_policy_settings(struct btd_admin_policy *admin_policy)
char *filename = ADMIN_POLICY_STORAGE;
struct stat st;
- if (stat(filename, &st) < 0) {
- btd_error(admin_policy->adapter_id,
- "Failed to get file %s information",
- filename);
- return;
- }
+ if (stat(filename, &st) < 0)
+ store_policy_settings(policy_data);
key_file = g_key_file_new();
--
2.33.0.153.gba50c8fa24-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [Bluez,v1,1/2] plugins/admin: add adapter_remove handler
2021-09-06 3:40 [Bluez PATCH v1 1/2] plugins/admin: add adapter_remove handler Howard Chung
2021-09-06 3:40 ` [Bluez PATCH v1 2/2] plugins/admin: create admin_policy_settings if not exists Howard Chung
@ 2021-09-06 3:55 ` bluez.test.bot
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2021-09-06 3:55 UTC (permalink / raw)
To: linux-bluetooth, howardchung
[-- Attachment #1: Type: text/plain, Size: 5577 bytes --]
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=542305
---Test result---
Test Summary:
CheckPatch PASS 0.60 seconds
GitLint PASS 0.22 seconds
Prep - Setup ELL PASS 43.75 seconds
Build - Prep PASS 0.13 seconds
Build - Configure PASS 7.75 seconds
Build - Make FAIL 143.68 seconds
Make Check FAIL 0.44 seconds
Make Distcheck PASS 227.12 seconds
Build w/ext ELL - Configure PASS 7.62 seconds
Build w/ext ELL - Make FAIL 132.10 seconds
Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint
##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL
##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build
##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree
##############################
Test: Build - Make - FAIL
Desc: Build the BlueZ source tree
Output:
plugins/admin.c: In function ‘admin_policy_destroy’:
plugins/admin.c:90:15: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
90 | char *path = adapter_get_path(admin_policy->adapter);
| ^~~~~~~~~~~~~~~~
plugins/admin.c:97:7: error: ‘MOCK_ADMIN_POLICY_INTERFACE’ undeclared (first use in this function); did you mean ‘ADMIN_POLICY_SET_INTERFACE’?
97 | MOCK_ADMIN_POLICY_INTERFACE);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| ADMIN_POLICY_SET_INTERFACE
plugins/admin.c:97:7: note: each undeclared identifier is reported only once for each function it appears in
plugins/admin.c: At top level:
plugins/admin.c:603:12: error: initialization of ‘void (*)(struct btd_adapter *)’ from incompatible pointer type ‘void (*)(void)’ [-Werror=incompatible-pointer-types]
603 | .remove = admin_policy_remove,
| ^~~~~~~~~~~~~~~~~~~
plugins/admin.c:603:12: note: (near initialization for ‘admin_policy_driver.remove’)
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8456: plugins/bluetoothd-admin.o] Error 1
make: *** [Makefile:4151: all] Error 2
##############################
Test: Make Check - FAIL
Desc: Run 'make check'
Output:
plugins/admin.c: In function ‘admin_policy_destroy’:
plugins/admin.c:90:15: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
90 | char *path = adapter_get_path(admin_policy->adapter);
| ^~~~~~~~~~~~~~~~
plugins/admin.c:97:7: error: ‘MOCK_ADMIN_POLICY_INTERFACE’ undeclared (first use in this function); did you mean ‘ADMIN_POLICY_SET_INTERFACE’?
97 | MOCK_ADMIN_POLICY_INTERFACE);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| ADMIN_POLICY_SET_INTERFACE
plugins/admin.c:97:7: note: each undeclared identifier is reported only once for each function it appears in
plugins/admin.c: At top level:
plugins/admin.c:603:12: error: initialization of ‘void (*)(struct btd_adapter *)’ from incompatible pointer type ‘void (*)(void)’ [-Werror=incompatible-pointer-types]
603 | .remove = admin_policy_remove,
| ^~~~~~~~~~~~~~~~~~~
plugins/admin.c:603:12: note: (near initialization for ‘admin_policy_driver.remove’)
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8456: plugins/bluetoothd-admin.o] Error 1
make: *** [Makefile:10443: check] Error 2
##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution
##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration
##############################
Test: Build w/ext ELL - Make - FAIL
Desc: Build BlueZ source with '--enable-external-ell' configuration
Output:
plugins/admin.c: In function ‘admin_policy_destroy’:
plugins/admin.c:90:15: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
90 | char *path = adapter_get_path(admin_policy->adapter);
| ^~~~~~~~~~~~~~~~
plugins/admin.c:97:7: error: ‘MOCK_ADMIN_POLICY_INTERFACE’ undeclared (first use in this function); did you mean ‘ADMIN_POLICY_SET_INTERFACE’?
97 | MOCK_ADMIN_POLICY_INTERFACE);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
| ADMIN_POLICY_SET_INTERFACE
plugins/admin.c:97:7: note: each undeclared identifier is reported only once for each function it appears in
plugins/admin.c: At top level:
plugins/admin.c:603:12: error: initialization of ‘void (*)(struct btd_adapter *)’ from incompatible pointer type ‘void (*)(void)’ [-Werror=incompatible-pointer-types]
603 | .remove = admin_policy_remove,
| ^~~~~~~~~~~~~~~~~~~
plugins/admin.c:603:12: note: (near initialization for ‘admin_policy_driver.remove’)
cc1: all warnings being treated as errors
make[1]: *** [Makefile:8456: plugins/bluetoothd-admin.o] Error 1
make: *** [Makefile:4151: all] Error 2
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-06 3:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-06 3:40 [Bluez PATCH v1 1/2] plugins/admin: add adapter_remove handler Howard Chung
2021-09-06 3:40 ` [Bluez PATCH v1 2/2] plugins/admin: create admin_policy_settings if not exists Howard Chung
2021-09-06 3:55 ` [Bluez,v1,1/2] plugins/admin: add adapter_remove handler bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).