summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-01-19 17:25:29 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2017-02-21 09:18:53 +0100
commit07570e245ac97054027acd928ed09ae2b83e62b0 (patch)
treea06f425ee44df65023acc05b78361052a00bf4f7
parent556a46959fa02720dd50faf7db616ef68be0d817 (diff)
downloadNetworkManager-07570e245ac97054027acd928ed09ae2b83e62b0.tar.gz
device: add support for 802-1x.auth-timeout
Use the per-connection authentication timeout for 802.1X Ethernet, MACsec and Wi-Fi connections. In case the value is not defined, fall back to the global one.
-rw-r--r--src/devices/nm-device-ethernet.c8
-rw-r--r--src/devices/nm-device-macsec.c9
-rw-r--r--src/devices/nm-device.c27
-rw-r--r--src/devices/nm-device.h1
-rw-r--r--src/devices/wifi/nm-device-wifi.c8
5 files changed, 46 insertions, 7 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index 9a2fd8c2f8..4a0367f1f0 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -751,6 +751,7 @@ static gboolean
supplicant_interface_init (NMDeviceEthernet *self)
{
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
+ guint timeout;
supplicant_interface_release (self);
@@ -770,8 +771,11 @@ supplicant_interface_init (NMDeviceEthernet *self)
G_CALLBACK (supplicant_iface_state_cb),
self);
- /* Set up a timeout on the connection attempt to fail it after 25 seconds */
- priv->supplicant.con_timeout_id = g_timeout_add_seconds (25, supplicant_connection_timeout_cb, self);
+ /* Set up a timeout on the connection attempt */
+ timeout = nm_device_get_supplicant_timeout (NM_DEVICE (self));
+ priv->supplicant.con_timeout_id = g_timeout_add_seconds (timeout,
+ supplicant_connection_timeout_cb,
+ self);
return TRUE;
}
diff --git a/src/devices/nm-device-macsec.c b/src/devices/nm-device-macsec.c
index 6c8b98cba3..350502d652 100644
--- a/src/devices/nm-device-macsec.c
+++ b/src/devices/nm-device-macsec.c
@@ -551,6 +551,7 @@ supplicant_interface_init (NMDeviceMacsec *self)
{
NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self);
NMDevice *parent;
+ guint timeout;
parent = nm_device_parent_get_device (NM_DEVICE (self));
g_return_val_if_fail (parent, FALSE);
@@ -573,9 +574,11 @@ supplicant_interface_init (NMDeviceMacsec *self)
G_CALLBACK (supplicant_iface_state_cb),
self);
- /* Set up a timeout on the connection attempt to fail it after 25 seconds */
- priv->supplicant.con_timeout_id = g_timeout_add_seconds (25, supplicant_connection_timeout_cb, self);
-
+ /* Set up a timeout on the connection attempt */
+ timeout = nm_device_get_supplicant_timeout (NM_DEVICE (self));
+ priv->supplicant.con_timeout_id = g_timeout_add_seconds (timeout,
+ supplicant_connection_timeout_cb,
+ self);
return TRUE;
}
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index e70594d17d..eceb5c383a 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -12946,6 +12946,33 @@ nm_device_spec_match_list (NMDevice *self, const GSList *specs)
return m == NM_MATCH_SPEC_MATCH;
}
+guint
+nm_device_get_supplicant_timeout (NMDevice *self)
+{
+ NMConnection *connection;
+ NMSetting8021x *s_8021x;
+ gs_free char *value = NULL;
+ gint timeout;
+#define SUPPLICANT_DEFAULT_TIMEOUT 25
+
+ g_return_val_if_fail (NM_IS_DEVICE (self), SUPPLICANT_DEFAULT_TIMEOUT);
+
+ connection = nm_device_get_applied_connection (self);
+ g_return_val_if_fail (connection, SUPPLICANT_DEFAULT_TIMEOUT);
+ s_8021x = nm_connection_get_setting_802_1x (connection);
+ g_return_val_if_fail (s_8021x, SUPPLICANT_DEFAULT_TIMEOUT);
+
+ timeout = nm_setting_802_1x_get_auth_timeout (s_8021x);
+ if (timeout > 0)
+ return timeout;
+
+ value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
+ "802-1x.auth-timeout",
+ self);
+ return _nm_utils_ascii_str_to_int64 (value, 10, 1, G_MAXINT32,
+ SUPPLICANT_DEFAULT_TIMEOUT);
+}
+
/*****************************************************************************/
static const char *
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index eb527cc374..4ddb817290 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -640,5 +640,6 @@ gboolean nm_device_update_hw_address (NMDevice *self);
void nm_device_update_initial_hw_address (NMDevice *self);
void nm_device_update_permanent_hw_address (NMDevice *self, gboolean force_freeze);
void nm_device_update_dynamic_ip_setup (NMDevice *self);
+guint nm_device_get_supplicant_timeout (NMDevice *self);
#endif /* __NETWORKMANAGER_DEVICE_H__ */
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 3af6c89f6e..e217a6c7ee 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -2575,6 +2575,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
const char *setting_name;
NMSettingWireless *s_wireless;
GError *error = NULL;
+ guint timeout;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
@@ -2646,8 +2647,11 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
nm_supplicant_interface_assoc (priv->sup_iface, config,
supplicant_iface_assoc_cb, self);
- /* Set up a timeout on the association attempt to fail after 25 seconds */
- priv->sup_timeout_id = g_timeout_add_seconds (25, supplicant_connection_timeout_cb, self);
+ /* Set up a timeout on the association attempt */
+ timeout = nm_device_get_supplicant_timeout (NM_DEVICE (self));
+ priv->sup_timeout_id = g_timeout_add_seconds (timeout,
+ supplicant_connection_timeout_cb,
+ self);
if (!priv->periodic_source_id)
priv->periodic_source_id = g_timeout_add_seconds (6, periodic_update_cb, self);