summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-09-18 17:21:34 +0200
committerThomas Haller <thaller@redhat.com>2015-09-18 17:31:51 +0200
commitc9b3617c35b3380428a1800e8aa6692ee68b4b74 (patch)
tree678420b32d73c4572cd5345b3b83335a34cb4c9d
parentb1ebbf4c809c859d1ea94032ce7eb8fbf5e45d40 (diff)
downloadNetworkManager-c9b3617c35b3380428a1800e8aa6692ee68b4b74.tar.gz
libnm: mark properties that take effect immediately on active connection (REAPPLY_IMMEDIATELY)
The flag is still unused.
-rw-r--r--libnm-core/nm-core-internal.h14
-rw-r--r--libnm-core/nm-setting-connection.c8
-rw-r--r--libnm-core/nm-setting-private.h10
-rw-r--r--libnm-core/nm-setting.c7
-rw-r--r--libnm-core/nm-setting.h2
5 files changed, 39 insertions, 2 deletions
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h
index 957970b37e..b55170b831 100644
--- a/libnm-core/nm-core-internal.h
+++ b/libnm-core/nm-core-internal.h
@@ -80,8 +80,20 @@
* takes into account properties marked with the %NM_SETTING_PARAM_INFERRABLE
* flag.
*/
-#define NM_SETTING_COMPARE_FLAG_INFERRABLE 0x80000000
+#define NM_SETTING_COMPARE_FLAG_INFERRABLE ((NMSettingCompareFlags) 0x80000000)
+/* NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY: this flag is used for properties
+ * that automatically get re-applied on an active connection when the settings
+ * connection is modified. For most properties, the applied-connection is distinct
+ * from the setting-connection and changes don't propagate. Exceptions are the
+ * firewall-zone and the metered property.
+ */
+#define NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY ((NMSettingCompareFlags) 0x40000000)
+
+/* NM_SETTING_COMPARE_FLAG_NONE: for convenience, define a special flag NONE -- which
+ * equals to numeric zero (NM_SETTING_COMPARE_FLAG_EXACT).
+ */
+#define NM_SETTING_COMPARE_FLAG_NONE ((NMSettingCompareFlags) 0)
#define NM_SETTING_SECRET_FLAGS_ALL \
diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c
index 32469e5376..0217c358c1 100644
--- a/libnm-core/nm-setting-connection.c
+++ b/libnm-core/nm-setting-connection.c
@@ -1533,6 +1533,9 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
* (for example "Home", "Work", "Public"). %NULL or unspecified zone means
* the connection will be placed in the default zone as defined by the
* firewall.
+ *
+ * When updating this property on a currently activated connection,
+ * the change takes effect immediately.
**/
/* ---ifcfg-rh---
* property: zone
@@ -1549,6 +1552,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
NM_SETTING_PARAM_FUZZY_IGNORE |
+ NM_SETTING_PARAM_REAPPLY_IMMEDIATELY |
G_PARAM_STATIC_STRINGS));
/**
@@ -1677,6 +1681,9 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
*
* Whether the connection is metered.
*
+ * When updating this property on a currently activated connection,
+ * the change takes effect immediately.
+ *
* Since: 1.2
**/
/* ---ifcfg-rh---
@@ -1693,5 +1700,6 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
NM_TYPE_METERED,
NM_METERED_UNKNOWN,
G_PARAM_READWRITE |
+ NM_SETTING_PARAM_REAPPLY_IMMEDIATELY |
G_PARAM_STATIC_STRINGS));
}
diff --git a/libnm-core/nm-setting-private.h b/libnm-core/nm-setting-private.h
index aa90d9c73d..8f59e26303 100644
--- a/libnm-core/nm-setting-private.h
+++ b/libnm-core/nm-setting-private.h
@@ -89,6 +89,16 @@ gboolean _nm_setting_clear_secrets_with_flags (NMSetting *setting,
/* This is a legacy property, which clients should not send to the daemon. */
#define NM_SETTING_PARAM_LEGACY (1 << (5 + G_PARAM_USER_SHIFT))
+/* When a connection is active and gets modified, usually the change
+ * to the settings-connection does not propagate automatically to the
+ * applied-connection of the device. For certain properties like the
+ * firewall zone and the metered property, this is different.
+ *
+ * Such fields can be ignored during nm_connection_compare() with the
+ * NMSettingCompareFlag NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY.
+ */
+#define NM_SETTING_PARAM_REAPPLY_IMMEDIATELY (1 << (6 + G_PARAM_USER_SHIFT))
+
/* Ensure the setting's GType is registered at library load time */
#define NM_SETTING_REGISTER_TYPE(x) \
static void __attribute__((constructor)) register_setting (void) \
diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c
index 4eda1e1299..0f8347c166 100644
--- a/libnm-core/nm-setting.c
+++ b/libnm-core/nm-setting.c
@@ -1107,6 +1107,10 @@ nm_setting_compare (NMSetting *a,
&& !NM_FLAGS_HAS (prop_spec->flags, NM_SETTING_PARAM_INFERRABLE))
continue;
+ if ( NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY)
+ && NM_FLAGS_HAS (prop_spec->flags, NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))
+ continue;
+
if ( NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS)
&& NM_FLAGS_HAS (prop_spec->flags, NM_SETTING_PARAM_SECRET))
continue;
@@ -1132,6 +1136,9 @@ should_compare_prop (NMSetting *setting,
if ((comp_flags & NM_SETTING_COMPARE_FLAG_INFERRABLE) && !(prop_flags & NM_SETTING_PARAM_INFERRABLE))
return FALSE;
+ if ((comp_flags & NM_SETTING_COMPARE_FLAG_IGNORE_REAPPLY_IMMEDIATELY) && !(prop_flags & NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))
+ return FALSE;
+
if (prop_flags & NM_SETTING_PARAM_SECRET) {
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
diff --git a/libnm-core/nm-setting.h b/libnm-core/nm-setting.h
index 3601fce30b..5df73663cb 100644
--- a/libnm-core/nm-setting.h
+++ b/libnm-core/nm-setting.h
@@ -127,7 +127,7 @@ typedef enum {
NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT = 0x00000040,
NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP = 0x00000080,
- /* 0x80000000 is used for a private flag */
+ /* Higher flags like 0x80000000 and 0x40000000 are used internally as private flags */
} NMSettingCompareFlags;