mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 22:20:08 +01:00
device: avoid crash setting VPN config during unrealize
During nm_device_unrealize(), we first clear the device's ifindex. Then we call _set_state_full(NM_DEVICE_STATE_UNMANAGED). NMVpnConnection are subclasses of NMActiveConnection, it is that way connected to NM_DEVICE_STATE_CHANGED signal. And this leads to a call to _set_vpn_state(), which then calls nm_device_replace_vpn6_config() to unregister the config. Thereby an assertion fails because the ifindex no longer matches. Fix that by relaxing the assertion. Also, don't apply the IP configuration in unexpected device states. https://bugzilla.redhat.com/show_bug.cgi?id=1912423 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/927
This commit is contained in:
parent
fa786e1f46
commit
63a248ecb2
1 changed files with 11 additions and 5 deletions
|
|
@ -13800,18 +13800,24 @@ void
|
|||
nm_device_replace_vpn6_config(NMDevice *self, NMIP6Config *old, NMIP6Config *config)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
|
||||
NMDeviceState state;
|
||||
|
||||
nm_assert(!old || NM_IS_IP6_CONFIG(old));
|
||||
nm_assert(!old || nm_ip6_config_get_ifindex(old) > 0);
|
||||
nm_assert(!old || nm_device_get_ip_ifindex(self) == 0
|
||||
|| nm_device_get_ip_ifindex(self) == nm_ip6_config_get_ifindex(old));
|
||||
nm_assert(!config || NM_IS_IP6_CONFIG(config));
|
||||
nm_assert(!old || nm_ip6_config_get_ifindex(old) == nm_device_get_ip_ifindex(self));
|
||||
nm_assert(!config || nm_ip6_config_get_ifindex(config) == nm_device_get_ip_ifindex(self));
|
||||
nm_assert(!config || nm_ip6_config_get_ifindex(config) > 0);
|
||||
nm_assert(!config || nm_device_get_ip_ifindex(self) == nm_ip6_config_get_ifindex(config));
|
||||
|
||||
if (!_replace_vpn_config_in_list(&priv->vpn_configs_6, (GObject *) old, (GObject *) config))
|
||||
return;
|
||||
|
||||
/* NULL to use existing configs */
|
||||
if (!ip_config_merge_and_apply(self, AF_INET6, TRUE))
|
||||
_LOGW(LOGD_IP6, "failed to set VPN routes for device");
|
||||
state = nm_device_get_state(self);
|
||||
if (state >= NM_DEVICE_STATE_IP_CONFIG && state <= NM_DEVICE_STATE_ACTIVATED) {
|
||||
if (!ip_config_merge_and_apply(self, AF_INET6, TRUE))
|
||||
_LOGW(LOGD_IP6, "failed to set VPN routes for device");
|
||||
}
|
||||
}
|
||||
|
||||
NMIP6Config *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue