summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Giudici <fgiudici@redhat.com>2018-01-15 12:17:54 +0100
committerFrancesco Giudici <fgiudici@redhat.com>2018-01-15 12:17:54 +0100
commitdc079de6cb0c1c1ad8b6c64a0e682bfb3a4fcace (patch)
tree4ec5167490ebb3c4c5f808b409e1b4c67097e579
parent21fdaa0a1b26e0126c4337c09bfa5fe9ac692c41 (diff)
downloadNetworkManager-fg/dhcp_lease.tar.gz
device: never stop trying renewing the leasefg/dhcp_lease
Always reschedule a lease renewal attempt: just clear the scheduled renewal if the connection is really deactivated.
-rw-r--r--src/devices/nm-device.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 909233302e..ad1d804330 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -6263,15 +6263,23 @@ dhcp4_fail (NMDevice *self, gboolean timeout)
&& (timeout || (priv->ip4_state == IP_CONF))
&& !priv->dhcp4.was_active)
nm_device_activate_schedule_ip4_config_timeout (self);
- else if (priv->ip4_state == IP_DONE || priv->dhcp4.was_active) {
+ else if ( priv->dhcp4.num_tries_left < DHCP_NUM_TRIES_MAX
+ || priv->ip4_state == IP_DONE
+ || priv->dhcp4.was_active) {
/* Don't fail immediately when the lease expires but try to
* restart DHCP for a predefined number of times.
*/
if (priv->dhcp4.num_tries_left) {
priv->dhcp4.num_tries_left--;
dhcp_schedule_restart (self, AF_INET, "lease expired");
- } else
+ } else {
nm_device_ip_method_failed (self, AF_INET, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
+ /* We failed but schedule again the retries as the connection may stay up
+ * if the ipv6 method is configured and we want to keep trying renewing
+ * our lost lease in this case.
+ */
+ dhcp_schedule_restart (self, AF_INET, "renewal failed");
+ }
} else
g_warn_if_reached ();
}
@@ -6313,6 +6321,14 @@ dhcp4_state_changed (NMDhcpClient *client,
break;
}
+ /* After long time we have been able to renew the lease:
+ * update the ip state
+ */
+ if ( priv->dhcp4.num_tries_left < DHCP_NUM_TRIES_MAX
+ && priv->ip4_state == IP_FAIL) {
+ _set_ip_state (self, AF_INET, IP_CONF);
+ }
+
g_free (priv->dhcp4.pac_url);
priv->dhcp4.pac_url = g_strdup (g_hash_table_lookup (options, "wpad"));
nm_device_set_proxy_config (self, priv->dhcp4.pac_url);
@@ -7009,15 +7025,23 @@ dhcp6_fail (NMDevice *self, gboolean timeout)
&& (timeout || (priv->ip6_state == IP_CONF))
&& !priv->dhcp6.was_active)
nm_device_activate_schedule_ip6_config_timeout (self);
- else if (priv->ip6_state == IP_DONE || priv->dhcp6.was_active) {
+ else if ( priv->dhcp6.num_tries_left < DHCP_NUM_TRIES_MAX
+ || priv->ip6_state == IP_DONE
+ || priv->dhcp6.was_active) {
/* Don't fail immediately when the lease expires but try to
* restart DHCP for a predefined number of times.
*/
if (priv->dhcp6.num_tries_left) {
priv->dhcp6.num_tries_left--;
dhcp_schedule_restart (self, AF_INET6, "lease expired");
- } else
+ } else {
nm_device_ip_method_failed (self, AF_INET6, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
+ /* We failed but schedule again the retries as the connection may stay up
+ * if the ipv4 method is configured and we want to keep trying renewing
+ * our lost lease in this case.
+ */
+ dhcp_schedule_restart (self, AF_INET6, "renewal failed");
+ }
} else
g_warn_if_reached ();
} else {
@@ -7084,6 +7108,14 @@ dhcp6_state_changed (NMDhcpClient *client,
applied_config_clear (&priv->dhcp6.ip6_config);
}
+ /* After long time we have been able to renew the lease:
+ * update the ip state
+ */
+ if ( priv->dhcp6.num_tries_left < DHCP_NUM_TRIES_MAX
+ && priv->ip6_state == IP_FAIL) {
+ _set_ip_state (self, AF_INET6, IP_CONF);
+ }
+
priv->dhcp6.num_tries_left = DHCP_NUM_TRIES_MAX;
if (priv->ip6_state == IP_CONF) {
@@ -13449,6 +13481,11 @@ _set_state_full (NMDevice *self,
break;
}
+ /* Stop DHCP renewal if any in progress (as too many lease renewal
+ * failures may bring us here) */
+ dhcp4_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE);
+ dhcp6_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE);
+
connection = nm_device_get_settings_connection (self);
_LOGW (LOGD_DEVICE | LOGD_WIFI,
"Activation: failed for connection '%s'",