diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2020-04-23 08:48:33 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2020-04-27 08:44:19 +0200 |
commit | 479700519e8cf7c0efa1b1e72e220e2a5b0c6bc5 (patch) | |
tree | 9999b57aa6819446cb8156027f224514dd891dfd | |
parent | fc837cbb6f43c3718752ac4c8884c18b64fdec7c (diff) | |
download | NetworkManager-bg/flush-slaves-ipv6-rh1816517.tar.gz |
device: flush IP configuration of slaves during activationbg/flush-slaves-ipv6-rh1816517
If a device only has an IPv6 link-local address, we don't generate an
assumed connection. Therefore, when a new slave connection (without IP
configuration) is activated on the device, we don't deactivate any
existing connection and the link-local address remains configured.
The IP configuration of an activated slave should be predictable and
not depend on the previous state; let's flush addresses and routes on
activation.
https://bugzilla.redhat.com/show_bug.cgi?id=1816517
-rw-r--r-- | src/devices/nm-device.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 9b97a35c18..462620a5bd 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -10566,6 +10566,8 @@ act_stage3_ip_config_start (NMDevice *self, } else { NMSettingIP6ConfigPrivacy ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; const char *ip6_privacy_str = "0"; + NMPlatform *platform; + int ifindex; if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_DISABLED)) { nm_device_sysctl_ip_conf_set (self, AF_INET6, "disable_ipv6", "1"); @@ -10573,18 +10575,35 @@ act_stage3_ip_config_start (NMDevice *self, } if (nm_streq (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)) { - if ( !priv->master - && !nm_device_sys_iface_state_is_external (self)) { - gboolean ipv6ll_handle_old = priv->ipv6ll_handle; - - /* When activating an IPv6 'ignore' connection we need to revert back - * to kernel IPv6LL, but the kernel won't actually assign an address - * to the interface until disable_ipv6 is bounced. - */ - set_nm_ipv6ll (self, FALSE); - if (ipv6ll_handle_old) - nm_device_sysctl_ip_conf_set (self, AF_INET6, "disable_ipv6", "1"); - restore_ip6_properties (self); + if (!nm_device_sys_iface_state_is_external (self)) { + if (priv->master) { + /* If a device only has an IPv6 link-local address, + * we don't generate an assumed connection. Therefore, + * when a new slave connection (without IP configuration) + * is activated on the device, the link-local address + * remains configured. The IP configuration of an activated + * slave should not depend on the previous state. Flush + * addresses and routes on activation. + */ + ifindex = nm_device_get_ip_ifindex (self); + platform = nm_device_get_platform (self); + + if (ifindex > 0) { + nm_platform_ip_route_flush (platform, AF_INET6, ifindex); + nm_platform_ip_address_flush (platform, AF_INET6, ifindex); + } + } else { + gboolean ipv6ll_handle_old = priv->ipv6ll_handle; + + /* When activating an IPv6 'ignore' connection we need to revert back + * to kernel IPv6LL, but the kernel won't actually assign an address + * to the interface until disable_ipv6 is bounced. + */ + set_nm_ipv6ll (self, FALSE); + if (ipv6ll_handle_old) + nm_device_sysctl_ip_conf_set (self, AF_INET6, "disable_ipv6", "1"); + restore_ip6_properties (self); + } } return NM_ACT_STAGE_RETURN_IP_DONE; } |