mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 05:28:07 +02:00
manager: fix wrongly removing DNS configuration on shutdown
When NetworkManager exits, it must preserve the DNS configuration of devices that are left up. Fixes:9498ea507e(cherry picked from commit2158d6a5a8)
This commit is contained in:
parent
0633974952
commit
fa7cacd7df
3 changed files with 20 additions and 4 deletions
|
|
@ -2600,12 +2600,14 @@ nm_device_get_enslaved (NMDevice *self)
|
||||||
/**
|
/**
|
||||||
* nm_device_removed:
|
* nm_device_removed:
|
||||||
* @self: the #NMDevice
|
* @self: the #NMDevice
|
||||||
|
* @unconfigure_ip_config: whether to clear the IP config objects
|
||||||
|
* of the device (provided, it is still not cleared at this point).
|
||||||
*
|
*
|
||||||
* Called by the manager when the device was removed. Releases the device from
|
* Called by the manager when the device was removed. Releases the device from
|
||||||
* the master in case it's enslaved.
|
* the master in case it's enslaved.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
nm_device_removed (NMDevice *self)
|
nm_device_removed (NMDevice *self, gboolean unconfigure_ip_config)
|
||||||
{
|
{
|
||||||
NMDevicePrivate *priv;
|
NMDevicePrivate *priv;
|
||||||
|
|
||||||
|
|
@ -2618,6 +2620,9 @@ nm_device_removed (NMDevice *self)
|
||||||
nm_device_master_release_one_slave (priv->master, self, FALSE, NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED);
|
nm_device_master_release_one_slave (priv->master, self, FALSE, NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!unconfigure_ip_config)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Clean up IP configs; this does not actually deconfigure the
|
/* Clean up IP configs; this does not actually deconfigure the
|
||||||
* interface, it just clears the configuration to which policy
|
* interface, it just clears the configuration to which policy
|
||||||
* is reacting via NM_DEVICE_IP4_CONFIG_CHANGED/NM_DEVICE_IP6_CONFIG_CHANGED
|
* is reacting via NM_DEVICE_IP4_CONFIG_CHANGED/NM_DEVICE_IP6_CONFIG_CHANGED
|
||||||
|
|
|
||||||
|
|
@ -385,7 +385,7 @@ gboolean nm_device_has_unmodified_applied_connection (NMDevice *self,
|
||||||
NMSettingCompareFlags compare_flags);
|
NMSettingCompareFlags compare_flags);
|
||||||
NMSetting * nm_device_get_applied_setting (NMDevice *dev, GType setting_type);
|
NMSetting * nm_device_get_applied_setting (NMDevice *dev, GType setting_type);
|
||||||
|
|
||||||
void nm_device_removed (NMDevice *dev);
|
void nm_device_removed (NMDevice *self, gboolean unconfigure_ip_config);
|
||||||
|
|
||||||
gboolean nm_device_is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags);
|
gboolean nm_device_is_available (NMDevice *dev, NMDeviceCheckDevAvailableFlags flags);
|
||||||
gboolean nm_device_has_carrier (NMDevice *dev);
|
gboolean nm_device_has_carrier (NMDevice *dev);
|
||||||
|
|
|
||||||
|
|
@ -833,13 +833,13 @@ remove_device (NMManager *self,
|
||||||
gboolean allow_unmanage)
|
gboolean allow_unmanage)
|
||||||
{
|
{
|
||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||||
|
gboolean unmanage = FALSE;
|
||||||
|
|
||||||
_LOGD (LOGD_DEVICE, "(%s): removing device (allow_unmanage %d, managed %d)",
|
_LOGD (LOGD_DEVICE, "(%s): removing device (allow_unmanage %d, managed %d)",
|
||||||
nm_device_get_iface (device), allow_unmanage, nm_device_get_managed (device, FALSE));
|
nm_device_get_iface (device), allow_unmanage, nm_device_get_managed (device, FALSE));
|
||||||
|
|
||||||
if (allow_unmanage && nm_device_get_managed (device, FALSE)) {
|
if (allow_unmanage && nm_device_get_managed (device, FALSE)) {
|
||||||
NMActRequest *req = nm_device_get_act_request (device);
|
NMActRequest *req = nm_device_get_act_request (device);
|
||||||
gboolean unmanage = FALSE;
|
|
||||||
|
|
||||||
/* Leave activated interfaces up when quitting so their configuration
|
/* Leave activated interfaces up when quitting so their configuration
|
||||||
* can be taken over when NM restarts. This ensures connectivity while
|
* can be taken over when NM restarts. This ensures connectivity while
|
||||||
|
|
@ -869,7 +869,18 @@ remove_device (NMManager *self,
|
||||||
priv->devices = g_slist_remove (priv->devices, device);
|
priv->devices = g_slist_remove (priv->devices, device);
|
||||||
|
|
||||||
if (nm_device_is_real (device)) {
|
if (nm_device_is_real (device)) {
|
||||||
nm_device_removed (device);
|
gboolean unconfigure_ip_config = !quitting || unmanage;
|
||||||
|
|
||||||
|
/* When we don't unmanage the device on shutdown, we want to preserve the DNS
|
||||||
|
* configuration in resolv.conf. For that, we must leak the configuration
|
||||||
|
* in NMPolicy/NMDnsManager. We do that, by emitting the device-removed signal
|
||||||
|
* with device's ip-config object still uncleared. In that case, NMPolicy
|
||||||
|
* never learns to unconfigure the ip-config objects and does not remove them
|
||||||
|
* from DNS on shutdown (which is ugly, because we don't cleanup the memory
|
||||||
|
* properly).
|
||||||
|
*
|
||||||
|
* Control that by passing @unconfigure_ip_config. */
|
||||||
|
nm_device_removed (device, unconfigure_ip_config);
|
||||||
|
|
||||||
g_signal_emit (self, signals[DEVICE_REMOVED], 0, device);
|
g_signal_emit (self, signals[DEVICE_REMOVED], 0, device);
|
||||||
_notify (self, PROP_DEVICES);
|
_notify (self, PROP_DEVICES);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue