summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-03-17 16:28:07 +0100
committerThomas Haller <thaller@redhat.com>2018-03-20 21:03:20 +0100
commit1010cc777fc94404ab2b387e85756360fa6b883e (patch)
tree8b3b63e353d0d4891e9fad7a80814906fb1114ca
parentb95f9741440027254a50d321657301d397f7f847 (diff)
downloadNetworkManager-th/ipv6-ll-reapply-rh1552069.tar.gz
device: merge IPv4 and IPv6 versions of _cleanup_ip_pre()th/ipv6-ll-reapply-rh1552069
-rw-r--r--src/devices/nm-device.c58
1 files changed, 26 insertions, 32 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 96a110cfd6..fc7c76b94d 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -9351,37 +9351,31 @@ delete_on_deactivate_check_and_schedule (NMDevice *self, int ifindex)
}
static void
-_cleanup_ip4_pre (NMDevice *self, CleanupType cleanup_type)
-{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
-
- _set_ip_state (self, AF_INET, IP_NONE);
-
- if (nm_clear_g_source (&priv->queued_ip_config_id_4))
- _LOGD (LOGD_DEVICE, "clearing queued IP4 config change");
- priv->queued_ip4_config_pending = FALSE;
-
- dhcp4_cleanup (self, cleanup_type, FALSE);
- arp_cleanup (self);
- dnsmasq_cleanup (self);
- ipv4ll_cleanup (self);
-}
-
-static void
-_cleanup_ip6_pre (NMDevice *self, CleanupType cleanup_type)
+_cleanup_ip_pre (NMDevice *self, int addr_family, CleanupType cleanup_type)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+ const gboolean IS_IPv4 = (addr_family == AF_INET);
- _set_ip_state (self, AF_INET6, IP_NONE);
+ _set_ip_state (self, addr_family, IP_NONE);
- if (nm_clear_g_source (&priv->queued_ip_config_id_6))
- _LOGD (LOGD_DEVICE, "clearing queued IP6 config change");
- priv->queued_ip6_config_pending = FALSE;
+ if (nm_clear_g_source (&priv->queued_ip_config_id_x[IS_IPv4])) {
+ _LOGD (LOGD_DEVICE, "clearing queued IP%c config change",
+ nm_utils_addr_family_to_char (addr_family));
+ }
- g_clear_object (&priv->dad6_ip6_config);
- dhcp6_cleanup (self, cleanup_type, FALSE);
- nm_clear_g_source (&priv->linklocal6_timeout_id);
- addrconf6_cleanup (self);
+ if (IS_IPv4) {
+ priv->queued_ip4_config_pending = FALSE;
+ dhcp4_cleanup (self, cleanup_type, FALSE);
+ arp_cleanup (self);
+ dnsmasq_cleanup (self);
+ ipv4ll_cleanup (self);
+ } else {
+ priv->queued_ip6_config_pending = FALSE;
+ g_clear_object (&priv->dad6_ip6_config);
+ dhcp6_cleanup (self, cleanup_type, FALSE);
+ nm_clear_g_source (&priv->linklocal6_timeout_id);
+ addrconf6_cleanup (self);
+ }
}
gboolean
@@ -9479,7 +9473,7 @@ nm_device_reactivate_ip4_config (NMDevice *self,
: NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
if (!nm_streq0 (method_old, method_new)) {
- _cleanup_ip4_pre (self, CLEANUP_TYPE_DECONFIGURE);
+ _cleanup_ip_pre (self, AF_INET, CLEANUP_TYPE_DECONFIGURE);
_set_ip_state (self, AF_INET, IP_WAIT);
if (!nm_device_activate_stage3_ip4_start (self))
_LOGW (LOGD_IP4, "Failed to apply IPv4 configuration");
@@ -9521,7 +9515,7 @@ nm_device_reactivate_ip6_config (NMDevice *self,
: NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
if (!nm_streq0 (method_old, method_new)) {
- _cleanup_ip6_pre (self, CLEANUP_TYPE_DECONFIGURE);
+ _cleanup_ip_pre (self, AF_INET6, CLEANUP_TYPE_DECONFIGURE);
_set_ip_state (self, AF_INET6, IP_WAIT);
if (!nm_device_activate_stage3_ip6_start (self))
_LOGW (LOGD_IP6, "Failed to apply IPv6 configuration");
@@ -12634,8 +12628,8 @@ _cleanup_generic_pre (NMDevice *self, CleanupType cleanup_type)
queued_state_clear (self);
- _cleanup_ip4_pre (self, cleanup_type);
- _cleanup_ip6_pre (self, cleanup_type);
+ _cleanup_ip_pre (self, AF_INET, cleanup_type);
+ _cleanup_ip_pre (self, AF_INET6, cleanup_type);
}
static void
@@ -13249,8 +13243,8 @@ _set_state_full (NMDevice *self,
/* Clean up any half-done IP operations if the device's layer2
* finds out it needs authentication during IP config.
*/
- _cleanup_ip4_pre (self, CLEANUP_TYPE_DECONFIGURE);
- _cleanup_ip6_pre (self, CLEANUP_TYPE_DECONFIGURE);
+ _cleanup_ip_pre (self, AF_INET, CLEANUP_TYPE_DECONFIGURE);
+ _cleanup_ip_pre (self, AF_INET6, CLEANUP_TYPE_DECONFIGURE);
}
break;
default: