dns: don't update routing and DNS if no devices were ever managed
Avoids blowing away existing routes and resolv.conf if NM never managed any devices.
This commit is contained in:

committed by
Dan Williams

parent
184d01c27f
commit
0051b44a09
@@ -1097,6 +1097,10 @@ dispose (GObject *object)
|
|||||||
g_slist_free (priv->plugins);
|
g_slist_free (priv->plugins);
|
||||||
priv->plugins = NULL;
|
priv->plugins = NULL;
|
||||||
|
|
||||||
|
/* If last_iface is NULL, this means we haven't done a DNS update before,
|
||||||
|
* so no reason to try and take down entries from resolv.conf.
|
||||||
|
*/
|
||||||
|
if (priv->last_iface != NULL) {
|
||||||
/* If we're quitting leave a valid resolv.conf in place, not one
|
/* If we're quitting leave a valid resolv.conf in place, not one
|
||||||
* pointing to 127.0.0.1 if any plugins were active. Thus update
|
* pointing to 127.0.0.1 if any plugins were active. Thus update
|
||||||
* DNS after disposing of all plugins.
|
* DNS after disposing of all plugins.
|
||||||
@@ -1107,6 +1111,7 @@ dispose (GObject *object)
|
|||||||
error && error->message ? error->message : "(unknown)");
|
error && error->message ? error->message : "(unknown)");
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_slist_foreach (priv->configs, (GFunc) g_object_unref, NULL);
|
g_slist_foreach (priv->configs, (GFunc) g_object_unref, NULL);
|
||||||
g_slist_free (priv->configs);
|
g_slist_free (priv->configs);
|
||||||
|
@@ -1023,6 +1023,15 @@ device_state_changed (NMDevice *device,
|
|||||||
update_routing_and_dns (policy, FALSE);
|
update_routing_and_dns (policy, FALSE);
|
||||||
break;
|
break;
|
||||||
case NM_DEVICE_STATE_UNMANAGED:
|
case NM_DEVICE_STATE_UNMANAGED:
|
||||||
|
if ( old_state == NM_DEVICE_STATE_UNAVAILABLE
|
||||||
|
|| old_state == NM_DEVICE_STATE_DISCONNECTED) {
|
||||||
|
/* If the device was never activated, there's no point in
|
||||||
|
* updating routing or DNS. This allows us to keep the previous
|
||||||
|
* resolv.conf or routes from before NM started if no device was
|
||||||
|
* ever managed by NM.
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
}
|
||||||
case NM_DEVICE_STATE_UNAVAILABLE:
|
case NM_DEVICE_STATE_UNAVAILABLE:
|
||||||
update_routing_and_dns (policy, FALSE);
|
update_routing_and_dns (policy, FALSE);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user