summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2015-05-06 10:54:35 +0200
committerJiří Klimeš <jklimes@redhat.com>2015-06-19 09:32:58 +0200
commit6caafab258762713a354cf37591510b6ac29936c (patch)
tree7fe4e46ae16bc7cdc79be0b661f8fc55a642d24b
parent203e48033ba34a175be96da08f54b6d06916820f (diff)
downloadNetworkManager-6caafab258762713a354cf37591510b6ac29936c.tar.gz
libnm: add autoconnect-slaves property to NMSettingConnection
The property is used for controlling whether slaves should be brought up with a master connection. If 0, activating the master will not activate slaves. But if set to 1, activating the master will bring up slaves as well. The property can have the third state (-1), meaning that the value is default. That is either a value set in the configuration file for the property, or 0.
-rw-r--r--libnm-core/nm-setting-connection.c59
-rw-r--r--libnm-core/nm-setting-connection.h22
-rw-r--r--libnm-core/tests/test-general.c1
-rw-r--r--libnm/libnm.ver2
4 files changed, 84 insertions, 0 deletions
diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c
index 5812a0a442..6832a985d6 100644
--- a/libnm-core/nm-setting-connection.c
+++ b/libnm-core/nm-setting-connection.c
@@ -27,6 +27,7 @@
#include "nm-utils.h"
#include "nm-utils-private.h"
+#include "nm-core-enum-types.h"
#include "nm-setting-connection.h"
#include "nm-connection-private.h"
#include "nm-setting-bond.h"
@@ -66,6 +67,7 @@ typedef struct {
char *type;
char *master;
char *slave_type;
+ NMSettingConnectionAutoconnectSlaves autoconnect_slaves;
GSList *permissions; /* list of Permission structs */
gboolean autoconnect;
gint autoconnect_priority;
@@ -91,6 +93,7 @@ enum {
PROP_ZONE,
PROP_MASTER,
PROP_SLAVE_TYPE,
+ PROP_AUTOCONNECT_SLAVES,
PROP_SECONDARIES,
PROP_GATEWAY_PING_TIMEOUT,
PROP_METERED,
@@ -605,6 +608,25 @@ nm_setting_connection_is_slave_type (NMSettingConnection *setting,
}
/**
+ * nm_setting_connection_get_autoconnect_slaves:
+ * @setting: the #NMSettingConnection
+ *
+ * Returns the #NMSettingConnection:autoconnect-slaves property of the connection.
+ *
+ * Returns: whether slaves of the connection should be activated together
+ * with the connection.
+ *
+ * Since: 1.2
+ **/
+NMSettingConnectionAutoconnectSlaves
+nm_setting_connection_get_autoconnect_slaves (NMSettingConnection *setting)
+{
+ g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT);
+
+ return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->autoconnect_slaves;
+}
+
+/**
* nm_setting_connection_get_num_secondaries:
* @setting: the #NMSettingConnection
*
@@ -1153,6 +1175,9 @@ set_property (GObject *object, guint prop_id,
g_free (priv->slave_type);
priv->slave_type = g_value_dup_string (value);
break;
+ case PROP_AUTOCONNECT_SLAVES:
+ priv->autoconnect_slaves = g_value_get_enum (value);
+ break;
case PROP_SECONDARIES:
g_slist_free_full (priv->secondaries, g_free);
priv->secondaries = _nm_utils_strv_to_slist (g_value_get_boxed (value));
@@ -1227,6 +1252,9 @@ get_property (GObject *object, guint prop_id,
case PROP_SLAVE_TYPE:
g_value_set_string (value, nm_setting_connection_get_slave_type (setting));
break;
+ case PROP_AUTOCONNECT_SLAVES:
+ g_value_set_enum (value, nm_setting_connection_get_autoconnect_slaves (setting));
+ break;
case PROP_SECONDARIES:
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->secondaries));
break;
@@ -1561,6 +1589,37 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
G_PARAM_STATIC_STRINGS));
/**
+ * NMSettingConnection:autoconnect-slaves:
+ *
+ * Whether or not slaves of this connection should be automatically brought up
+ * when NetworkManager activates this connection. This only has a real effect
+ * for master connections.
+ * The permitted values are: 0: leave slave connections untouched,
+ * 1: activate all the slave connections with this connection, -1: default.
+ * If -1 (default) is set, global connection.autoconnect-slaves is read to
+ * determine the real value. If it is default as well, this fallbacks to 0.
+ *
+ * Since: 1.2
+ **/
+ /* ---ifcfg-rh---
+ * property: autoconnect-slaves
+ * variable: AUTOCONNECT-SLAVES(+)
+ * default: no
+ * description: Whether slaves of this connection should be auto-connected
+ * when this connection is activated.
+ * ---end---
+ */
+ g_object_class_install_property
+ (object_class, PROP_AUTOCONNECT_SLAVES,
+ g_param_spec_enum (NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, "", "",
+ NM_TYPE_SETTING_CONNECTION_AUTOCONNECT_SLAVES,
+ NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ NM_SETTING_PARAM_FUZZY_IGNORE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
* NMSettingConnection:secondaries:
*
* List of connection UUIDs that should be activated when the base
diff --git a/libnm-core/nm-setting-connection.h b/libnm-core/nm-setting-connection.h
index 1692fe2c53..0f502c955e 100644
--- a/libnm-core/nm-setting-connection.h
+++ b/libnm-core/nm-setting-connection.h
@@ -56,10 +56,30 @@ G_BEGIN_DECLS
#define NM_SETTING_CONNECTION_ZONE "zone"
#define NM_SETTING_CONNECTION_MASTER "master"
#define NM_SETTING_CONNECTION_SLAVE_TYPE "slave-type"
+#define NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES "autoconnect-slaves"
#define NM_SETTING_CONNECTION_SECONDARIES "secondaries"
#define NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT "gateway-ping-timeout"
#define NM_SETTING_CONNECTION_METERED "metered"
+/* Types for property values */
+/**
+ * NMSettingConnectionAutoconnectSlaves:
+ * @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT: default value
+ * @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO: slaves are not brought up when
+ * master is activated
+ * @NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES: slaves are brought up when
+ * master is activated
+ *
+ * #NMSettingConnectionAutoconnectSlaves values indicate whether slave connections
+ * should be activated when master is activated.
+ */
+typedef enum {
+ NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT = -1,
+ NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO = 0,
+ NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES = 1,
+} NMSettingConnectionAutoconnectSlaves;
+
+
/**
* NMSettingConnection:
*
@@ -112,6 +132,8 @@ const char *nm_setting_connection_get_master (NMSettingConnection *set
gboolean nm_setting_connection_is_slave_type (NMSettingConnection *setting,
const char *type);
const char *nm_setting_connection_get_slave_type (NMSettingConnection *setting);
+NM_AVAILABLE_IN_1_2
+NMSettingConnectionAutoconnectSlaves nm_setting_connection_get_autoconnect_slaves (NMSettingConnection *setting);
guint32 nm_setting_connection_get_num_secondaries (NMSettingConnection *setting);
const char *nm_setting_connection_get_secondary (NMSettingConnection *setting, guint32 idx);
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index 670a0f3e97..24128862ba 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -1968,6 +1968,7 @@ test_connection_diff_a_only (void)
{ NM_SETTING_CONNECTION_ZONE, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_CONNECTION_MASTER, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_CONNECTION_SLAVE_TYPE, NM_SETTING_DIFF_RESULT_IN_A },
+ { NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_CONNECTION_SECONDARIES, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, NM_SETTING_DIFF_RESULT_IN_A },
{ NM_SETTING_CONNECTION_METERED, NM_SETTING_DIFF_RESULT_IN_A },
diff --git a/libnm/libnm.ver b/libnm/libnm.ver
index 34890414c3..e8990c3e98 100644
--- a/libnm/libnm.ver
+++ b/libnm/libnm.ver
@@ -853,6 +853,8 @@ global:
nm_metered_get_type;
nm_setting_802_1x_check_cert_scheme;
nm_setting_bridge_get_multicast_snooping;
+ nm_setting_connection_autoconnect_slaves_get_type;
+ nm_setting_connection_get_autoconnect_slaves;
nm_setting_connection_get_metered;
nm_setting_ip_config_add_dns_option;
nm_setting_ip_config_clear_dns_options;