diff options
author | Dan Williams <dcbw@redhat.com> | 2013-06-17 15:44:23 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2013-06-21 16:17:18 -0500 |
commit | 00203a879832db2a1fb9694c8ca8259f85a67ab4 (patch) | |
tree | 4cbd8443d7ee97e9d65ab130c43c6b79656f0fda | |
parent | e1bb469f80b240c86f54b7855f713871cffdc8cb (diff) |
libnm-util: add gateway-ping-timeout property to connection setting
To better handle broken hardware, like switches which don't pass
traffic for a few seconds after a carrier has been negotiated,
add a timeout to control how long to wait for successful pings
of the gateway before giving up and proceeding with IP config.
Default is 0, which means don't ping the gateway, just assume
the NIC/switch aren't lying and can pass traffic immediately.
-rw-r--r-- | libnm-util/libnm-util.ver | 1 | ||||
-rw-r--r-- | libnm-util/nm-setting-connection.c | 44 | ||||
-rw-r--r-- | libnm-util/nm-setting-connection.h | 3 |
3 files changed, 48 insertions, 0 deletions
diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver index 4a138f04..e1101f75 100644 --- a/libnm-util/libnm-util.ver +++ b/libnm-util/libnm-util.ver @@ -241,6 +241,7 @@ global: nm_setting_connection_error_quark; nm_setting_connection_get_autoconnect; nm_setting_connection_get_connection_type; + nm_setting_connection_get_gateway_ping_timeout; nm_setting_connection_get_id; nm_setting_connection_get_interface_name; nm_setting_connection_get_master; diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c index 49ffc5ab..448d1039 100644 --- a/libnm-util/nm-setting-connection.c +++ b/libnm-util/nm-setting-connection.c @@ -92,6 +92,7 @@ typedef struct { gboolean read_only; char *zone; GSList *secondaries; /* secondary connections to activate with the base connection */ + guint gateway_ping_timeout; } NMSettingConnectionPrivate; enum { @@ -108,6 +109,7 @@ enum { PROP_MASTER, PROP_SLAVE_TYPE, PROP_SECONDARIES, + PROP_GATEWAY_PING_TIMEOUT, LAST_PROP }; @@ -656,6 +658,24 @@ nm_setting_connection_remove_secondary (NMSettingConnection *setting, guint32 id g_object_notify (G_OBJECT (setting), NM_SETTING_CONNECTION_SECONDARIES); } +/** + * nm_setting_connection_get_gateway_ping_timeout: + * @setting: the #NMSettingConnection + * + * Returns: the value contained in the #NMSettingConnection:gateway-ping-timeout + * property. + * + * Since: 0.9.10 + **/ +guint32 +nm_setting_connection_get_gateway_ping_timeout (NMSettingConnection *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_CONNECTION (setting), 0); + + return NM_SETTING_CONNECTION_GET_PRIVATE (setting)->gateway_ping_timeout; +} + + static gint find_setting_by_name (gconstpointer a, gconstpointer b) { @@ -920,6 +940,9 @@ set_property (GObject *object, guint prop_id, g_slist_free_full (priv->secondaries, g_free); priv->secondaries = g_value_dup_boxed (value); break; + case PROP_GATEWAY_PING_TIMEOUT: + priv->gateway_ping_timeout = g_value_get_uint (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -980,6 +1003,9 @@ get_property (GObject *object, guint prop_id, case PROP_SECONDARIES: g_value_set_boxed (value, priv->secondaries); break; + case PROP_GATEWAY_PING_TIMEOUT: + g_value_set_uint (value, priv->gateway_ping_timeout); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1267,4 +1293,22 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) "when the base connection itself is activated.", DBUS_TYPE_G_LIST_OF_STRING, G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_FUZZY_IGNORE)); + + /** + * NMSettingConnection:gateway-ping-timeout: + * + * If greater than zero, delay success of IP addressing until either the + * timeout is reached, or an IP gateway replies to a ping. + * + * Since: 0.9.10 + **/ + g_object_class_install_property + (object_class, PROP_GATEWAY_PING_TIMEOUT, + g_param_spec_uint (NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT, + "Gateway Ping Timeout", + "If greater than zero, delay success of IP " + "addressing until either the timeout is reached, or " + "an IP gateway replies to a ping.", + 0, 30, 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); } diff --git a/libnm-util/nm-setting-connection.h b/libnm-util/nm-setting-connection.h index fd6f30d0..945ff775 100644 --- a/libnm-util/nm-setting-connection.h +++ b/libnm-util/nm-setting-connection.h @@ -80,6 +80,7 @@ GQuark nm_setting_connection_error_quark (void); #define NM_SETTING_CONNECTION_MASTER "master" #define NM_SETTING_CONNECTION_SLAVE_TYPE "slave-type" #define NM_SETTING_CONNECTION_SECONDARIES "secondaries" +#define NM_SETTING_CONNECTION_GATEWAY_PING_TIMEOUT "gateway-ping-timeout" /** * NMSettingConnection: @@ -135,6 +136,8 @@ const char *nm_setting_connection_get_secondary (NMSettingConnection *set gboolean nm_setting_connection_add_secondary (NMSettingConnection *setting, const char *sec_uuid); void nm_setting_connection_remove_secondary (NMSettingConnection *setting, guint32 idx); +guint32 nm_setting_connection_get_gateway_ping_timeout (NMSettingConnection *setting); + G_END_DECLS #endif /* NM_SETTING_CONNECTION_H */ |