From acee2eb9e4954eb33b85fa10a3522b8253271126 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 23 Sep 2014 15:38:33 -0500 Subject: [PATCH] dhcp: fail the device if DHCP fails after having succeeded earlier (rh #1139326) If DHCP fails to renew or rebind a lease, fail the device since the IP config is no longer valid. Commit e2b7c482 was actually wrong for dhcp[4|6]_fail(), since (ip_state == IP_FAIL) will never be true if DHCP has ever been started, as IP_FAIL is only set from nm_device_activate_ip[4|6]_config_timeout(), which obviously will not be called in DHCP code paths if DHCP has previously succeeded. --- src/devices/nm-device.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 75b07d2f03..21f50b0274 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2686,8 +2686,10 @@ dhcp4_fail (NMDevice *self, gboolean timeout) dhcp4_cleanup (self, TRUE, FALSE); if (timeout || (priv->ip4_state == IP_CONF)) nm_device_activate_schedule_ip4_config_timeout (self); - else if (priv->ip4_state == IP_FAIL) + else if (priv->ip4_state == IP_DONE) nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED); + else + g_warn_if_reached (); } static void @@ -3121,8 +3123,10 @@ dhcp6_fail (NMDevice *self, gboolean timeout) if (priv->dhcp6_mode == NM_RDISC_DHCP_LEVEL_MANAGED) { if (timeout || (priv->ip6_state == IP_CONF)) nm_device_activate_schedule_ip6_config_timeout (self); - else if (priv->ip6_state == IP_FAIL) + else if (priv->ip6_state == IP_DONE) nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED); + else + g_warn_if_reached (); } else { /* not a hard failure; just live with the RA info */ if (priv->ip6_state == IP_CONF)