diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2016-10-08 10:27:15 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-10-16 10:08:13 +0200 |
commit | 51d7a18f2e09c0c9e36c5f2995a356e2737931f5 (patch) | |
tree | d87a8e92b8817f1d5d2d4649892c78de18aa7d28 /libnm-core/nm-setting-connection.c | |
parent | 92a8cfac69d8ac00df94dc4da7a09d8f168d0c46 (diff) | |
download | NetworkManager-51d7a18f2e09c0c9e36c5f2995a356e2737931f5.tar.gz |
libnm-core: introduce connection.autoconnect-retries property
While technically it's already possible to implement a fail-over
mechanism using multiple connections (for example, defining a higher
priority DHCP connection with short DHCP timeout and a lower priority
one with static address), in practice this doesn't work well as we try
to autoactivate each connection 4 times before switching to the next
one.
Introduce a connection.autoconnect-retries property that can be used
to change the number of retries. The special value 0 means infinite
and can be used to try the connection forever. A -1 value means the
global configured default, which is equal to 4 unless overridden.
https://bugzilla.gnome.org/show_bug.cgi?id=763524
Diffstat (limited to 'libnm-core/nm-setting-connection.c')
-rw-r--r-- | libnm-core/nm-setting-connection.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index ed1c164a5e..af3f4d5615 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -72,6 +72,7 @@ typedef struct { GSList *permissions; /* list of Permission structs */ gboolean autoconnect; gint autoconnect_priority; + gint autoconnect_retries; guint64 timestamp; gboolean read_only; char *zone; @@ -90,6 +91,7 @@ enum { PROP_PERMISSIONS, PROP_AUTOCONNECT, PROP_AUTOCONNECT_PRIORITY, + PROP_AUTOCONNECT_RETRIES, PROP_TIMESTAMP, PROP_READ_ONLY, PROP_ZONE, @@ -532,6 +534,25 @@ nm_setting_connection_get_autoconnect_priority (NMSettingConnection *setting) } /** + * nm_setting_connection_get_autoconnect_retries: + * @setting: the #NMSettingConnection + * + * Returns the #NMSettingConnection:autoconnect-retries property of the connection. + * Zero means infinite, -1 means the global default value. + * + * Returns: the connection's autoconnect retries + * + * Since: 1.6 + **/ +gint +nm_setting_connection_get_autoconnect_retries (NMSettingConnection *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), -1); + + return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->autoconnect_retries; +} + +/** * nm_setting_connection_get_timestamp: * @setting: the #NMSettingConnection * @@ -1210,6 +1231,9 @@ set_property (GObject *object, guint prop_id, case PROP_AUTOCONNECT_PRIORITY: priv->autoconnect_priority = g_value_get_int (value); break; + case PROP_AUTOCONNECT_RETRIES: + priv->autoconnect_retries = g_value_get_int (value); + break; case PROP_TIMESTAMP: priv->timestamp = g_value_get_uint64 (value); break; @@ -1296,6 +1320,9 @@ get_property (GObject *object, guint prop_id, case PROP_AUTOCONNECT_PRIORITY: g_value_set_int (value, nm_setting_connection_get_autoconnect_priority (setting)); break; + case PROP_AUTOCONNECT_RETRIES: + g_value_set_int (value, nm_setting_connection_get_autoconnect_retries (setting)); + break; case PROP_TIMESTAMP: g_value_set_uint64 (value, nm_setting_connection_get_timestamp (setting)); break; @@ -1571,6 +1598,23 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS)); + + /** + * NMSettingConnection:autoconnect-retries: + * + * The number of times a connection should be tried when autoctivating before + * giving up. Zero means forever, -1 means the global default (4 times if not + * overridden). + */ + g_object_class_install_property + (object_class, PROP_AUTOCONNECT_RETRIES, + g_param_spec_int (NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES, "", "", + -1, G_MAXINT32, -1, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + NM_SETTING_PARAM_FUZZY_IGNORE | + G_PARAM_STATIC_STRINGS)); + /** * NMSettingConnection:timestamp: * |