mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-09 03:38:09 +02:00
dhcp: dhclient: fix timeout greater than 60 seconds
The default timeout in dhclient is 60 seconds; if a lease can't be obtained during such interval, dhclient sends to NM a FAIL event and then the IP method fails. Thus, even if user specified a greater dhcp-timeout, NM terminated DHCP after 60 seconds. Fix this by passing an explicit timeout to dhclient.
This commit is contained in:
parent
d67d12ebe1
commit
82ef497cc9
3 changed files with 23 additions and 0 deletions
|
|
@ -147,6 +147,14 @@ nm_dhcp_client_get_priority (NMDhcpClient *self)
|
||||||
return NM_DHCP_CLIENT_GET_PRIVATE (self)->priority;
|
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 *
|
GBytes *
|
||||||
nm_dhcp_client_get_client_id (NMDhcpClient *self)
|
nm_dhcp_client_get_client_id (NMDhcpClient *self)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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_priority (NMDhcpClient *self);
|
||||||
|
|
||||||
|
guint32 nm_dhcp_client_get_timeout (NMDhcpClient *self);
|
||||||
|
|
||||||
GBytes *nm_dhcp_client_get_client_id (NMDhcpClient *self);
|
GBytes *nm_dhcp_client_get_client_id (NMDhcpClient *self);
|
||||||
|
|
||||||
const char *nm_dhcp_client_get_hostname (NMDhcpClient *self);
|
const char *nm_dhcp_client_get_hostname (NMDhcpClient *self);
|
||||||
|
|
|
||||||
|
|
@ -342,6 +342,8 @@ dhclient_start (NMDhcpClient *client,
|
||||||
char *binary_name, *cmd_str, *pid_file = NULL, *system_bus_address_env = NULL;
|
char *binary_name, *cmd_str, *pid_file = NULL, *system_bus_address_env = NULL;
|
||||||
gboolean ipv6, success;
|
gboolean ipv6, success;
|
||||||
char *escaped, *preferred_leasefile_path = NULL;
|
char *escaped, *preferred_leasefile_path = NULL;
|
||||||
|
guint32 timeout;
|
||||||
|
char timeout_str[64];
|
||||||
|
|
||||||
g_return_val_if_fail (priv->pid_file == NULL, FALSE);
|
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);
|
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
|
/* 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
|
* to be something else, we need to push it to dhclient, since dhclient
|
||||||
* sanitizes the environment it gives the action scripts.
|
* sanitizes the environment it gives the action scripts.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue