From f754f9790032d6dcab892808539f57560703aa1b Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 26 Sep 2019 13:41:02 +0200 Subject: [PATCH] device: don't reapply IP config on link up for disconnected devices Only reapply the IP configuration on link up if the IP state is CONF or DONE. Previously we also reapplied it when the device was disconnected (IP state NONE) and this could lead to a situation where an incomplete config was applied; then we intersected the desired configuration with the external - incomplete - one, causing the removal of part of desired configuration (for example the default route). Fixes: d0b16b9283dc ('device: unconditionally reapply IP configuration on link up') https://bugzilla.redhat.com/show_bug.cgi?id=1754511 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/291 (cherry picked from commit 64a9dd38047a05592581e78453bf23582f195b1d) (cherry picked from commit 722cddfad8739557473517d2e3736edcb853710d) --- src/devices/nm-device.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index e0fac76140..43f03739bc 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -3885,12 +3885,18 @@ device_link_changed (NMDevice *self) if (priv->up && (!was_up || seen_down)) { /* the link was down and just came up. That happens for example, while changing MTU. * We must restore IP configuration. */ - if (!ip_config_merge_and_apply (self, AF_INET, TRUE)) - _LOGW (LOGD_IP4, "failed applying IP4 config after link comes up again"); + if (NM_IN_SET (priv->ip_state_4, NM_DEVICE_IP_STATE_CONF, + NM_DEVICE_IP_STATE_DONE)) { + if (!ip_config_merge_and_apply (self, AF_INET, TRUE)) + _LOGW (LOGD_IP4, "failed applying IP4 config after link comes up again"); + } priv->linklocal6_dad_counter = 0; - if (!ip_config_merge_and_apply (self, AF_INET6, TRUE)) - _LOGW (LOGD_IP6, "failed applying IP6 config after link comes up again"); + if (NM_IN_SET (priv->ip_state_6, NM_DEVICE_IP_STATE_CONF, + NM_DEVICE_IP_STATE_DONE)) { + if (!ip_config_merge_and_apply (self, AF_INET6, TRUE)) + _LOGW (LOGD_IP6, "failed applying IP6 config after link comes up again"); + } } if (update_unmanaged_specs)