mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-03 10:10:28 +01:00
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
This commit is contained in:
parent
92a8cfac69
commit
51d7a18f2e
4 changed files with 49 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
@ -531,6 +533,25 @@ nm_setting_connection_get_autoconnect_priority (NMSettingConnection *setting)
|
|||
return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->autoconnect_priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ G_BEGIN_DECLS
|
|||
#define NM_SETTING_CONNECTION_TYPE "type"
|
||||
#define NM_SETTING_CONNECTION_AUTOCONNECT "autoconnect"
|
||||
#define NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY "autoconnect-priority"
|
||||
#define NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES "autoconnect-retries"
|
||||
#define NM_SETTING_CONNECTION_TIMESTAMP "timestamp"
|
||||
#define NM_SETTING_CONNECTION_READ_ONLY "read-only"
|
||||
#define NM_SETTING_CONNECTION_PERMISSIONS "permissions"
|
||||
|
|
@ -123,6 +124,8 @@ const char *nm_setting_connection_get_interface_name (NMSettingConnection *set
|
|||
const char *nm_setting_connection_get_connection_type (NMSettingConnection *setting);
|
||||
gboolean nm_setting_connection_get_autoconnect (NMSettingConnection *setting);
|
||||
gint nm_setting_connection_get_autoconnect_priority (NMSettingConnection *setting);
|
||||
NM_AVAILABLE_IN_1_6
|
||||
gint nm_setting_connection_get_autoconnect_retries (NMSettingConnection *setting);
|
||||
guint64 nm_setting_connection_get_timestamp (NMSettingConnection *setting);
|
||||
gboolean nm_setting_connection_get_read_only (NMSettingConnection *setting);
|
||||
|
||||
|
|
|
|||
|
|
@ -1922,6 +1922,7 @@ test_connection_diff_a_only (void)
|
|||
{ NM_SETTING_CONNECTION_TIMESTAMP, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_AUTOCONNECT, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_AUTOCONNECT_RETRIES, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_READ_ONLY, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_PERMISSIONS, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
{ NM_SETTING_CONNECTION_ZONE, NM_SETTING_DIFF_RESULT_IN_A },
|
||||
|
|
|
|||
|
|
@ -1088,6 +1088,7 @@ libnm_1_6_0 {
|
|||
global:
|
||||
nm_capability_get_type;
|
||||
nm_connection_get_setting_proxy;
|
||||
nm_setting_connection_get_autoconnect_retries;
|
||||
nm_setting_proxy_get_type;
|
||||
nm_setting_proxy_new;
|
||||
nm_setting_proxy_get_method;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue