diff options
Diffstat (limited to 'src/dhcp/nm-dhcp-dhclient-utils.c')
-rw-r--r-- | src/dhcp/nm-dhcp-dhclient-utils.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/dhcp/nm-dhcp-dhclient-utils.c b/src/dhcp/nm-dhcp-dhclient-utils.c index 9ae355ece1..309dbc6cee 100644 --- a/src/dhcp/nm-dhcp-dhclient-utils.c +++ b/src/dhcp/nm-dhcp-dhclient-utils.c @@ -33,7 +33,9 @@ #include "platform/nm-platform.h" #include "NetworkManagerUtils.h" -#define CLIENTID_TAG "send dhcp-client-identifier" +#define TIMEOUT_TAG "timeout" +#define RETRY_TAG "retry" +#define CLIENTID_TAG "send dhcp-client-identifier" #define HOSTNAME4_TAG "send host-name" #define HOSTNAME4_FORMAT HOSTNAME4_TAG " \"%s\"; # added by NetworkManager" @@ -261,6 +263,7 @@ nm_dhcp_dhclient_create_config (const char *interface, GBytes *client_id, const char *anycast_addr, const char *hostname, + guint32 timeout, gboolean use_fqdn, const char *orig_path, const char *orig_contents, @@ -309,6 +312,17 @@ nm_dhcp_dhclient_create_config (const char *interface, if (intf[0] && !nm_streq (intf, interface)) continue; + /* Some timing parameters in dhclient should not be imported (timeout, retry). + * The retry parameter will be simply not used as we will exit on first failure. + * The timeout one instead may affect NetworkManager behavior: if the timeout + * elapses before dhcp-timeout dhclient will report failure and cause NM to + * fail the dhcp process before dhcp-timeout. So, always skip importing timeout + * as we will need to add one greater than dhcp-timeout. + */ + if ( !strncmp (p, TIMEOUT_TAG, strlen (TIMEOUT_TAG)) + || !strncmp (p, RETRY_TAG, strlen (RETRY_TAG))) + continue; + if (!strncmp (p, CLIENTID_TAG, strlen (CLIENTID_TAG))) { /* Override config file "dhcp-client-id" and use one from the connection */ if (client_id) @@ -374,6 +388,14 @@ nm_dhcp_dhclient_create_config (const char *interface, } else g_string_append_c (new_contents, '\n'); + /* ensure dhclient timeout is greater than dhcp-timeout: as dhclient timeout default value is + * 60 seconds, we need this only if dhcp-timeout is greater than 60. + */ + if (timeout >= 60) { + timeout = timeout < G_MAXINT32 ? timeout + 1 : G_MAXINT32; + g_string_append_printf (new_contents, "timeout %u;\n", timeout); + } + if (addr_family == AF_INET) { add_ip4_config (new_contents, client_id, hostname, use_fqdn); add_request (reqs, "rfc3442-classless-static-routes"); |