summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2018-05-07 16:57:48 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2018-06-01 15:51:17 +0200
commit8006e5700b7a2009de5bfb6ddf951f889b5f67ce (patch)
treec4e512575ced905896661c2305ff70cb276818ae
parentb18c9e44ed2304b867aae833cd2d579e5c75cdf4 (diff)
downloadNetworkManager-bg/rh1573780.tar.gz
dhcp: fix handling of failure eventsbg/rh1573780
DHCPv4 can fail for two reasons: (a) the client failed to contact server and to get an initial lease (b) the client failed to renew the lease after it was successfully acquired For (a) the client generates a TIMEOUT event, for (b) an EXPIRED event. Currently we fail the IP method immediately after (a), but this doesn't work well when the carrier flickers and we restart the client because if the server goes temporarily down, the IP method fails and DHCP is never restarted. Let's change this, and determine whether to fail IP configuration only by looking at the current IP state: when it's IP_CONF then we are getting the initial lease and a failure means that IP configuration must fail; otherwise any other state means that the lease expired or could not be renewed and thus we keep the client running for the grace period. https://bugzilla.redhat.com/show_bug.cgi?id=1573780
-rw-r--r--src/devices/nm-device.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 9a40a0dd5e..fc71ad8f11 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -6830,11 +6830,12 @@ dhcp4_grace_period_expired (gpointer user_data)
}
static void
-dhcp4_fail (NMDevice *self, gboolean timeout)
+dhcp4_fail (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
- _LOGD (LOGD_DHCP4, "DHCPv4 failed%s", timeout ? " (timeout)" : "");
+ _LOGD (LOGD_DHCP4, "DHCPv4 failed (ip_state %s)",
+ _ip_state_to_string (priv->ip4_state));
/* Keep client running if there are static addresses configured
* on the interface.
@@ -6848,7 +6849,7 @@ dhcp4_fail (NMDevice *self, gboolean timeout)
* configuration.
*/
if ( !priv->dhcp4.was_active
- && (timeout || priv->ip4_state == IP_CONF)) {
+ && priv->ip4_state == IP_CONF) {
dhcp4_cleanup (self, CLEANUP_TYPE_DECONFIGURE, FALSE);
nm_device_activate_schedule_ip4_config_timeout (self);
return;
@@ -6911,7 +6912,7 @@ dhcp4_state_changed (NMDhcpClient *client,
case NM_DHCP_STATE_BOUND:
if (!ip4_config) {
_LOGW (LOGD_DHCP4, "failed to get IPv4 config in response to DHCP event.");
- dhcp4_fail (self, FALSE);
+ dhcp4_fail (self);
break;
}
@@ -6950,11 +6951,11 @@ dhcp4_state_changed (NMDhcpClient *client,
if (dhcp4_lease_change (self, ip4_config))
nm_device_update_metered (self);
else
- dhcp4_fail (self, FALSE);
+ dhcp4_fail (self);
}
break;
case NM_DHCP_STATE_TIMEOUT:
- dhcp4_fail (self, TRUE);
+ dhcp4_fail (self);
break;
case NM_DHCP_STATE_EXPIRE:
/* Ignore expiry before we even have a lease (NAK, old lease, etc) */
@@ -6963,7 +6964,7 @@ dhcp4_state_changed (NMDhcpClient *client,
/* fall through */
case NM_DHCP_STATE_DONE:
case NM_DHCP_STATE_FAIL:
- dhcp4_fail (self, FALSE);
+ dhcp4_fail (self);
break;
default:
break;