diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c index 5a465d8f94..17986aa825 100644 --- a/src/dhcp/nm-dhcp-client.c +++ b/src/dhcp/nm-dhcp-client.c @@ -147,6 +147,14 @@ nm_dhcp_client_get_priority (NMDhcpClient *self) return NM_DHCP_CLIENT_GET_PRIVATE (self)->priority; } +guint32 +nm_dhcp_client_get_timeout (NMDhcpClient *self) +{ + g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), 0); + + return NM_DHCP_CLIENT_GET_PRIVATE (self)->timeout; +} + GBytes * nm_dhcp_client_get_client_id (NMDhcpClient *self) { diff --git a/src/dhcp/nm-dhcp-client.h b/src/dhcp/nm-dhcp-client.h index 23ea349e88..d790e3e10a 100644 --- a/src/dhcp/nm-dhcp-client.h +++ b/src/dhcp/nm-dhcp-client.h @@ -117,6 +117,8 @@ const GByteArray *nm_dhcp_client_get_hw_addr (NMDhcpClient *self); guint32 nm_dhcp_client_get_priority (NMDhcpClient *self); +guint32 nm_dhcp_client_get_timeout (NMDhcpClient *self); + GBytes *nm_dhcp_client_get_client_id (NMDhcpClient *self); const char *nm_dhcp_client_get_hostname (NMDhcpClient *self); diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c index 64d93744f2..dc66be25dd 100644 --- a/src/dhcp/nm-dhcp-dhclient.c +++ b/src/dhcp/nm-dhcp-dhclient.c @@ -342,6 +342,8 @@ dhclient_start (NMDhcpClient *client, char *binary_name, *cmd_str, *pid_file = NULL, *system_bus_address_env = NULL; gboolean ipv6, success; char *escaped, *preferred_leasefile_path = NULL; + guint32 timeout; + char timeout_str[64]; g_return_val_if_fail (priv->pid_file == NULL, FALSE); @@ -444,6 +446,17 @@ dhclient_start (NMDhcpClient *client, g_ptr_array_add (argv, (gpointer) priv->conf_file); } + /* Specify a timeout longer than configuration's one, + * so that dhclient doesn't send back a FAIL event before + * that time. + */ + timeout = nm_dhcp_client_get_timeout (client); + if (timeout >= 60) { + timeout = timeout < G_MAXINT32 ? timeout + 1 : G_MAXINT32; + g_ptr_array_add (argv, (gpointer) "-timeout"); + g_ptr_array_add (argv, (gpointer) nm_sprintf_buf (timeout_str, "%u", (unsigned) timeout)); + } + /* Usually the system bus address is well-known; but if it's supposed * to be something else, we need to push it to dhclient, since dhclient * sanitizes the environment it gives the action scripts.