summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2023-03-14 12:48:34 +0100
committerLubomir Rintel <lkundrak@v3.sk>2023-03-16 17:53:16 +0100
commit8425edeb00cc79b7f4586107989898d3213a2afc (patch)
treecb6d4fccac9732d15eb6855f6d3d3c34567dba32
parente685c5ebb6931c03759ebb4306962cac3c334a1a (diff)
downloadNetworkManager-8425edeb00cc79b7f4586107989898d3213a2afc.tar.gz
WIP: config-data: add on-add-and-activate= to [connection*]
This marks the [connection*] section as taking effect on connection being added with AddAndActivate as opposed to impacting the existing connections. [connection.wifi] match-device=type:wifi on-add-and-activate=yes 802-11-wireless.assigned-mac-address=stable TODO: document, figure out if this is a good idea, make it suck less if possible
-rw-r--r--src/core/nm-config-data.c16
-rw-r--r--src/libnm-base/nm-config-base.h5
2 files changed, 18 insertions, 3 deletions
diff --git a/src/core/nm-config-data.c b/src/core/nm-config-data.c
index fd65cf5b78..a6dd2ab424 100644
--- a/src/core/nm-config-data.c
+++ b/src/core/nm-config-data.c
@@ -19,6 +19,7 @@
typedef struct {
char *group_name;
gboolean stop_match;
+ gboolean on_add_and_activate;
struct {
/* have a separate boolean field @has, because a @spec with
* value %NULL does not necessarily mean, that the property
@@ -1493,6 +1494,7 @@ _match_section_infos_foreach(const MatchSectionInfo *match_section_infos,
NMDevice *device,
const NMPlatformLink *pllink,
const char *match_device_type,
+ gboolean on_add_and_activate,
gpointer (*match_section_cb)(const MatchSectionInfo *m,
GKeyFile *keyfile,
gpointer user_data),
@@ -1504,6 +1506,9 @@ _match_section_infos_foreach(const MatchSectionInfo *match_section_infos,
if (!match_section_infos)
goto out;
+ if (match_section_infos->on_add_and_activate != on_add_and_activate)
+ goto out;
+
match_dhcp_plugin = nm_dhcp_manager_get_config(nm_dhcp_manager_get());
for (; match_section_infos->group_name; match_section_infos++) {
@@ -1561,6 +1566,7 @@ _match_section_infos_lookup(const MatchSectionInfo *match_section_infos,
device,
pllink,
match_device_type,
+ FALSE,
_match_section_info_get_str,
(gpointer) property,
(gpointer *) out_value);
@@ -1783,6 +1789,11 @@ _match_section_info_init(MatchSectionInfo *connection_info,
&connection_info->match_device.has);
connection_info->stop_match =
nm_config_keyfile_get_boolean(keyfile, group, NM_CONFIG_KEYFILE_KEY_STOP_MATCH, FALSE);
+ connection_info->on_add_and_activate =
+ nm_config_keyfile_get_boolean(keyfile,
+ group,
+ NM_CONFIG_KEYFILE_KEY_ON_ADD_AND_ACTIVATE,
+ FALSE);
if (is_device) {
connection_info->device.allowed_connections =
@@ -1801,7 +1812,10 @@ _match_section_info_init(MatchSectionInfo *connection_info,
gs_free char *key = g_steal_pointer(&keys[i]);
char *value;
- if (NM_IN_STRSET(key, NM_CONFIG_KEYFILE_KEY_STOP_MATCH, NM_CONFIG_KEYFILE_KEY_MATCH_DEVICE))
+ if (NM_IN_STRSET(key,
+ NM_CONFIG_KEYFILE_KEY_STOP_MATCH,
+ NM_CONFIG_KEYFILE_KEY_MATCH_DEVICE,
+ NM_CONFIG_KEYFILE_KEY_ON_ADD_AND_ACTIVATE))
continue;
if (j > 0 && nm_streq(vals[j - 1].name, key))
diff --git a/src/libnm-base/nm-config-base.h b/src/libnm-base/nm-config-base.h
index c413e867ea..d6c56d0231 100644
--- a/src/libnm-base/nm-config-base.h
+++ b/src/libnm-base/nm-config-base.h
@@ -71,8 +71,9 @@
#define NM_CONFIG_KEYFILE_KEY_DEVICE_CARRIER_WAIT_TIMEOUT "carrier-wait-timeout"
#define NM_CONFIG_KEYFILE_KEY_DEVICE_WIFI_IWD_AUTOCONNECT "wifi.iwd.autoconnect"
-#define NM_CONFIG_KEYFILE_KEY_MATCH_DEVICE "match-device"
-#define NM_CONFIG_KEYFILE_KEY_STOP_MATCH "stop-match"
+#define NM_CONFIG_KEYFILE_KEY_MATCH_DEVICE "match-device"
+#define NM_CONFIG_KEYFILE_KEY_STOP_MATCH "stop-match"
+#define NM_CONFIG_KEYFILE_KEY_ON_ADD_AND_ACTIVATE "on-add-and-activate"
#define NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS ".was" /* check-config-options skip */
#define NM_CONFIG_KEYFILE_KEY_CONFIG_ENABLE "enable" /* check-config-options skip */