From patchwork Thu Jan 25 00:07:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 766914 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78AE3193 for ; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; cv=none; b=mIB8Rm3IMc92H//8kItCUbt2eoaEaaO+t6YiHMiI/tnb0aBOYIdwpBauSmyWvDpIxu1Mh4A49rYhnY3JduaQpzNyxrW0HmOYGVPIYNalHXLw0z6ziyTnVe6jxCzUdi2S9ZQD/uEvQwamdy/p08IoZ5lvUhamYWXPI+a4MkCDAe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; c=relaxed/simple; bh=F/HbVo4A4RjQZ+vKiPn5ElqvSWqMFTAmzzmaMvmbiz8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lEIL0LTxRnibgZcZY4BY2TIuaNJxK/G3jx41syuf0r9KGbqoAupZNA7EycP8kIiL6s2AA0HLUkmfiI9d6R7Yerm6ChVtK2a5A8Z+TZjt47ZNGoxSE+YQuYqRrS5xFfFzyZxQ1xuiRzq70fDLiYqmP1SM3WH+pUqc9r0b4SXoSgw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sv2UYyvQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sv2UYyvQ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 230E9C433C7; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706141249; bh=F/HbVo4A4RjQZ+vKiPn5ElqvSWqMFTAmzzmaMvmbiz8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Sv2UYyvQz/nf0WtlQzINAoyW8/q+HHTxUSOotCUVoAVe216KofhA/nq/lH6N9c3WX dGWN4YLGzag3/ggh2praBez1CYs+/0gKV97CfuaHF/CLrWZHzsHrdR6cCQrLeSoBYx DQI0AG0/hatImfpKzUyp05xWK7SMFxwzMhLNQwC0uu/gr9r78SnRaLJThgLUKDWXIu BqcQb3oXD2GkeHBhLork3zOgTMDbq8/UFea3LVfYlpGKD1rUrGKpzcRqwbIrEs8z5L NSIZszvoT4ZzAUrcqqXQ00BYBOXB+g3HQq+DJQlwofGgVERpQFgxr6ifWTlG5meKVO aLRf++bwgh0KQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C05BC47E49; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Thu, 25 Jan 2024 00:07:26 +0000 Subject: [PATCH BlueZ v3 1/8] configure, README: introduce --enable-external-plugins Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-rm-ext-plugins-v3-1-d141f7870bb6@gmail.com> References: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> In-Reply-To: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706141247; l=2129; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=e1EdDSyciHHAaX9NsOJkW3suqFVoEXcg0Cnn7chU+j0=; b=ArEUScUswXs1Jus2LYZ/6mJV+xYFIIB+RTKcI7RvIw8Q5PeY08L3U/7Lzzq1xAX4tniFMSytA YdLYfnQ56IODVG764Q5VTO6lO0PZpJkS3B61zbIdLO6bLMhugXhDuhF X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov As the README chunk says, disabled by default, since they rely on internal API/ABI and can break at any point. Instead everyone affected should work and upstream their plugin into the bluez project. --- README | 13 +++++++++++++ configure.ac | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/README b/README index 7de7045a8..6c0777046 100644 --- a/README +++ b/README @@ -249,6 +249,19 @@ For a working system, certain configuration options need to be enabled: systems. The behavior of the deprecated tools may be unstable or simply don't work anymore. + --enable-external-plugins + + Enable support for external plugins + + By default external plugins for bluetoothd and obexd are not + supported and thus disabled. + + External plugins require access to internal, undocumented and + unversioned API in said daemons. As such they can break at any + time. If you have such plugins, enable this option and work + actively with the community to make said plugin part of the + upstream bluez project. + --enable-nfc This option enable NFC pairing support. diff --git a/configure.ac b/configure.ac index cab5da581..5e353a1d6 100644 --- a/configure.ac +++ b/configure.ac @@ -364,6 +364,16 @@ AC_ARG_ENABLE(deprecated, AS_HELP_STRING([--enable-deprecated], [enable_deprecated=${enableval}]) AM_CONDITIONAL(DEPRECATED, test "${enable_deprecated}" = "yes") +AC_ARG_ENABLE(external-plugsin, AS_HELP_STRING([--enable-external-plugins], + [enable support for external plugins]), + [enable_external_plugins=${enableval}]) +AM_CONDITIONAL(EXTERNAL_PLUGINS, test "${enable_external_plugins}" = "yes") +if (test "${enable_external_plugins}" = "yes"); then + AC_DEFINE(EXTERNAL_PLUGINS, 1, [Define if external plugin support is required]) +else + AC_DEFINE(EXTERNAL_PLUGINS, 0, [Define if external plugin support is required]) +fi + AC_ARG_ENABLE(sixaxis, AS_HELP_STRING([--enable-sixaxis], [enable sixaxis plugin]), [enable_sixaxis=${enableval}]) AM_CONDITIONAL(SIXAXIS, test "${enable_sixaxis}" = "yes" && From patchwork Thu Jan 25 00:07:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 766059 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78B03196 for ; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; cv=none; b=GQlqMUcjyc463SI0z+2M9Xto8fxll+T+75m77u/uGwOwCZ/sZF0HOq34AK9zblgPWtMrOyViUEbGSwTvMoMIA7ykuPGWRSrWkygFu7ll5smeCKwxjtH3I1eGgrDFU2uxDeYo5ytH1EQKd/njdSRfzIy5fNGsaX3zyOjzz7fJW/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; c=relaxed/simple; bh=MakOcaBw3YSuN3nn/DHr0vOxRiZjIEdQeSW/80o/hfg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ESAbLzmEGxXaOM6/zJV9dlNdKPVGtoSblZJLO8uUbNspy8BDEHSn13rmx2WP/Y6B8RqPcz0uHLawMCGdH7x9bkhGRI/RaigTBnNIe4goEqHZCacnNHbXlYUZDiPrYYaKvyZyYChU3xV47dHt0KOt+XbfAkLEnpwMyaYL0rtwntw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dQ9MNZHE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dQ9MNZHE" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2B0CBC43390; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706141249; bh=MakOcaBw3YSuN3nn/DHr0vOxRiZjIEdQeSW/80o/hfg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=dQ9MNZHEcaC71ieOMrhmIKh+VJIJXkQ5Zceo7HywpK7QZ4XAtv5nGYk9SCakoaBMs F0qcpC6pCJJ95rIeZSDz9LWFWKj4ocR4cFXnj/gEYWl0Em47o91w7khICY2sTcK6vq eW0Qei3RYzPiyP23N/PKkO46TcYzbTubHOfSmavVQoIS5JU1chIv6a1BSuwq7fgtsq s7JPpW+B3/A12LF20uA7Zkf1LUAyr/LvrlcfE1PJwDma7YgWuwIMs2PNqLTQWHFqtd 2XnwKYqE6Dc5A416gdaV5FseZ80UJnltajeIBJKbIPedR5MRJd+l0GIp6cCJsOo5mn d2liRKxtJc1+w== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14CA8C48285; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Thu, 25 Jan 2024 00:07:27 +0000 Subject: [PATCH BlueZ v3 2/8] obexd: factor out external plugin support Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-rm-ext-plugins-v3-2-d141f7870bb6@gmail.com> References: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> In-Reply-To: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706141247; l=5642; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=pGvGwURoyXDGW5FladnamFTHwTNZsaHX3sUoMvQj5ac=; b=pV8O38XCOg7+8a1uxsvUlId50hnGrxTkL40L3c4scHDtvK5p5dFB6kDMTVSRuhXvg9ny4EA0i upfu5sowOirD//OTAJr4Wtm/M+gZqF5I8zABnGQO2c7NEoCEPHzM8e/ X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov As a whole all plugins should be built-in, otherwise they would be using internal, undocumented, unversioned, unstable API. Flesh out the external plugin support into a few pre-processor blocks and simplify the normal path. Hide the internal API (omit export-dynamic) when built without external plugins. --- Makefile.obexd | 2 ++ obexd/src/obexd.h | 2 +- obexd/src/plugin.c | 93 ++++++++++++++++++++++++++++++++++++------------------ obexd/src/plugin.h | 4 +++ 4 files changed, 70 insertions(+), 31 deletions(-) diff --git a/Makefile.obexd b/Makefile.obexd index 5d1a4ff65..9175de2a4 100644 --- a/Makefile.obexd +++ b/Makefile.obexd @@ -86,7 +86,9 @@ obexd_src_obexd_LDADD = lib/libbluetooth-internal.la \ $(ICAL_LIBS) $(DBUS_LIBS) $(LIBEBOOK_LIBS) \ $(LIBEDATASERVER_LIBS) $(GLIB_LIBS) -ldl +if EXTERNAL_PLUGINS obexd_src_obexd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic +endif obexd_src_obexd_CPPFLAGS = $(AM_CPPFLAGS) $(GLIB_CFLAGS) $(DBUS_CFLAGS) \ $(ICAL_CFLAGS) -DOBEX_PLUGIN_BUILTIN \ diff --git a/obexd/src/obexd.h b/obexd/src/obexd.h index fe312a65b..af5265da5 100644 --- a/obexd/src/obexd.h +++ b/obexd/src/obexd.h @@ -18,7 +18,7 @@ #define OBEX_MAS (1 << 8) #define OBEX_MNS (1 << 9) -gboolean plugin_init(const char *pattern, const char *exclude); +void plugin_init(const char *pattern, const char *exclude); void plugin_cleanup(void); gboolean manager_init(void); diff --git a/obexd/src/plugin.c b/obexd/src/plugin.c index a3eb24753..212299fa5 100644 --- a/obexd/src/plugin.c +++ b/obexd/src/plugin.c @@ -37,11 +37,14 @@ static GSList *plugins = NULL; struct obex_plugin { +#if EXTERNAL_PLUGINS void *handle; +#endif const struct obex_plugin_desc *desc; }; -static gboolean add_plugin(void *handle, const struct obex_plugin_desc *desc) +#if EXTERNAL_PLUGINS +static gboolean add_external_plugin(void *handle, const struct obex_plugin_desc *desc) { struct obex_plugin *plugin; @@ -65,6 +68,26 @@ static gboolean add_plugin(void *handle, const struct obex_plugin_desc *desc) return TRUE; } +#endif + +static void add_plugin(const struct obex_plugin_desc *desc) +{ + struct obex_plugin *plugin; + + plugin = g_try_new0(struct obex_plugin, 1); + if (plugin == NULL) + return; + + plugin->desc = desc; + + if (desc->init() < 0) { + g_free(plugin); + return; + } + + plugins = g_slist_append(plugins, plugin); + DBG("Plugin %s loaded", desc->name); +} static gboolean check_plugin(const struct obex_plugin_desc *desc, char **patterns, char **excludes) @@ -93,42 +116,23 @@ static gboolean check_plugin(const struct obex_plugin_desc *desc, } -#include "builtin.h" - -gboolean plugin_init(const char *pattern, const char *exclude) +static void external_plugin_init(char **patterns, char **excludes) { - char **patterns = NULL; - char **excludes = NULL; +#if EXTERNAL_PLUGINS GDir *dir; const char *file; - unsigned int i; - if (strlen(PLUGINDIR) == 0) - return FALSE; - - if (pattern) - patterns = g_strsplit_set(pattern, ":, ", -1); - - if (exclude) - excludes = g_strsplit_set(exclude, ":, ", -1); - - DBG("Loading builtin plugins"); - - for (i = 0; __obex_builtin[i]; i++) { - if (check_plugin(__obex_builtin[i], - patterns, excludes) == FALSE) - continue; + warn("Using external plugins is not officially supported.\n"); + warn("Consider upstreaming your plugins into the BlueZ project."); - add_plugin(NULL, __obex_builtin[i]); - } + if (strlen(PLUGINDIR) == 0) + return; DBG("Loading plugins %s", PLUGINDIR); dir = g_dir_open(PLUGINDIR, 0, NULL); if (!dir) { - g_strfreev(patterns); - g_strfreev(excludes); - return FALSE; + return; } while ((file = g_dir_read_name(dir)) != NULL) { @@ -164,15 +168,42 @@ gboolean plugin_init(const char *pattern, const char *exclude) continue; } - if (add_plugin(handle, desc) == FALSE) + if (add_external_plugin(handle, desc) == FALSE) dlclose(handle); } g_dir_close(dir); +#endif +} + +#include "builtin.h" + +void plugin_init(const char *pattern, const char *exclude) +{ + char **patterns = NULL; + char **excludes = NULL; + unsigned int i; + + if (pattern) + patterns = g_strsplit_set(pattern, ":, ", -1); + + if (exclude) + excludes = g_strsplit_set(exclude, ":, ", -1); + + DBG("Loading builtin plugins"); + + for (i = 0; __obex_builtin[i]; i++) { + if (check_plugin(__obex_builtin[i], + patterns, excludes) == FALSE) + continue; + + add_plugin(__obex_builtin[i]); + } + + external_plugin_init(patterns, excludes); + g_strfreev(patterns); g_strfreev(excludes); - - return TRUE; } void plugin_cleanup(void) @@ -187,8 +218,10 @@ void plugin_cleanup(void) if (plugin->desc->exit) plugin->desc->exit(); +#if EXTERNAL_PLUGINS if (plugin->handle != NULL) dlclose(plugin->handle); +#endif g_free(plugin); } diff --git a/obexd/src/plugin.h b/obexd/src/plugin.h index a91746cbc..e1756b9bf 100644 --- a/obexd/src/plugin.h +++ b/obexd/src/plugin.h @@ -20,10 +20,14 @@ struct obex_plugin_desc { #name, init, exit \ }; #else +#if EXTERNAL_PLUGINS #define OBEX_PLUGIN_DEFINE(name,init,exit) \ extern struct obex_plugin_desc obex_plugin_desc \ __attribute__ ((visibility("default"))); \ const struct obex_plugin_desc obex_plugin_desc = { \ #name, init, exit \ }; +#else +#error "Requested non built-in plugin, while external plugins is disabled" +#endif #endif From patchwork Thu Jan 25 00:07:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 766910 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0F337EC for ; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; cv=none; b=JU4oE7DU0K4Hj3dmKMyvfDfDPhwEekdNSiTken2h9gUZoTMnJ0IzLmO+vjHSqe7hTcDYO4QgjVmjEO9tym+M5hFOP6/Dz/+gDH420g7szgZCyy5VVW7kbsJhhQGTJ6dlAF4QqaLu9R4ICuA25Iw3zQwKhgFUBYhqYNDqaezmLKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; c=relaxed/simple; bh=l4M0CYae6sACNUXdM/RsB3Lv49E/9xZZDseXRMJSHq8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RRQVulpkAO61S7c4L0DdhuLZJGwlFIobAjwZueYlOlflNyPnBGKkreS8IIIRQt9w77Jg3CGPRlUrXoz4XtW6IjA3mhY9Z2rvjyqUEgUO7fB4kXrdxXczB7z3k2Nk71HBhlfhM6lYJRBxY4hbvlOJt3tv7P0I3EePSHdBuJIeFk8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JTuOGrKz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JTuOGrKz" Received: by smtp.kernel.org (Postfix) with ESMTPS id 56093C43399; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706141249; bh=l4M0CYae6sACNUXdM/RsB3Lv49E/9xZZDseXRMJSHq8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=JTuOGrKzc/nBg/f1oZW1FJAysHpv9R9Inerc8CRdJnnkqTkdW3sDC6ERQNzX2WAPE BHOnOZwKT9gH8LOhruCGA5hixfm/Eoza8JLJASjOww6b7GFEz1yNcSeAW5osYDgaLF B17XLMiNQevp2bhXX7bti0R+4QifVoINbYQQrhwJA07cNRht9BVcwh/X1Ga3Tnfqkd FrwYjTd+ESNE9ru2fGvXFeLhqEhS79QwYUdWj3dpo/ZB3kcaEV19pQDfkVxjyIDZp7 KEGzgoO2itdXjWhpDrBthbi4f6hE+8CvmAGSi1ysPTq+vjeaWILxvIZAiAHaUpXPS8 LriE62vmTQ7Dg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45FFFC47422; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Thu, 25 Jan 2024 00:07:28 +0000 Subject: [PATCH BlueZ v3 3/8] bluetoothd: remove external-dummy plugin Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-rm-ext-plugins-v3-3-d141f7870bb6@gmail.com> References: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> In-Reply-To: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706141247; l=1499; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=EjARRPevchGHDkRRE9GXFlLSL06rTs7sjbEgjh12uig=; b=juwWclaFPWcNd5TdWC+/p4fMBo+sdoJQR4TpExGNPc2KAmyVsySvm5XtHUk0307MGLbTJIV2U 1g3dsfY5ypcDX+nljfxVJTfqC4YZRy4kr/zf4v9DXKvGf+50os3SKDz X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov The external plugins infra is getting deprecated and disabled by default. Remove this dummy plugin. --- Makefile.am | 8 -------- plugins/external-dummy.c | 28 ---------------------------- 2 files changed, 36 deletions(-) diff --git a/Makefile.am b/Makefile.am index e738eb3a5..ea51b25cc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -293,14 +293,6 @@ builtin_ldadd = include Makefile.plugins -if MAINTAINER_MODE -plugin_LTLIBRARIES += plugins/external-dummy.la -plugins_external_dummy_la_SOURCES = plugins/external-dummy.c -plugins_external_dummy_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version \ - -no-undefined -plugins_external_dummy_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden -endif - pkglibexec_PROGRAMS += src/bluetoothd src_bluetoothd_SOURCES = $(builtin_sources) \ diff --git a/plugins/external-dummy.c b/plugins/external-dummy.c deleted file mode 100644 index 1c209e8b7..000000000 --- a/plugins/external-dummy.c +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * - * BlueZ - Bluetooth protocol stack for Linux - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "src/plugin.h" -#include "src/log.h" - -static int dummy_init(void) -{ - DBG(""); - - return 0; -} - -static void dummy_exit(void) -{ - DBG(""); -} - -BLUETOOTH_PLUGIN_DEFINE(external_dummy, VERSION, - BLUETOOTH_PLUGIN_PRIORITY_LOW, dummy_init, dummy_exit) From patchwork Thu Jan 25 00:07:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 766058 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D4AD385 for ; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; cv=none; b=NT5N0Rlqt8jSAG/MqJrKlqSZtP3iM7veJ9sEOy8vBr+PN59sKJHxgeyxXr4Kjq8AW+jaXZ0Am0hcmwW+F6P4kqccK5kbymuBf/e9qEQaqXubjl3hN9QaBTXa+E3D0WLtUfZU41GwMOiJhW7uFxPuR5yORSwSZnJneS/7sMgHgxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; c=relaxed/simple; bh=OzzMlvRUPsVuxo2uwdVZjdw1XvEQcNHqU3yi1nNQhrA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kOPNJEUWmfP3DmdjAdiy2FNarhM0WEogqYTYm+Pp0X5tUFqtjJNlq6Q8uhT5WuAiDp3Hq5WkJfO4Jq2mQr8sGnmVPIqMGb0lIQxxr+vOUBnTY132KwWeynm6dhdLyRxAbji1aW60RcQZqUmFUI21PCYH9DLBeLuEnfwquZPA/Rw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SHW/H8PP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SHW/H8PP" Received: by smtp.kernel.org (Postfix) with ESMTPS id 61862C43394; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706141249; bh=OzzMlvRUPsVuxo2uwdVZjdw1XvEQcNHqU3yi1nNQhrA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=SHW/H8PPoCBoHf52Bn8eEUh7pzpSNvINcIACQ6mNYzQlG+5LCDUzotWD0xIE15dKx MYpCDs9TMdsDdF+KhIgWPC0MyRwbDziRzqlrPYpxmlNt8ty6qu3aZ/hyzx4gH48RMd nRV8FQs3ApYAisBODHtl7rn/faFOajNIbiFTpBziCUr04lYCGPEaXRvzOmOcaMeYPl CV6rN7hwXOdz0idWmIPRSCuY6KC8Zr4+L7VsBtIpTAPWMSIDxxWs+OLmbUE6ldvuVv 5Ry62vN07mFh2KGXCWQR61zxibjbhv8XPn8/SW03F3cLfrx1mjiUeLeqIoailXp7Dc 2kYwuKu60qJ0A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50C41C47E49; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Thu, 25 Jan 2024 00:07:29 +0000 Subject: [PATCH BlueZ v3 4/8] bluetoothd: convert external sixaxis plugin to builtin Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-rm-ext-plugins-v3-4-d141f7870bb6@gmail.com> References: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> In-Reply-To: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706141247; l=1169; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=rf/DV6bb4eocv72jDKDqDG7KvOMIubc6ZBWpK2UcaNg=; b=KxRl4ybPO5mJHkVzDDAtgZUvph+fZVnffBMx8aPVzyUh8lR3h3/ICmd//jTaWiDwEwFCUB0vc 5XsfOXvGPILBw7RutVwXSkIDTxksANQNjoLHHU9R/mmileW53K8fPps X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov Convert the only known external plugin to built-in. It's a tiny 20K binary that distros ship a separate package for. Make it a builtin, which allows distros to drop the separate package, it also enables us to compile out support for external modules - both in terms of extra code and hide the internal bluetoothd API. This means that libudev.so is pulled in, which is fine since its ABI has been stable for over a decade. --- Makefile.plugins | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile.plugins b/Makefile.plugins index 5880ed0df..7cf66fd59 100644 --- a/Makefile.plugins +++ b/Makefile.plugins @@ -110,11 +110,9 @@ builtin_modules += battery builtin_sources += profiles/battery/battery.c if SIXAXIS -plugin_LTLIBRARIES += plugins/sixaxis.la -plugins_sixaxis_la_SOURCES = plugins/sixaxis.c -plugins_sixaxis_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version -plugins_sixaxis_la_LIBADD = $(UDEV_LIBS) -plugins_sixaxis_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden +builtin_modules += sixaxis +builtin_sources += plugins/sixaxis.c +builtin_ldadd += $(UDEV_LIBS) endif if BAP From patchwork Thu Jan 25 00:07:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 766057 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE68B625 for ; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; cv=none; b=iUIEJLbwi66pIzpO2wJchUpX/G9cO5aYVsKNmJYhT4GbHznYuPEI/BWpXdJb+fSEUXQVpUaErAZ5a8bNheBHAn2vvQT6l71Y4H4S17Ra4F8oRmO+lELd3iclC8wUSjXwDdHqsqA387kMXROU1pN5800BiPaQNHl+j6nKVUabXLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; c=relaxed/simple; bh=6gXYqDg1iagSWrUXKqg53BuHbuqGR2ccSQ8itNAtFvw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Bo6lPZ5TCTJEg+3Q78Nm9APxyckriJ54DJoIFlV0iR0iD7jKe0h1a2gW+05Zk54HfO9DPKF0yIoA1zEIUHxEwc97wgwFKu0N8h7W/AlWj1aqP2jTGlVMGF9rP9b9rwsHikqp+kXjH32eFmVzHNwG9AKupVEEho0ydIAoBxY5tQg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KmM//y31; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KmM//y31" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6E6D0C433A6; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706141249; bh=6gXYqDg1iagSWrUXKqg53BuHbuqGR2ccSQ8itNAtFvw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=KmM//y31E/oYj9vjZM4O1fctMb755yLeOHhbkJTUDCchwv2O9KRNnuITppK5V/EYo CEzBdnWTmiqHma60kLEMlM+H/+yLecEjzR1S87HbZwRemAbxUtnaGkRtWVNjLieMsG O6h7wGxOhcO7eBgogOc5cUed5Bt2KvNoUfKmJt2YN4j6K6G7ot57Vy3O5QGcCTkjxW WBeQ0KLf4vPbjrebXeCjyC7J70UE9K27/VD6jvYexjNo79H7DrgUZzFb7+yhDyivIh /A7WlSmkPaqeq5DGGEFSQAHVx6BYuJwp9aOQ5UUO5PxzL1J/iOvd+Tp7eMpuVUKsk+ lLNSQ9owmkdug== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D655C46CD2; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Thu, 25 Jan 2024 00:07:30 +0000 Subject: [PATCH BlueZ v3 5/8] bluetoothd: factor out external plugin support Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-rm-ext-plugins-v3-5-d141f7870bb6@gmail.com> References: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> In-Reply-To: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706141247; l=6433; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=WpwMNuo+0wxS6pXtowstfiORfl+j7pw7iu2tGBo4NYw=; b=YhA6OzZVIrsv8/HKdWR6zlickTTm/N6qZmOL6VuKOOytzHq9BwEM36JSztnHhY4HGEmWij5yF tUxij5AsLi5DSGSTtDEauCBGOIQ4TiQJ4kS3BaZZ1tcYRQ/a6gK3WMz X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov As a whole all plugins should be built-in, otherwise they would be using internal, undocumented, unversioned, unstable API. Flesh out the external plugin support into a few pre-processor blocks and simplify the normal path. --- Makefile.am | 4 --- src/btd.h | 2 +- src/plugin.c | 97 ++++++++++++++++++++++++++++++++++++++---------------------- src/plugin.h | 16 ++++++++++ 4 files changed, 79 insertions(+), 40 deletions(-) diff --git a/Makefile.am b/Makefile.am index ea51b25cc..1b82e8551 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,11 +51,7 @@ EXTRA_DIST += src/bluetooth.service.in src/org.bluez.service plugindir = $(libdir)/bluetooth/plugins -if MAINTAINER_MODE -build_plugindir = $(abs_top_srcdir)/plugins/.libs -else build_plugindir = $(plugindir) -endif if MANPAGES man_MANS = diff --git a/src/btd.h b/src/btd.h index b7e7ebd61..7166e2168 100644 --- a/src/btd.h +++ b/src/btd.h @@ -155,7 +155,7 @@ struct btd_opts { extern struct btd_opts btd_opts; -gboolean plugin_init(const char *enable, const char *disable); +void plugin_init(const char *enable, const char *disable); void plugin_cleanup(void); void rfkill_init(void); diff --git a/src/plugin.c b/src/plugin.c index 2a29a888e..ae9406375 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -29,7 +29,9 @@ static GSList *plugins = NULL; struct bluetooth_plugin { +#if EXTERNAL_PLUGINS void *handle; +#endif gboolean active; const struct bluetooth_plugin_desc *desc; }; @@ -42,7 +44,8 @@ static int compare_priority(gconstpointer a, gconstpointer b) return plugin2->desc->priority - plugin1->desc->priority; } -static gboolean add_plugin(void *handle, +#if EXTERNAL_PLUGINS +static gboolean add_external_plugin(void *handle, const struct bluetooth_plugin_desc *desc) { struct bluetooth_plugin *plugin; @@ -71,6 +74,22 @@ static gboolean add_plugin(void *handle, return TRUE; } +#endif + +static void add_plugin(const struct bluetooth_plugin_desc *desc) +{ + struct bluetooth_plugin *plugin; + + DBG("Loading %s plugin", desc->name); + + plugin = g_try_new0(struct bluetooth_plugin, 1); + if (plugin == NULL) + return; + + plugin->desc = desc; + + plugins = g_slist_insert_sorted(plugins, plugin, compare_priority); +} static gboolean enable_plugin(const char *name, char **cli_enable, char **cli_disable) @@ -98,48 +117,24 @@ static gboolean enable_plugin(const char *name, char **cli_enable, return TRUE; } -#include "src/builtin.h" -gboolean plugin_init(const char *enable, const char *disable) +static void external_plugin_init(char **cli_disabled, char **cli_enabled) { - GSList *list; +#if EXTERNAL_PLUGINS GDir *dir; const char *file; - char **cli_disabled, **cli_enabled; - unsigned int i; - - /* Make a call to BtIO API so its symbols got resolved before the - * plugins are loaded. */ - bt_io_error_quark(); - if (enable) - cli_enabled = g_strsplit_set(enable, ", ", -1); - else - cli_enabled = NULL; - - if (disable) - cli_disabled = g_strsplit_set(disable, ", ", -1); - else - cli_disabled = NULL; - - DBG("Loading builtin plugins"); - - for (i = 0; __bluetooth_builtin[i]; i++) { - if (!enable_plugin(__bluetooth_builtin[i]->name, cli_enabled, - cli_disabled)) - continue; - - add_plugin(NULL, __bluetooth_builtin[i]); - } + warn("Using external plugins is not officially supported.\n"); + warn("Consider upstreaming your plugins into the BlueZ project."); if (strlen(PLUGINDIR) == 0) - goto start; + return; DBG("Loading plugins %s", PLUGINDIR); dir = g_dir_open(PLUGINDIR, 0, NULL); if (!dir) - goto start; + return; while ((file = g_dir_read_name(dir)) != NULL) { const struct bluetooth_plugin_desc *desc; @@ -174,13 +169,45 @@ gboolean plugin_init(const char *enable, const char *disable) continue; } - if (add_plugin(handle, desc) == FALSE) + if (add_external_plugin(handle, desc) == FALSE) dlclose(handle); } g_dir_close(dir); +#endif +} + +#include "src/builtin.h" + +void plugin_init(const char *enable, const char *disable) +{ + GSList *list; + char **cli_disabled = NULL; + char **cli_enabled = NULL; + unsigned int i; + + /* Make a call to BtIO API so its symbols got resolved before the + * plugins are loaded. */ + bt_io_error_quark(); + + if (enable) + cli_enabled = g_strsplit_set(enable, ", ", -1); + + if (disable) + cli_disabled = g_strsplit_set(disable, ", ", -1); + + DBG("Loading builtin plugins"); + + for (i = 0; __bluetooth_builtin[i]; i++) { + if (!enable_plugin(__bluetooth_builtin[i]->name, cli_enabled, + cli_disabled)) + continue; + + add_plugin(__bluetooth_builtin[i]); + } + + external_plugin_init(cli_enabled, cli_disabled); -start: for (list = plugins; list; list = list->next) { struct bluetooth_plugin *plugin = list->data; int err; @@ -201,8 +228,6 @@ start: g_strfreev(cli_enabled); g_strfreev(cli_disabled); - - return TRUE; } void plugin_cleanup(void) @@ -217,8 +242,10 @@ void plugin_cleanup(void) if (plugin->active == TRUE && plugin->desc->exit) plugin->desc->exit(); +#if EXTERNAL_PLUGINS if (plugin->handle != NULL) dlclose(plugin->handle); +#endif g_free(plugin); } diff --git a/src/plugin.h b/src/plugin.h index 8d0903f2d..a1984d536 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -13,14 +13,19 @@ struct bluetooth_plugin_desc { const char *name; +#if EXTERNAL_PLUGINS const char *version; +#endif int priority; int (*init) (void); void (*exit) (void); +#if EXTERNAL_PLUGINS void *debug_start; void *debug_stop; +#endif }; +#if EXTERNAL_PLUGINS #ifdef BLUETOOTH_PLUGIN_BUILTIN #define BLUETOOTH_PLUGIN_DEFINE(name, version, priority, init, exit) \ const struct bluetooth_plugin_desc \ @@ -41,3 +46,14 @@ struct bluetooth_plugin_desc { __start___debug, __stop___debug \ }; #endif +#else +#ifdef BLUETOOTH_PLUGIN_BUILTIN +#define BLUETOOTH_PLUGIN_DEFINE(name, version, priority, init, exit) \ + const struct bluetooth_plugin_desc \ + __bluetooth_builtin_ ## name = { \ + #name, priority, init, exit \ + }; +#else +#error "Requested non built-in plugin, while external plugins is disabled" +#endif +#endif From patchwork Thu Jan 25 00:07:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 766912 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE62C38C for ; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; cv=none; b=vEP7cplVqquVy/UOniSq2Vp85MsYE755mh6uPQAqt62K2xIbyN3GJSzr2UB3kxd19PIuh0hojRnUjbggIC3Swa86g3qR0lvhJWh7hTcjUbjtiHf/1nQr1pvXQpKAXuizbN2vpE4TGzRq1wa59Wv3+G1sbCX1roznAsYqZYobP1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; c=relaxed/simple; bh=jAEahC6aEhwGsx03XeCGs0r51Ila42pXjrHeGrsvCtM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cMKjriNaYRThgSWgltxQHSiqlSJjnmwvForP41miwo3MgCxj6xULR+ISht59fBvWhHwY+2UHUquHF6HDyYYdhvtdNeAW/R7eaECOV3sGXPH+NAOUqABFqWWA5aIfMlgYXnQZVASmpwQA/taUZc/mzkVU8EtOu6x7uaTKF8FrXr4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qpAn5Z+D; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qpAn5Z+D" Received: by smtp.kernel.org (Postfix) with ESMTPS id 7B9E0C433B1; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706141249; bh=jAEahC6aEhwGsx03XeCGs0r51Ila42pXjrHeGrsvCtM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qpAn5Z+DbOd8P1iHF/tc316/IXFisRrbo/tHB9lrK/km6WTBekIggJXya/VblKFxK 6gKEXfvAFPmuypQtSPp3hiiYXB1lcb+BDf9OTSz89jQi67Jl3kKmk6ZdH6U0hmvXlK lwIn2jBFarQUG8jkkulAf2/q4GX1ykPg8Mt/wWD752289CqKa5rL3CbS3ebLZbmStj QnW8s1qFpuZnNe4ndo8PfvZ+i/DDn+UurSSZnMSPw9v5oIntmaBELHwkNDcw+qF/Go CLDa+GwXVMfvqtChbcwn1VYEuJMUFzPwUtyIHP796tjs71x9guKkVEYDBgFo0mJO+4 4dpAGiu/PIlqQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68189C48286; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Thu, 25 Jan 2024 00:07:31 +0000 Subject: [PATCH BlueZ v3 6/8] bluetoothd: don't export internal API Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-rm-ext-plugins-v3-6-d141f7870bb6@gmail.com> References: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> In-Reply-To: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706141247; l=1034; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=oJMu/7JQ1+IQo+7iiJJvhOj5+NWG/IUCz9D6MPY+H5E=; b=gqoFk2vwm70LpS2pC9QJH75kEM3NxbTIZ63sgK1kmGy8o1KYGJBUdvV7TSpU2mVkhjacaZfIw CZLlNz79mG3C7O67OgjRegHIEjZ+tlvivofPTx7n18hwMKW+Ksv6+eq X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov ... when building without external plugins. --- Makefile.am | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 1b82e8551..b98519e84 100644 --- a/Makefile.am +++ b/Makefile.am @@ -293,7 +293,6 @@ pkglibexec_PROGRAMS += src/bluetoothd src_bluetoothd_SOURCES = $(builtin_sources) \ $(attrib_sources) $(btio_sources) \ - src/bluetooth.ver \ src/main.c src/log.h src/log.c \ src/backtrace.h src/backtrace.c \ src/rfkill.c src/btd.h src/sdpd.h \ @@ -325,8 +324,12 @@ src_bluetoothd_LDADD = lib/libbluetooth-internal.la \ src/libshared-glib.la \ $(BACKTRACE_LIBS) $(GLIB_LIBS) $(DBUS_LIBS) -ldl -lrt \ $(builtin_ldadd) + +if EXTERNAL_PLUGINS +src_bluetoothd_SOURCES += src/bluetooth.ver src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \ -Wl,--version-script=$(srcdir)/src/bluetooth.ver +endif src_bluetoothd_DEPENDENCIES = lib/libbluetooth-internal.la \ gdbus/libgdbus-internal.la \ From patchwork Thu Jan 25 00:07:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 766056 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE64F399 for ; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; cv=none; b=UHPDcsgyFWk8Ic1aLX/7JrpL9OfPGpCwSHZI7KEVMKP31IxMEcY329oyZG4xCco9VeIuDtPY3lxe5/DGlDC9K/HuyH/bVbuyY9kOHOKf3NA1LwNAJdRiT3MOwUtCl6NwpQdBngdF8QD+9qwPtax/gXA+oIYKvU8hUjoZKfMX+Dg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; c=relaxed/simple; bh=G9genvZ+XzEEPgL5CU4jnpFYI5JsJj4sQ/6exI14zAQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oxZUItQDIOw7E+QEF/ojyqGPdP8LYwjyGKfRwZOfNUwXOLs3tvPwrXYLSFyN5Zu33/W2i/vG72anS2B7YJLHhUifxF/ITAgRCQalTGsJ2saSQwHekcUw5DYilOIKmflIVn9Z2sSa6tGSJpQqcpgeCjwCAoouQdbBtfZ99kV7oCY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=io/b2CsC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="io/b2CsC" Received: by smtp.kernel.org (Postfix) with ESMTPS id 819D7C43330; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706141249; bh=G9genvZ+XzEEPgL5CU4jnpFYI5JsJj4sQ/6exI14zAQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=io/b2CsC/KZ8uTVFakQaMkU/Dwj/JMPeFaHsYX5ootxTkqqhfM0p/jQ0W6kBC132D HM7AGSdnYTnaxh/eoHtqoJrzrgEq/x9QuE9uxEkhAcuYpgsu7uVGzfJEdSrfyp9o4x ekyhfWPSw42IU2YI62h2OvQq/9ouV20sk0S07U9Txbu2/DlgAA/tpPS9jN6xMxDEFI TmqjPCdcO1/LrUBN767CGjZR7PQhgt7efcPOorNXcoAtY4KVBW/Z6XuQ0hf3zjXYrc SwpVAQvvX5Ye/MjwjbAP3QJLYrYCSbDe03ULkbdaE4rs2QJX8UkMHb05kUQy5ju4sz UrketYFwc/m5Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71AFEC47422; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Thu, 25 Jan 2024 00:07:32 +0000 Subject: [PATCH BlueZ v3 7/8] bluetoothd: change plugin loading alike obexd Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-rm-ext-plugins-v3-7-d141f7870bb6@gmail.com> References: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> In-Reply-To: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706141247; l=3470; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=6yElFux7++NnGhXn3yTR7PlLXi4XViEHuKoqMgyFigw=; b=lXobeEKJxrFM52Kbj5OKm+XlDLerbaNjVpH6BHJ+gVI6v9prO3Dq3yf8MN1lpY74DOfrslXio 9dmelYX4Up5DokHJDjLYU6/lUlWsrR7KgtmfxLmtqeRLBWvN5yx4WFB X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov Currently, we print "Loading foobar" for every plugin, before we try the respective init() callback. Instead we handle the latter in a bunch, at the end of the process. Do the init() call early, print "Loaded" once it's actually successful and drop the no-longer "active" tracking. --- src/plugin.c | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/plugin.c b/src/plugin.c index ae9406375..3895792bc 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -32,7 +32,6 @@ struct bluetooth_plugin { #if EXTERNAL_PLUGINS void *handle; #endif - gboolean active; const struct bluetooth_plugin_desc *desc; }; @@ -44,6 +43,22 @@ static int compare_priority(gconstpointer a, gconstpointer b) return plugin2->desc->priority - plugin1->desc->priority; } +static int init_plugin(const struct bluetooth_plugin_desc *desc) +{ + int err; + + err = desc->init(); + if (err < 0) { + if (err == -ENOSYS || err == -ENOTSUP) + warn("System does not support %s plugin", + desc->name); + else + error("Failed to init %s plugin", + desc->name); + } + return err; +} + #if EXTERNAL_PLUGINS static gboolean add_external_plugin(void *handle, const struct bluetooth_plugin_desc *desc) @@ -58,19 +73,22 @@ static gboolean add_external_plugin(void *handle, return FALSE; } - DBG("Loading %s plugin", desc->name); - plugin = g_try_new0(struct bluetooth_plugin, 1); if (plugin == NULL) return FALSE; plugin->handle = handle; - plugin->active = FALSE; plugin->desc = desc; + if (init_plugin(desc) < 0) { + g_free(plugin); + return FALSE; + } + __btd_enable_debug(desc->debug_start, desc->debug_stop); plugins = g_slist_insert_sorted(plugins, plugin, compare_priority); + DBG("Plugin %s loaded", desc->name); return TRUE; } @@ -88,7 +106,13 @@ static void add_plugin(const struct bluetooth_plugin_desc *desc) plugin->desc = desc; + if (init_plugin(desc) < 0) { + g_free(plugin); + return; + } + plugins = g_slist_insert_sorted(plugins, plugin, compare_priority); + DBG("Plugin %s loaded", desc->name); } static gboolean enable_plugin(const char *name, char **cli_enable, @@ -181,7 +205,6 @@ static void external_plugin_init(char **cli_disabled, char **cli_enabled) void plugin_init(const char *enable, const char *disable) { - GSList *list; char **cli_disabled = NULL; char **cli_enabled = NULL; unsigned int i; @@ -208,24 +231,6 @@ void plugin_init(const char *enable, const char *disable) external_plugin_init(cli_enabled, cli_disabled); - for (list = plugins; list; list = list->next) { - struct bluetooth_plugin *plugin = list->data; - int err; - - err = plugin->desc->init(); - if (err < 0) { - if (err == -ENOSYS || err == -ENOTSUP) - warn("System does not support %s plugin", - plugin->desc->name); - else - error("Failed to init %s plugin", - plugin->desc->name); - continue; - } - - plugin->active = TRUE; - } - g_strfreev(cli_enabled); g_strfreev(cli_disabled); } @@ -239,7 +244,7 @@ void plugin_cleanup(void) for (list = plugins; list; list = list->next) { struct bluetooth_plugin *plugin = list->data; - if (plugin->active == TRUE && plugin->desc->exit) + if (plugin->desc->exit) plugin->desc->exit(); #if EXTERNAL_PLUGINS From patchwork Thu Jan 25 00:07:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 766911 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D443D7FB for ; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; cv=none; b=hggfsj0ry/WjBkBvoODEteVp+QQwYvK0kUSVbSky7MSVl22wEAChx7O2XRRuI4MTEzJgeQ3RhhaXY/yytjsFxCR0g8IxteJHAEgPWdTUq+YDPDuGb9DkTEOG0fWwVpq3BfRJyo6NCgN8STR7hOxOGe4NdD+xJfmUbwGygTg8KWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706141249; c=relaxed/simple; bh=mb3vibSeCho7dxgk/hsygvpcHcp9zzLKyD4RpuB1Dx8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WbpxzUyxsw+LFrNidmoTI8frNAvdoCRhDKYthnvFtcDJYnhZCScs/VwDC6Rup41wY0GcQZyjMhC2l5qLzm0ddt2cDHZMFh+Edu2eEWxBf+gyu2ZI88vlSUBQ+EtHPvZ9VAh/C7NOhJg1IHsSIrhjC3XmDBqg73ZOJZ7RS1Q6pvw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rJFb358M; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rJFb358M" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8F90BC433B2; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706141249; bh=mb3vibSeCho7dxgk/hsygvpcHcp9zzLKyD4RpuB1Dx8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=rJFb358MzAw5LZ67Gm+tYneIvcCoDvCRCRy/QdV+iJTsfe0YaUQLvZa7YloIuEQXL V3CJcfhNWZTbDcMwfQIZRAhnpIO0Qjv9hLyqFuL7ZECdwQowoBWoKAPH9DlygdBqz/ suxCr5wp9PVkpTx1UAVPtL9akZUUFhK5gAt5VDwpNTbWJ/3Aa5p6/IIcjDIvBVlxaH gqKKRo111rGm4iBmQEcWuLiQCzXsi4olReWBzRz7KcpK9UpGijsKRg6X4sHifbJokA thXEyLGuf881VhoW234eP3smjdcSZ1Ymz8atAkqBm6p1jprXVdDYQ7Nj5Q1EOtLJom n5V0UCjPEBzsQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 808A1C47E49; Thu, 25 Jan 2024 00:07:29 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Thu, 25 Jan 2024 00:07:33 +0000 Subject: [PATCH BlueZ v3 8/8] android: export only (android) entrypoint from the modules Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240125-rm-ext-plugins-v3-8-d141f7870bb6@gmail.com> References: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> In-Reply-To: <20240125-rm-ext-plugins-v3-0-d141f7870bb6@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706141247; l=3016; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=A9wt+5pbCxd+p0NIbARFNH3H5ujiQXTs0z8giNMkb3Y=; b=/aEvjGs3MbYixjLOan9wWHGqwyPZWWCZK59mBHKklNkQ5PYGLAlkoCB4NKv7P+fayVcjuXLYp PAWOS9I/kbvBH54JomfS9UfDqU1y7LBVAgRtWiLL4eDfiWL/x3R/AXH X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov The android specific modules, have a designated HMI entrypoint. Hide everything else with -fvisibility=hidden. --- android/Makefile.am | 3 +++ android/hal-audio.c | 1 + android/hal-bluetooth.c | 1 + android/hal-sco.c | 1 + 4 files changed, 6 insertions(+) diff --git a/android/Makefile.am b/android/Makefile.am index 309910147..e3756e89c 100644 --- a/android/Makefile.am +++ b/android/Makefile.am @@ -96,6 +96,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \ android/hal-log.h \ android/hal-ipc.h android/hal-ipc.c \ android/hal-utils.h android/hal-utils.c +android_bluetooth_default_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden android_bluetooth_default_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/android android_bluetooth_default_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version \ -no-undefined @@ -195,6 +196,7 @@ android_audio_a2dp_default_la_SOURCES = android/audio-msg.h \ android/hardware/audio_effect.h \ android/hardware/hardware.h \ android/system/audio.h +android_audio_a2dp_default_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden android_audio_a2dp_default_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/android \ $(SBC_CFLAGS) android_audio_a2dp_default_la_LIBADD = $(SBC_LIBS) -lrt @@ -212,6 +214,7 @@ android_audio_sco_default_la_SOURCES = android/hal-log.h \ android/audio_utils/resampler.c \ android/audio_utils/resampler.h \ android/system/audio.h +android_audio_sco_default_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden android_audio_sco_default_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/android android_audio_sco_default_la_LIBADD = $(SPEEXDSP_LIBS) -lrt android_audio_sco_default_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version \ diff --git a/android/hal-audio.c b/android/hal-audio.c index d37d6098c..f3d9b40a6 100644 --- a/android/hal-audio.c +++ b/android/hal-audio.c @@ -1618,6 +1618,7 @@ static struct hw_module_methods_t hal_module_methods = { .open = audio_open, }; +__attribute__ ((visibility("default"))) struct audio_module HAL_MODULE_INFO_SYM = { .common = { .tag = HARDWARE_MODULE_TAG, diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c index d4442e620..7d1e5ac63 100644 --- a/android/hal-bluetooth.c +++ b/android/hal-bluetooth.c @@ -1117,6 +1117,7 @@ static struct hw_module_methods_t bluetooth_module_methods = { .open = open_bluetooth, }; +__attribute__ ((visibility("default"))) struct hw_module_t HAL_MODULE_INFO_SYM = { .tag = HARDWARE_MODULE_TAG, .version_major = 1, diff --git a/android/hal-sco.c b/android/hal-sco.c index d7c08a68b..3d66ad357 100644 --- a/android/hal-sco.c +++ b/android/hal-sco.c @@ -1507,6 +1507,7 @@ static struct hw_module_methods_t hal_module_methods = { .open = sco_open, }; +__attribute__ ((visibility("default"))) struct audio_module HAL_MODULE_INFO_SYM = { .common = { .tag = HARDWARE_MODULE_TAG,