summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2019-08-14 10:55:44 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2019-09-16 12:56:25 +0200
commita3ebdd548c29084468dca8c28fbde0cad88735d9 (patch)
tree69d737417b9e5ed609b9520ffc29ec5a7463a08a
parent87c6d186e8cb5eafe65c12d38f2b387c4a725bcd (diff)
downloadNetworkManager-a3ebdd548c29084468dca8c28fbde0cad88735d9.tar.gz
device: keep client running after activation failurebg/dhcp-keep
If DHCPv4 fails but IPv6 succeeds it makes sense to continue trying DHCP so that we will eventually be able to get an address if the DHCP server comes back. Always keep the client running; it will be only terminated when the connection is brought down. https://bugzilla.redhat.com/show_bug.cgi?id=1688329
-rw-r--r--src/devices/nm-device.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 81e8d934f9..02963b52c2 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -7736,7 +7736,13 @@ dhcp4_fail (NMDevice *self, NMDhcpState dhcp_state)
_ip_state_to_string (priv->ip_state_4),
priv->dhcp4.was_active);
- /* Keep client running if there are static addresses configured
+ /* The client is always left running after a failure. */
+
+ /* Nothing to do if we failed before... */
+ if (priv->ip_state_4 == NM_DEVICE_IP_STATE_FAIL)
+ goto clear_config;
+
+ /* ... and also if there are static addresses configured
* on the interface.
*/
if ( priv->ip_state_4 == NM_DEVICE_IP_STATE_DONE
@@ -7752,14 +7758,12 @@ dhcp4_fail (NMDevice *self, NMDhcpState dhcp_state)
*/
if ( dhcp_state == NM_DHCP_STATE_TERMINATED
|| (!priv->dhcp4.was_active && priv->ip_state_4 == NM_DEVICE_IP_STATE_CONF)) {
- dhcp4_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE);
nm_device_activate_schedule_ip_config_timeout (self, AF_INET);
return;
}
/* In any other case (expired lease, assumed connection, etc.),
- * start a grace period in which we keep the client running,
- * hoping that it will regain a lease.
+ * wait for some time before failing the IP method.
*/
if (!priv->dhcp4.grace_id) {
priv->dhcp4.grace_id = g_timeout_add_seconds (DHCP_GRACE_PERIOD_SEC,
@@ -8381,10 +8385,16 @@ dhcp6_fail (NMDevice *self, NMDhcpState dhcp_state)
_ip_state_to_string (priv->ip_state_6),
priv->dhcp6.was_active);
+ /* The client is always left running after a failure. */
+
+ /* Nothing to do if we failed before... */
+ if (priv->ip_state_6 == NM_DEVICE_IP_STATE_FAIL)
+ goto clear_config;
+
is_dhcp_managed = (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_MANAGED);
if (is_dhcp_managed) {
- /* Keep client running if there are static addresses configured
+ /* ... and also if there are static addresses configured
* on the interface.
*/
if ( priv->ip_state_6 == NM_DEVICE_IP_STATE_DONE
@@ -8400,14 +8410,12 @@ dhcp6_fail (NMDevice *self, NMDhcpState dhcp_state)
*/
if ( dhcp_state == NM_DHCP_STATE_TERMINATED
|| (!priv->dhcp6.was_active && priv->ip_state_6 == NM_DEVICE_IP_STATE_CONF)) {
- dhcp6_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE);
nm_device_activate_schedule_ip_config_timeout (self, AF_INET6);
return;
}
/* In any other case (expired lease, assumed connection, etc.),
- * start a grace period in which we keep the client running,
- * hoping that it will regain a lease.
+ * wait for some time before failing the IP method.
*/
if (!priv->dhcp6.grace_id) {
priv->dhcp6.grace_id = g_timeout_add_seconds (DHCP_GRACE_PERIOD_SEC,