summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-01-11 09:59:25 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2016-01-12 09:56:14 +0100
commitd26a8c2eed6ce180fdc5566969affe888c9cec94 (patch)
tree4feef89237e356f85b903546eaba884a69675154
parent9b94d33232bf8251a13a56ca24920597a542b4bf (diff)
downloadNetworkManager-d26a8c2eed6ce180fdc5566969affe888c9cec94.tar.gz
device: export nm_device_reactivate_ip{4,6}_config functions
nm_device_reactivate_ip6_config() will be used to reconfigure IPv6 addressing when a VLAN interface changes MAC.
-rw-r--r--src/devices/nm-device.c92
-rw-r--r--src/devices/nm-device.h6
2 files changed, 65 insertions, 33 deletions
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);