core: allow device subclasses to override DHCP timeout

This commit is contained in:
Daniel Drake
2009-07-15 13:48:28 -04:00
committed by Dan Williams
parent 14bc75edaa
commit 0f56957b77
3 changed files with 20 additions and 7 deletions

View File

@@ -508,8 +508,7 @@ nm_dhcp_manager_handle_timeout (gpointer user_data)
{ {
NMDHCPDevice *device = (NMDHCPDevice *) user_data; NMDHCPDevice *device = (NMDHCPDevice *) user_data;
nm_info ("(%s): DHCP transaction took too long (>%ds), stopping it.", nm_info ("(%s): DHCP transaction took too long, stopping it.", device->iface);
device->iface, NM_DHCP_TIMEOUT);
nm_dhcp_manager_cancel_transaction (device->manager, device->iface); nm_dhcp_manager_cancel_transaction (device->manager, device->iface);
@@ -625,7 +624,11 @@ nm_dhcp_manager_begin_transaction (NMDHCPManager *manager,
setting = s_ip4 ? g_object_ref (s_ip4) : NULL; setting = s_ip4 ? g_object_ref (s_ip4) : NULL;
} }
nm_info ("Activation (%s) Beginning DHCP transaction.", iface); if (timeout == 0)
timeout = NM_DHCP_TIMEOUT;
nm_info ("Activation (%s) Beginning DHCP transaction (timeout in %d seconds)",
iface, timeout);
device->pid = nm_dhcp_client_start (device, uuid, setting); device->pid = nm_dhcp_client_start (device, uuid, setting);
if (setting) if (setting)
@@ -634,9 +637,6 @@ nm_dhcp_manager_begin_transaction (NMDHCPManager *manager,
if (device->pid == 0) if (device->pid == 0)
return FALSE; return FALSE;
if (timeout == 0)
timeout = NM_DHCP_TIMEOUT;
/* Set up a timeout on the transaction to kill it after the timeout */ /* Set up a timeout on the transaction to kill it after the timeout */
device->timeout_id = g_timeout_add_seconds (timeout, device->timeout_id = g_timeout_add_seconds (timeout,
nm_dhcp_manager_handle_timeout, nm_dhcp_manager_handle_timeout,

View File

@@ -89,6 +89,7 @@ typedef struct {
/* IP configuration info */ /* IP configuration info */
NMIP4Config * ip4_config; /* Config from DHCP, PPP, or system config files */ NMIP4Config * ip4_config; /* Config from DHCP, PPP, or system config files */
NMDHCPManager * dhcp_manager; NMDHCPManager * dhcp_manager;
guint32 dhcp_timeout;
gulong dhcp_state_sigid; gulong dhcp_state_sigid;
gulong dhcp_timeout_sigid; gulong dhcp_timeout_sigid;
NMDHCP4Config * dhcp4_config; NMDHCP4Config * dhcp4_config;
@@ -142,6 +143,7 @@ nm_device_init (NMDevice *self)
priv->capabilities = NM_DEVICE_CAP_NONE; priv->capabilities = NM_DEVICE_CAP_NONE;
memset (&priv->ip6_address, 0, sizeof (struct in6_addr)); memset (&priv->ip6_address, 0, sizeof (struct in6_addr));
priv->state = NM_DEVICE_STATE_UNMANAGED; priv->state = NM_DEVICE_STATE_UNMANAGED;
priv->dhcp_timeout = 0;
} }
static GObject* static GObject*
@@ -899,7 +901,7 @@ real_act_stage3_ip_config_start (NMDevice *self, NMDeviceStateReason *reason)
/* DHCP manager will cancel any transaction already in progress and we do not /* DHCP manager will cancel any transaction already in progress and we do not
want to cancel this activation if we get "down" state from that. */ want to cancel this activation if we get "down" state from that. */
g_signal_handler_block (priv->dhcp_manager, priv->dhcp_state_sigid); g_signal_handler_block (priv->dhcp_manager, priv->dhcp_state_sigid);
success = nm_dhcp_manager_begin_transaction (priv->dhcp_manager, ip_iface, uuid, s_ip4, 45); success = nm_dhcp_manager_begin_transaction (priv->dhcp_manager, ip_iface, uuid, s_ip4, priv->dhcp_timeout);
g_signal_handler_unblock (priv->dhcp_manager, priv->dhcp_state_sigid); g_signal_handler_unblock (priv->dhcp_manager, priv->dhcp_state_sigid);
if (success) { if (success) {
@@ -2536,3 +2538,12 @@ nm_device_spec_match_list (NMDeviceInterface *device, const GSList *specs)
return FALSE; return FALSE;
} }
void
nm_device_set_dhcp_timeout (NMDevice *device,
guint32 timeout)
{
g_return_if_fail (NM_IS_DEVICE (device));
NM_DEVICE_GET_PRIVATE (device)->dhcp_timeout = timeout;
}

View File

@@ -162,6 +162,8 @@ void nm_device_set_managed (NMDevice *device,
gboolean managed, gboolean managed,
NMDeviceStateReason reason); NMDeviceStateReason reason);
void nm_device_set_dhcp_timeout (NMDevice *device, guint32 timeout);
G_END_DECLS G_END_DECLS
#endif /* NM_DEVICE_H */ #endif /* NM_DEVICE_H */