manager: ensure IP config of device is cleared before removal

If the manager removes the device, the IP config objects must
be cleared. The reason is that NMPolicy registers to the IP config
changed signal and passes these object on to NMDnsManager.

If the INTERNAL_DEVICE_REMOVED signal is emited with IP configuration
object pending, those objects will be leaked.

This partly redoes commit f72816bf10,
which was reverted.

Co-Authored-By: Thomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=764483
This commit is contained in:
Lubomir Rintel 2016-04-04 16:58:33 +02:00 committed by Thomas Haller
parent c5d827057e
commit 9498ea507e
2 changed files with 14 additions and 1 deletions

View file

@ -2585,6 +2585,18 @@ 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 clears the configuration to which policy
* is reacting via NM_DEVICE_IP4_CONFIG_CHANGED/NM_DEVICE_IP6_CONFIG_CHANGED
* signal. As NMPolicy registered the NMIPxConfig instances in NMDnsManager,
* these would be leaked otherwise. */
priv->default_route.v4_has = FALSE;
priv->default_route.v4_is_assumed = TRUE;
nm_device_set_ip4_config (self, NULL, 0, FALSE, FALSE, NULL);
priv->default_route.v6_has = FALSE;
priv->default_route.v6_is_assumed = TRUE;
nm_device_set_ip6_config (self, NULL, FALSE, FALSE, NULL);
}
static gboolean

View file

@ -869,9 +869,10 @@ remove_device (NMManager *self,
priv->devices = g_slist_remove (priv->devices, device);
if (nm_device_is_real (device)) {
nm_device_removed (device);
g_signal_emit (self, signals[DEVICE_REMOVED], 0, device);
_notify (self, PROP_DEVICES);
nm_device_removed (device);
}
g_signal_emit (self, signals[INTERNAL_DEVICE_REMOVED], 0, device);
_notify (self, PROP_ALL_DEVICES);