diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 48604135ba..f8710412b7 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -89,6 +89,7 @@ parent_hwaddr_changed (NMDevice *parent, NMConnection *connection; NMSettingWired *s_wired; const char *cloned_mac = NULL, *new_mac; + NMSettingIPConfig *s_ip6; /* Never touch assumed devices */ if (nm_device_uses_assumed_connection (self)) @@ -110,6 +111,11 @@ parent_hwaddr_changed (NMDevice *parent, if (new_mac) { nm_device_set_hw_addr (self, nm_device_get_hw_address (parent), "set", LOGD_VLAN); + /* When changing the hw address the interface is taken down, + * removing the IPv6 configuration; reapply it. + */ + s_ip6 = nm_connection_get_setting_ip6_config (connection); + nm_device_reactivate_ip6_config (NM_DEVICE (self), s_ip6, s_ip6); } } } diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 05cdb51970..da5f401e7b 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -6924,6 +6924,63 @@ _hash_check_invalid_keys (GHashTable *hash, const char *setting_name, GError **e return TRUE; } +void +nm_device_reactivate_ip4_config (NMDevice *self, + NMSettingIPConfig *s_ip4_old, + NMSettingIPConfig *s_ip4_new) +{ + NMDevicePrivate *priv; + + g_return_if_fail (NM_IS_DEVICE (self)); + priv = NM_DEVICE_GET_PRIVATE (self); + + if (priv->ip4_state != IP_NONE) { + g_clear_object (&priv->con_ip4_config); + priv->con_ip4_config = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); + nm_ip4_config_merge_setting (priv->con_ip4_config, + s_ip4_new, + nm_device_get_ip4_route_metric (self)); + + if (strcmp (nm_setting_ip_config_get_method (s_ip4_new), + nm_setting_ip_config_get_method (s_ip4_old))) { + _cleanup_ip4_pre (self, CLEANUP_TYPE_DECONFIGURE); + priv->ip4_state = IP_WAIT; + if (!nm_device_activate_stage3_ip4_start (self)) + _LOGW (LOGD_IP4, "Failed to apply IPv4 configuration"); + } else + ip4_config_merge_and_apply (self, NULL, TRUE, NULL); + } +} + +void +nm_device_reactivate_ip6_config (NMDevice *self, + NMSettingIPConfig *s_ip6_old, + NMSettingIPConfig *s_ip6_new) +{ + NMDevicePrivate *priv; + + g_return_if_fail (NM_IS_DEVICE (self)); + priv = NM_DEVICE_GET_PRIVATE (self); + + if (priv->ip6_state != IP_NONE) { + g_clear_object (&priv->con_ip6_config); + priv->con_ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); + nm_ip6_config_merge_setting (priv->con_ip6_config, + s_ip6_new, + nm_device_get_ip6_route_metric (self)); + + if (strcmp (nm_setting_ip_config_get_method (s_ip6_new), + nm_setting_ip_config_get_method (s_ip6_old))) { + _cleanup_ip6_pre (self, CLEANUP_TYPE_DECONFIGURE); + priv->ip6_state = IP_WAIT; + if (!nm_device_activate_stage3_ip6_start (self)) + _LOGW (LOGD_IP6, "Failed to apply IPv6 configuration"); + } else + ip6_config_merge_and_apply (self, TRUE, NULL); + } +} + + /* reapply_connection: * @connection: the new connection settings to be applied or %NULL to reapply * the current settings connection @@ -7004,39 +7061,8 @@ reapply_connection (NMDevice *self, nm_device_update_firewall_zone (self); nm_device_update_metered (self); - if (priv->ip4_state != IP_NONE) { - g_clear_object (&priv->con_ip4_config); - priv->con_ip4_config = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); - nm_ip4_config_merge_setting (priv->con_ip4_config, - s_ip4_new, - nm_device_get_ip4_route_metric (self)); - - if (strcmp (nm_setting_ip_config_get_method (s_ip4_new), - nm_setting_ip_config_get_method (s_ip4_old))) { - _cleanup_ip4_pre (self, CLEANUP_TYPE_DECONFIGURE); - priv->ip4_state = IP_WAIT; - if (!nm_device_activate_stage3_ip4_start (self)) - _LOGW (LOGD_IP4, "Failed to apply IPv4 configuration"); - } else - ip4_config_merge_and_apply (self, NULL, TRUE, NULL); - } - - if (priv->ip6_state != IP_NONE) { - g_clear_object (&priv->con_ip6_config); - priv->con_ip6_config = nm_ip6_config_new (nm_device_get_ip_ifindex (self)); - nm_ip6_config_merge_setting (priv->con_ip6_config, - s_ip6_new, - nm_device_get_ip6_route_metric (self)); - - if (strcmp (nm_setting_ip_config_get_method (s_ip6_new), - nm_setting_ip_config_get_method (s_ip6_old))) { - _cleanup_ip6_pre (self, CLEANUP_TYPE_DECONFIGURE); - priv->ip6_state = IP_WAIT; - if (!nm_device_activate_stage3_ip6_start (self)) - _LOGW (LOGD_IP6, "Failed to apply IPv6 configuration"); - } else - ip6_config_merge_and_apply (self, TRUE, NULL); - } + nm_device_reactivate_ip4_config (self, s_ip4_old, s_ip4_new); + nm_device_reactivate_ip6_config (self, s_ip6_old, s_ip6_new); return TRUE; } diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 4e35aad6f4..e173b2db9f 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -529,6 +529,12 @@ void nm_device_reapply_settings_immediately (NMDevice *self); void nm_device_update_firewall_zone (NMDevice *self); void nm_device_update_metered (NMDevice *self); +void nm_device_reactivate_ip4_config (NMDevice *device, + NMSettingIPConfig *s_ip4_old, + NMSettingIPConfig *s_ip4_new); +void nm_device_reactivate_ip6_config (NMDevice *device, + NMSettingIPConfig *s_ip6_old, + NMSettingIPConfig *s_ip6_new); void nm_device_update_hw_address (NMDevice *self); void nm_device_update_initial_hw_address (NMDevice *self);