diff options
author | Thomas Haller <thaller@redhat.com> | 2016-10-11 14:42:35 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-10-26 14:01:01 +0200 |
commit | 28aef7e3b032fb87fa44acdddd6096e389313b7a (patch) | |
tree | a3197d3f82b6c364ba9cba9f75f9254692c4b95f | |
parent | c53496fe4a8a669b7208d4036c3a7c55ced0865c (diff) | |
download | NetworkManager-th/no-unmanage-on-quit-rh1371126.tar.gz |
core: don't unmanage devices on shutdownth/no-unmanage-on-quit-rh1371126
This patch is only on nm-1-4 branch, master will solve this differently.
https://bugzilla.redhat.com/show_bug.cgi?id=1371126
https://bugzilla.redhat.com/show_bug.cgi?id=1378418
-rw-r--r-- | src/devices/nm-device.c | 102 |
1 files changed, 22 insertions, 80 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index a100eb1284..f058b17dc6 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -3492,95 +3492,37 @@ nm_device_can_assume_connections (NMDevice *self) return !!NM_DEVICE_GET_CLASS (self)->update_connection; } -/** - * nm_device_can_assume_active_connection: - * @self: #NMDevice instance - * - * This is a convenience function to determine whether the device's active - * connection can be assumed if NetworkManager restarts. This method returns - * %TRUE if and only if the device can assume connections, and the device has - * an active connection, and that active connection can be assumed. - * - * Returns: %TRUE if the device's active connection can be assumed, or %FALSE - * if there is no active connection or the active connection cannot be - * assumed. - */ static gboolean -nm_device_can_assume_active_connection (NMDevice *self) +unmanaged_on_quit (NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); NMConnection *connection; - const char *method; - const char *assumable_ip6_methods[] = { - NM_SETTING_IP6_CONFIG_METHOD_IGNORE, - NM_SETTING_IP6_CONFIG_METHOD_AUTO, - NM_SETTING_IP6_CONFIG_METHOD_DHCP, - NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL, - NM_SETTING_IP6_CONFIG_METHOD_MANUAL, - NULL - }; - const char *assumable_ip4_methods[] = { - NM_SETTING_IP4_CONFIG_METHOD_DISABLED, - NM_SETTING_IP6_CONFIG_METHOD_AUTO, - NM_SETTING_IP6_CONFIG_METHOD_MANUAL, - NULL - }; + /* By default, return FALSE here. Only NMDeviceWifi overwrites this function + * to always unmanage wifi devices. Also device types that cannot assume + * connections in principle, return TRUE here. */ if (!nm_device_can_assume_connections (self)) - return FALSE; - - connection = nm_device_get_applied_connection (self); - if (!connection) - return FALSE; - - /* Can't assume connections that aren't yet configured - * FIXME: what about bridges/bonds waiting for slaves? - */ - if (priv->state < NM_DEVICE_STATE_IP_CONFIG) - return FALSE; - if (priv->ip4_state != IP_DONE && priv->ip6_state != IP_DONE) - return FALSE; - - method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG); - if (!g_strv_contains (assumable_ip6_methods, method)) - return FALSE; - - method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG); - if (!g_strv_contains (assumable_ip4_methods, method)) - return FALSE; - - return TRUE; -} - -static gboolean -unmanaged_on_quit (NMDevice *self) -{ - /* 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 (self)) { - /* An assume connection must be left alone */ - return FALSE; - } + return TRUE; - if (!nm_device_get_act_request (self)) { - /* 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. - */ - return FALSE; - } + /* Originally, we would only keep devices up that can be assumed afterwards. + * However, that meant we unmanged layer-2 only devices. So, this was step + * by step refined to unmanage less (commit 25aaaab3, rh#1311988, rh#1333983). + * But there are more scenarios where we also want to keep the device up + * (rh#1378418, rh#1371126). + * + * This change diverges from "master" branch, where it was solved diffrently + * (commit 58e01e9c9). Note that when fixing bgo#746440, handling shutdown + * for "master" will be reworked further. */ - if (!nm_platform_link_can_assume (NM_PLATFORM_GET, nm_device_get_ifindex (self))) { - /* The device has no layer 3 configuration. Leave it up. */ - return FALSE; + connection = nm_device_get_applied_connection (self); + if (connection) { + if (NM_IN_STRSET (nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG), + NM_SETTING_IP4_CONFIG_METHOD_SHARED)) { + /* shared connections are to be unmangaed. */ + return TRUE; + } } - if (nm_device_can_assume_active_connection (self)) - return FALSE; - - return TRUE; + return FALSE; } gboolean |