manager: don't remove the device before policy learns of ip config change

First let the device know it's being removed soon so that it has a
chance to clean up the IP configuration early.

If the manager removes the device fist, the policy never learns of
config removal and doesn't unhook it from the DNS manager resulting in a
IPConfig leak and possible wrong DNS configuration in effect.

Also adjust the route manager to skip over devices without IP
configuration when determining the best connection; it is perhaps
just due to being removed.

https://bugzilla.gnome.org/show_bug.cgi?id=764483
This commit is contained in:
Lubomir Rintel 2016-04-03 13:51:24 +02:00
parent c06289459f
commit f72816bf10
3 changed files with 12 additions and 8 deletions

View file

@ -2570,6 +2570,7 @@ void
nm_device_removed (NMDevice *self)
{
NMDevicePrivate *priv;
NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE;
g_return_if_fail (NM_IS_DEVICE (self));
@ -2579,6 +2580,13 @@ nm_device_removed (NMDevice *self)
* Release the slave from master, but don't touch the device. */
nm_device_master_release_one_slave (priv->master, self, FALSE, NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED);
}
/* Clean up IP configs; this does not actually deconfigure the
* interface, it just disowns the configuration so that policy
* unregisters it from the dns manager before the device itself
* is gone from manager. */
nm_device_set_ip4_config (self, NULL, 0, TRUE, TRUE, &ignored);
nm_device_set_ip6_config (self, NULL, TRUE, TRUE, &ignored);
}
static gboolean
@ -9971,7 +9979,6 @@ static void
_cleanup_generic_post (NMDevice *self, CleanupType cleanup_type)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMDeviceStateReason ignored = NM_DEVICE_STATE_REASON_NONE;
priv->default_route.v4_has = FALSE;
priv->default_route.v6_has = FALSE;
@ -9993,11 +10000,6 @@ _cleanup_generic_post (NMDevice *self, CleanupType cleanup_type)
priv->linklocal6_dad_counter = 0;
/* Clean up IP configs; this does not actually deconfigure the
* interface; the caller must flush routes and addresses explicitly.
*/
nm_device_set_ip4_config (self, NULL, 0, TRUE, TRUE, &ignored);
nm_device_set_ip6_config (self, NULL, TRUE, TRUE, &ignored);
g_clear_object (&priv->con_ip4_config);
g_clear_object (&priv->dev_ip4_config);
g_clear_object (&priv->ext_ip4_config);

View file

@ -1175,7 +1175,9 @@ _ipx_get_best_config (const VTableIP *vtable,
config_result = nm_device_get_ip4_config (device);
else
config_result = nm_device_get_ip6_config (device);
g_assert (config_result);
if (!config_result)
continue;
req = nm_device_get_act_request (device);
g_assert (req);

View file

@ -872,8 +872,8 @@ remove_device (NMManager *self,
if (nm_device_is_real (device)) {
g_signal_emit (self, signals[DEVICE_REMOVED], 0, device);
_notify (self, PROP_DEVICES);
nm_device_removed (device);
}
nm_device_removed (device);
g_signal_emit (self, signals[INTERNAL_DEVICE_REMOVED], 0, device);
_notify (self, PROP_ALL_DEVICES);