summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2015-08-25 10:01:50 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2015-08-25 11:48:46 +0200
commit735d15e0f41f9e97aaf4f3e92edf23e6ec750f14 (patch)
treeecb34f5427e979d6545578b6767edda1cc921d52
parent3d9640f24484286e04cc355eb42f961988e6db26 (diff)
downloadNetworkManager-bg/ip-method-fail-fixes-rh1168388.tar.gz
device: don't disconnect after DHCP failure when there are static IPsbg/ip-method-fail-fixes-rh1168388
Don't disconnect the device when the DHCP renewal fails and there are already configured static IP addresses on the device. Instead, keep trying DHCP at regular intervals. https://bugzilla.redhat.com/show_bug.cgi?id=1168388
-rw-r--r--src/devices/nm-device.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index be006f9ecb..136c6c7dc1 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -3651,6 +3651,7 @@ static void
dhcp4_fail (NMDevice *self, gboolean timeout)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ gboolean has_address = FALSE;
_LOGD (LOGD_DEVICE, "dhcp4 failed: timeout %d, restarted %d, num restarts left %u",
timeout, priv->dhcp4_restarted, priv->dhcp4_num_restarts_left);
@@ -3660,14 +3661,20 @@ dhcp4_fail (NMDevice *self, gboolean timeout)
if (!priv->dhcp4_restarted && (timeout || (priv->ip4_state == IP_CONF)))
nm_device_activate_schedule_ip4_config_timeout (self);
else if (priv->ip4_state == IP_DONE) {
- /* Don't fail the IP4 method immediately if the lease expired; try
- to restart DHCP a number of times */
- if (priv->dhcp4_num_restarts_left) {
+ /* Don't fail the IP4 method immediately if the lease expired but try to
+ restart DHCP a number of times. If there are static addresses
+ configured on the device, never fail the connection. */
+ if ( priv->con_ip4_config
+ && nm_ip4_config_get_num_addresses (priv->con_ip4_config) > 0)
+ has_address = TRUE;
+
+ if (has_address || priv->dhcp4_num_restarts_left) {
_LOGI (LOGD_DEVICE, "restarting DHCP4 in %d seconds", DHCP_RESTART_TIMEOUT);
priv->dhcp4_restart_id = g_timeout_add_seconds (DHCP_RESTART_TIMEOUT,
dhcp4_restart_cb, self);
priv->dhcp4_restarted = TRUE;
- priv->dhcp4_num_restarts_left--;
+ if (priv->dhcp4_num_restarts_left)
+ priv->dhcp4_num_restarts_left--;
} else {
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);
@@ -4318,6 +4325,7 @@ static void
dhcp6_fail (NMDevice *self, gboolean timeout)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ gboolean has_address = FALSE;
_LOGD (LOGD_DEVICE, "dhcp6 failed: timeout %d, restarted %d, num restarts left %u",
timeout, priv->dhcp6_restarted, priv->dhcp6_num_restarts_left);
@@ -4328,14 +4336,20 @@ dhcp6_fail (NMDevice *self, gboolean timeout)
if (!priv->dhcp6_restarted && (timeout || (priv->ip6_state == IP_CONF)))
nm_device_activate_schedule_ip6_config_timeout (self);
else if (priv->ip6_state == IP_DONE) {
- /* Don't fail the IP6 method immediately if the lease expired; try
- to restart DHCP a number of times */
- if (priv->dhcp6_num_restarts_left) {
+ /* Don't fail the IP6 method immediately if the lease expired but try to
+ restart DHCP a number of times. If there are static addresses
+ configured on the device, never fail the connection. */
+ if ( priv->con_ip6_config
+ && nm_ip6_config_get_num_addresses (priv->con_ip6_config) > 0)
+ has_address = TRUE;
+
+ if (has_address || priv->dhcp6_num_restarts_left) {
_LOGI (LOGD_DEVICE, "restarting DHCP6 in %d seconds", DHCP_RESTART_TIMEOUT);
priv->dhcp6_restart_id = g_timeout_add_seconds (DHCP_RESTART_TIMEOUT,
dhcp6_restart_cb, self);
priv->dhcp6_restarted = TRUE;
- priv->dhcp6_num_restarts_left--;
+ if (priv->dhcp6_num_restarts_left)
+ priv->dhcp6_num_restarts_left--;
} else {
nm_device_state_changed (self, NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED);