From 3cba4194f2b3305bbfe10cbf91f4892a9667be92 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 1 Apr 2016 11:04:34 +0200 Subject: [PATCH] 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 25aaaab3b7ee677f494e8b3b3c310294137626a1) (cherry picked from commit dab2d46aa2f44da6334762fbbf86bee276dd4471) --- src/nm-manager.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index e64c68af90..cb78ec3484 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -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)