From d381c50724079e3a774892db70146269697ee1ef Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Wed, 2 Sep 2015 10:14:35 +0200
Subject: [PATCH] device: retry DHCP after timeout/expiration for assumed
connections
If DHCP fails for an assumed connection, NetworkManager would
transition the device to the FAILED and then to the ACTIVATED state
(because it is assumed); hence if the DHCP server goes temporarily
down the device will go into a permanent state without IP
configuration.
Fix this and try DHCP again after some time when the connection
is an assumed one.
https://bugzilla.redhat.com/show_bug.cgi?id=1246496
(cherry picked from commit 2b9db2bf1b9f12586381d90a653bfe7c92f0d7e7)
---
src/devices/nm-device.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index d75bf5e..3a7d991 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -3467,6 +3467,16 @@ dhcp4_fail (NMDevice *self, gboolean timeout)
return;
}
+ /* Instead of letting an assumed connection fail (which means that the
+ * device will transition to the ACTIVATED state without IP configuration),
+ * retry DHCP again.
+ */
+ if (nm_device_uses_assumed_connection (self)) {
+ _LOGI (LOGD_DHCP4, "Scheduling DHCPv4 restart because the connection is assumed");
+ priv->dhcp4_restart_id = g_timeout_add_seconds (120, dhcp4_restart_cb, self);
+ return;
+ }
+
if (timeout || (priv->ip4_state == IP_CONF))
nm_device_activate_schedule_ip4_config_timeout (self);
else if (priv->ip4_state == IP_DONE)
@@ -4141,6 +4151,16 @@ dhcp6_fail (NMDevice *self, gboolean timeout)
return;
}
+ /* Instead of letting an assumed connection fail (which means that the
+ * device will transition to the ACTIVATED state without IP configuration),
+ * retry DHCP again.
+ */
+ if (nm_device_uses_assumed_connection (self)) {
+ _LOGI (LOGD_DHCP6, "Scheduling DHCPv6 restart because the connection is assumed");
+ priv->dhcp6_restart_id = g_timeout_add_seconds (120, dhcp6_restart_cb, self);
+ return;
+ }
+
if (timeout || (priv->ip6_state == IP_CONF))
nm_device_activate_schedule_ip6_config_timeout (self);
else if (priv->ip6_state == IP_DONE)
--
2.4.3