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.
This commit is contained in:
Beniamino Galvani
2017-01-19 17:25:29 +01:00
parent 556a46959f
commit 07570e245a
5 changed files with 46 additions and 7 deletions

View File

@@ -751,6 +751,7 @@ static gboolean
supplicant_interface_init (NMDeviceEthernet *self) supplicant_interface_init (NMDeviceEthernet *self)
{ {
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
guint timeout;
supplicant_interface_release (self); supplicant_interface_release (self);
@@ -770,8 +771,11 @@ supplicant_interface_init (NMDeviceEthernet *self)
G_CALLBACK (supplicant_iface_state_cb), G_CALLBACK (supplicant_iface_state_cb),
self); self);
/* Set up a timeout on the connection attempt to fail it after 25 seconds */ /* Set up a timeout on the connection attempt */
priv->supplicant.con_timeout_id = g_timeout_add_seconds (25, supplicant_connection_timeout_cb, self); 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; return TRUE;
} }

View File

@@ -551,6 +551,7 @@ supplicant_interface_init (NMDeviceMacsec *self)
{ {
NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self); NMDeviceMacsecPrivate *priv = NM_DEVICE_MACSEC_GET_PRIVATE (self);
NMDevice *parent; NMDevice *parent;
guint timeout;
parent = nm_device_parent_get_device (NM_DEVICE (self)); parent = nm_device_parent_get_device (NM_DEVICE (self));
g_return_val_if_fail (parent, FALSE); g_return_val_if_fail (parent, FALSE);
@@ -573,9 +574,11 @@ supplicant_interface_init (NMDeviceMacsec *self)
G_CALLBACK (supplicant_iface_state_cb), G_CALLBACK (supplicant_iface_state_cb),
self); self);
/* Set up a timeout on the connection attempt to fail it after 25 seconds */ /* Set up a timeout on the connection attempt */
priv->supplicant.con_timeout_id = g_timeout_add_seconds (25, supplicant_connection_timeout_cb, self); 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; return TRUE;
} }

View File

@@ -12946,6 +12946,33 @@ nm_device_spec_match_list (NMDevice *self, const GSList *specs)
return m == NM_MATCH_SPEC_MATCH; 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 * static const char *

View File

@@ -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_initial_hw_address (NMDevice *self);
void nm_device_update_permanent_hw_address (NMDevice *self, gboolean force_freeze); void nm_device_update_permanent_hw_address (NMDevice *self, gboolean force_freeze);
void nm_device_update_dynamic_ip_setup (NMDevice *self); void nm_device_update_dynamic_ip_setup (NMDevice *self);
guint nm_device_get_supplicant_timeout (NMDevice *self);
#endif /* __NETWORKMANAGER_DEVICE_H__ */ #endif /* __NETWORKMANAGER_DEVICE_H__ */

View File

@@ -2575,6 +2575,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
const char *setting_name; const char *setting_name;
NMSettingWireless *s_wireless; NMSettingWireless *s_wireless;
GError *error = NULL; GError *error = NULL;
guint timeout;
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE); 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, nm_supplicant_interface_assoc (priv->sup_iface, config,
supplicant_iface_assoc_cb, self); supplicant_iface_assoc_cb, self);
/* Set up a timeout on the association attempt to fail after 25 seconds */ /* Set up a timeout on the association attempt */
priv->sup_timeout_id = g_timeout_add_seconds (25, supplicant_connection_timeout_cb, self); 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) if (!priv->periodic_source_id)
priv->periodic_source_id = g_timeout_add_seconds (6, periodic_update_cb, self); priv->periodic_source_id = g_timeout_add_seconds (6, periodic_update_cb, self);