manager: don't unmanage devices without L3 config on shutdown

Use the following logic when quitting, if the device is managed:

  1) if the connection is assumed, leave it up
  2) if the device has no connection (eg, !req) leave it up
  3) if the device only has L2 leave it up

[thaller@redhat.com: original patch reworked by bgalvani@redhat.com and me]

https://bugzilla.redhat.com/show_bug.cgi?id=1311988
https://bugzilla.redhat.com/show_bug.cgi?id=1333983

(cherry picked from commit 25aaaab3b7)
(cherry picked from commit dab2d46aa2)
This commit is contained in:
Dan Williams 2016-04-01 11:04:34 +02:00 committed by Thomas Haller
parent 9a37d1d970
commit 3cba4194f2

View file

@ -839,19 +839,29 @@ remove_device (NMManager *self,
nm_device_get_iface (device), 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);
unmanage = TRUE;
/* Leave activated interfaces up when quitting so their configuration
* can be taken over when NM restarts. This ensures connectivity while
* NM is stopped. Devices which do not support connection assumption
* cannot be left up.
*/
if (!quitting) /* Forced removal; device already gone */
unmanage = TRUE;
else if (!nm_device_can_assume_active_connection (device))
unmanage = TRUE;
else if (!req)
unmanage = TRUE;
if (!quitting) {
/* the device is already gone. Unmanage it. */
} else {
/* Leave certain devices alone when quitting so their configuration
* can be taken over when NM restarts. This ensures connectivity while
* NM is stopped.
*/
if (nm_device_uses_assumed_connection (device)) {
/* An assume connection must be left alone */
unmanage = FALSE;
} else if (!nm_device_get_act_request (device)) {
/* a device without any active connection is either UNAVAILABLE or DISCONNECTED
* state. Since we don't know whether the device was upped by NetworkManager,
* we must leave it up on exit. */
unmanage = FALSE;
} else if (!nm_platform_link_can_assume (NM_PLATFORM_GET, nm_device_get_ifindex (device))) {
/* The device has no layer 3 configuration. Leave it up. */
unmanage = FALSE;
} else if (nm_device_can_assume_active_connection (device))
unmanage = FALSE;
}
if (unmanage) {
if (quitting)