Generalize Default Enabled Technologies
cover Generalize Default Enabled Technologies
Since nearly the beginning of connman, it has behaved such that the Ethernet technology is enabled (that is, powered) by default. Currently, this is hard-coded behavior into src/technology.c:technology_load.
However, if a different or additional technology is desired, there has historically been no way to achieve this via configuration.
The 'DefaultEnabledTechnologies' key/value pair introduced by this patch set is a list of technologies that are marked enabled (that is, powered) by default, separated by commas (","). The default value for this entry when empty is 'ethernet', matching the legacy behavior prior to the introduction of this setting.
Grant Erickson (3):
main: Introduce 'DefaultEnabledTechnologies' setting.
technology: Leverage 'DefaultEnabledTechnologies' setting.
doc: Document the 'DefaultEnabledTechnologies' setting.
doc/connman.conf.5.in | 5 +++++ src/main.c | 32 ++++++++++++++++++++++++++++++++ src/main.conf | 5 +++++ src/technology.c | 25 +++++++++++++++---------- 4 files changed, 57 insertions(+), 10 deletions(-)
Signature · 1 line
2.45.0
PATCH 1/3 main: Introduce 'DefaultEnabledTechnologies' setting.
This introduces a new 'DefaultEnabledTechnologies' configuration setting.
Since nearly the beginning of connman, it has behaved such that the Ethernet technology is enabled (that is, powered) by default. Currently, this is hard-coded behavior into src/technology.c:technology_load.
However, if a different or additional technology is desired, there has historically been no way to achieve this via configuration.
The 'DefaultEnabledTechnologies' key/value pair is a list of technologies that are marked enabled (that is, powered) by default, separated by commas ",". The default value for this entry when empty is 'ethernet', matching the legacy behavior prior to the introduction of this setting.
--- src/main.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
src/main.c +32 -0
@@ -78,6 +78,11 @@ static char *default_auto_connect[] = {NULL }; +static char *default_enabled_techs[] = { +"ethernet" , +NULL +}; +static char *default_favorite_techs[] = {"ethernet" ,NULL
@@ -99,6 +104,7 @@ static struct {bool bg_scan;char **pref_timeservers;unsigned int *auto_connect; +unsigned int *enabled_techs;unsigned int *favorite_techs;unsigned int *preferred_techs;unsigned int *always_connected_techs;
@@ -134,6 +140,7 @@ static struct { .bg_scan = true, .pref_timeservers = NULL, .auto_connect = NULL, + .enabled_techs = NULL, .favorite_techs = NULL, .preferred_techs = NULL, .always_connected_techs = NULL,
@@ -171,6 +178,7 @@ static struct {#define CONF_BG_SCAN "BackgroundScanning"#define CONF_PREF_TIMESERVERS "FallbackTimeservers"#define CONF_AUTO_CONNECT_TECHS "DefaultAutoConnectTechnologies" +#define CONF_ENABLED_TECHS "DefaultEnabledTechnologies"#define CONF_FAVORITE_TECHS "DefaultFavoriteTechnologies"#define CONF_ALWAYS_CONNECTED_TECHS "AlwaysConnectedTechnologies"#define CONF_PREFERRED_TECHS "PreferredTechnologies"
@@ -207,6 +215,7 @@ static const char *supported_options[] = {CONF_BG_SCAN ,CONF_PREF_TIMESERVERS ,CONF_AUTO_CONNECT_TECHS , +CONF_ENABLED_TECHS ,CONF_FAVORITE_TECHS ,CONF_ALWAYS_CONNECTED_TECHS , CONF_PREFERRED_TECHS,
@@ -437,6 +446,9 @@ static void parse_config(GKeyFile *config, const char *file) connman_settings.auto_connect =parse_service_types (default_auto_connect,CONF_ARRAY_SIZE (default_auto_connect)); + connman_settings.enabled_techs = +parse_service_types (default_enabled_techs, +CONF_ARRAY_SIZE (default_enabled_techs)); connman_settings.favorite_techs =parse_service_types (default_favorite_techs,CONF_ARRAY_SIZE (default_favorite_techs));
@@ -481,6 +493,23 @@ static void parse_config(GKeyFile *config, const char *file)g_clear_error (&error); +/* DefaultEnabledTechnologies */ + + str_list =__connman_config_get_string_list (config,GENERAL_GROUP , +CONF_ENABLED_TECHS , &len, &error); + +if (!error) + connman_settings.enabled_techs = +parse_service_types (str_list, len); +else + connman_settings.enabled_techs = +parse_service_types (default_enabled_techs, +CONF_ARRAY_SIZE (default_enabled_techs)); + +g_strfreev (str_list); + +g_clear_error (&error); + str_list =__connman_config_get_string_list (config,GENERAL_GROUP ,CONF_FAVORITE_TECHS , &len, &error);
@@ -1111,6 +1140,9 @@ unsigned int *connman_setting_get_uint_list(const char *key)if (g_str_equal (key,CONF_AUTO_CONNECT_TECHS ))return connman_settings.auto_connect; +if (g_str_equal (key,CONF_ENABLED_TECHS )) +return connman_settings.enabled_techs; +if (g_str_equal (key,CONF_FAVORITE_TECHS ))return connman_settings.favorite_techs;
Signature · 1 line
2.45.0
PATCH 2/3 technology: Leverage 'DefaultEnabledTechnologies' setting.
In reply to Grant EricksonThis leverages the new 'DefaultEnabledTechnologies' configuration setting.
--- src/technology.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
src/technology.c +15 -10
@@ -429,19 +429,27 @@ static void technology_load(struct connman_technology *technology)GKeyFile *keyfile;gchar *identifier;GError *error =NULL ; -bool enable, need_saving = false; +bool enable, need_saving = false, enable_persistent = false;char *enc; +int i; +unsigned int *enabled_types;DBG ("technology %p" , technology); +/* Determine which technology types are enabled by default */ + + enabled_types =connman_setting_get_uint_list ("DefaultEnabledTechnologies" ); +for (i =0 ; enabled_types && enabled_types[i] !=0 ; i++) { +if (technology->type == enabled_types[i]) { + enable_persistent = true; +break ; + } + } + keyfile =__connman_storage_load_global ();/* Fallback on disabling technology if file not found. */ if (!keyfile) { -if (technology->type ==CONNMAN_SERVICE_TYPE_ETHERNET ) -/* We enable ethernet by default */ - technology->enable_persistent = true; -else - technology->enable_persistent = false; + technology->enable_persistent = enable_persistent;return ; }
@@ -453,10 +461,7 @@ static void technology_load(struct connman_technology *technology)if (!error) technology->enable_persistent = enable;else { -if (technology->type ==CONNMAN_SERVICE_TYPE_ETHERNET ) - technology->enable_persistent = true; -else - technology->enable_persistent = false; + technology->enable_persistent = enable_persistent; need_saving = true;g_clear_error (&error);
Signature · 1 line
2.45.0
Re: [PATCH 2/3] technology: Leverage 'DefaultEnabledTechnologies' setting.
Hi Grant,
Quoted 6 lines · Grant Erickson
This leverages the new 'DefaultEnabledTechnologies' configuration setting.
--- src/technology.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
<snip>
Quoted 5 lines
src/technology.c +0
-1@@ -429,19 +429,27 @@ static void technology_load(struct connman_technology *technology)GKeyFile *keyfile;gchar *identifier;GError *error =NULL ; -bool enable, need_saving = false;
src/technology.c static void technology_load(struct connman_technology *technology) · line 441
Quoted 10 lines
src/technology.c +6
-0+bool enable, need_saving = false, enable_persistent = false;char *enc; +int i; +unsigned int *enabled_types;DBG ("technology %p" , technology); +/* Determine which technology types are enabled by default */ + + enabled_types =connman_setting_get_uint_list ("DefaultEnabledTechnologies" );
I amended this patch slightly to avoid > 80 character line. I moved this initializer to the variable declaration block.
Perhaps instead of duplicating these strings everywhere, the CONF_* defines should move somewhere as public API?
src/technology.c static void technology_load(struct connman_technology *technology) · line 448
Quoted 7 lines
src/technology.c +7
-0+for (i =0 ; enabled_types && enabled_types[i] !=0 ; i++) { +if (technology->type == enabled_types[i]) { + enable_persistent = true; +break ; + } + } +
Regards,
-Denis
Re: [PATCH 2/3] technology: Leverage 'DefaultEnabledTechnologies' setting.
Quoted 9 lines · Denis Kenzior
Quoted 5 lines · Grant Erickson
This leverages the new 'DefaultEnabledTechnologies' configuration setting.
--- src/technology.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)<snip>
Quoted 15 lines
src/technology.c static void technology_load(struct connman_technology *technology) · line 439
Quoted 13 lines
src/technology.c +5
-1@@ -429,19 +429,27 @@ static void technology_load(struct connman_technology *technology)GKeyFile *keyfile;gchar *identifier;GError *error =NULL ; -bool enable, need_saving = false; +bool enable, need_saving = false, enable_persistent = false;char *enc; +int i; +unsigned int *enabled_types;DBG ("technology %p" , technology); +/* Determine which technology types are enabled by default */ + + enabled_types =connman_setting_get_uint_list ("DefaultEnabledTechnologies" );I amended this patch slightly to avoid > 80 character line. I moved this initializer to the variable declaration block.
Thank you.
Quoted 1 line
Perhaps instead of duplicating these strings everywhere, the CONF_* defines should move somewhere as public API?
Fully agreed. Do you have any preferences on where?
Best,
Grant
Signature · 5 lines
Principal Nuovations [email protected] https://www.nuovations.com/
Re: [PATCH 2/3] technology: Leverage 'DefaultEnabledTechnologies' setting.
Hi Grant,
Quoted 5 lines
Quoted 2 lines
Perhaps instead of duplicating these strings everywhere, the CONF_* defines should move somewhere as public API?
Fully agreed. Do you have any preferences on where?
ConnMan uses a single header file (src/connman.h), so that's as good a place as any for now. Maybe in the future we start modularizing the code a bit more, but that is a battle for another day.
Regards,
-Denis
PATCH 3/3 doc: Document the 'DefaultEnabledTechnologies' setting.
In reply to Grant EricksonThis documents the 'DefaultEnabledTechnologies' configuration setting.
--- doc/connman.conf.5.in | 5 +++++ src/main.conf | 5 +++++ 2 files changed, 10 insertions(+)
doc/connman.conf.5.in +5 -0
@@ -77,6 +77,11 @@ for this entry when empty is ethernet,wifi,cellular. Services that are automatically connected must have been set up and saved to storage beforehand. .TP +.BI DefaultEnabledTechnologies= technology\fR[,...] +List of technologies that are marked enabled or powered +by default, separated by commas ",". The default value for +this entry when empty is \fIethernet\fR. +.TP .BI DefaultFavoriteTechnologies= technology\fR[,...] List of technologies that are marked favorite by default, separated by commas ",". The default value for this entry
src/main.conf +5 -0
@@ -49,6 +49,11 @@ # set up and saved to storage beforehand. # DefaultAutoConnectTechnologies = +# List of technologies that are marked enabled or powered +# by default, separated by commas ",". The default value for +# this entry when empty is "ethernet". +# DefaultEnabledTechnologies + # List of preferred technologies from the most preferred # one to the least preferred one separated by commas ",". # Services of the listed technology type will be tried one
Signature · 1 line
2.45.0
This series was applied to connman.git (master) by Denis Kenzior <[email protected]>:
Hello:
This series was applied to connman.git (master)
by Denis Kenzior <[email protected]>:
Quoted 9 lines · On Mon, 28 Jul 2025 15:32:14 -0700 you wrote:
Since nearly the beginning of connman, it has behaved such that the Ethernet technology is enabled (that is, powered) by default. Currently, this is hard-coded behavior into src/technology.c:technology_load.
However, if a different or additional technology is desired, there has historically been no way to achieve this via configuration.
[...]
Here is the summary with links:
- [1/3] main: Introduce 'DefaultEnabledTechnologies' setting.
https://git.kernel.org/pub/scm/network/connman/connman.git/?id=007f9262a11c - [2/3] technology: Leverage 'DefaultEnabledTechnologies' setting. (no matching commit) - [3/3] doc: Document the 'DefaultEnabledTechnologies' setting. https://git.kernel.org/pub/scm/network/connman/connman.git/?id=efd671b00fbb
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html