|
|
b8a464 |
From 126ff818cfdce4c390ad3f553dba7fcc71462d3d Mon Sep 17 00:00:00 2001
|
|
|
b8a464 |
From: Thomas Haller <thaller@redhat.com>
|
|
|
b8a464 |
Date: Tue, 11 Oct 2016 14:42:35 +0200
|
|
|
b8a464 |
Subject: [PATCH 1/1] core: don't unmanage devices on shutdown
|
|
|
b8a464 |
|
|
|
b8a464 |
... except Wi-Fi and devices that cannot assume connections at all.
|
|
|
b8a464 |
|
|
|
b8a464 |
https://bugzilla.redhat.com/show_bug.cgi?id=1371126
|
|
|
b8a464 |
https://bugzilla.redhat.com/show_bug.cgi?id=1378418
|
|
|
b8a464 |
(cherry picked from commit d298b7c96d939b6c5cb7eddd7824e4f0cd695294)
|
|
|
b8a464 |
(cherry picked from commit b14fe3ce0802c708b25982899d787bbbf15eebff)
|
|
|
b8a464 |
---
|
|
|
b8a464 |
src/devices/nm-device.c | 100 ++++++++++--------------------------------------
|
|
|
b8a464 |
1 file changed, 20 insertions(+), 80 deletions(-)
|
|
|
b8a464 |
|
|
|
b8a464 |
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
|
|
|
b8a464 |
index 2e01897..aabbd53 100644
|
|
|
b8a464 |
--- a/src/devices/nm-device.c
|
|
|
b8a464 |
+++ b/src/devices/nm-device.c
|
|
|
b8a464 |
@@ -3492,95 +3492,35 @@ nm_device_can_assume_connections (NMDevice *self)
|
|
|
b8a464 |
return !!NM_DEVICE_GET_CLASS (self)->update_connection;
|
|
|
b8a464 |
}
|
|
|
b8a464 |
|
|
|
b8a464 |
-/**
|
|
|
b8a464 |
- * nm_device_can_assume_active_connection:
|
|
|
b8a464 |
- * @self: #NMDevice instance
|
|
|
b8a464 |
- *
|
|
|
b8a464 |
- * This is a convenience function to determine whether the device's active
|
|
|
b8a464 |
- * connection can be assumed if NetworkManager restarts. This method returns
|
|
|
b8a464 |
- * %TRUE if and only if the device can assume connections, and the device has
|
|
|
b8a464 |
- * an active connection, and that active connection can be assumed.
|
|
|
b8a464 |
- *
|
|
|
b8a464 |
- * Returns: %TRUE if the device's active connection can be assumed, or %FALSE
|
|
|
b8a464 |
- * if there is no active connection or the active connection cannot be
|
|
|
b8a464 |
- * assumed.
|
|
|
b8a464 |
- */
|
|
|
b8a464 |
static gboolean
|
|
|
b8a464 |
-nm_device_can_assume_active_connection (NMDevice *self)
|
|
|
b8a464 |
+unmanaged_on_quit (NMDevice *self)
|
|
|
b8a464 |
{
|
|
|
b8a464 |
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
|
|
b8a464 |
NMConnection *connection;
|
|
|
b8a464 |
- const char *method;
|
|
|
b8a464 |
- const char *assumable_ip6_methods[] = {
|
|
|
b8a464 |
- NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
|
|
|
b8a464 |
- NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
|
|
b8a464 |
- NM_SETTING_IP6_CONFIG_METHOD_DHCP,
|
|
|
b8a464 |
- NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL,
|
|
|
b8a464 |
- NM_SETTING_IP6_CONFIG_METHOD_MANUAL,
|
|
|
b8a464 |
- NULL
|
|
|
b8a464 |
- };
|
|
|
b8a464 |
- const char *assumable_ip4_methods[] = {
|
|
|
b8a464 |
- NM_SETTING_IP4_CONFIG_METHOD_DISABLED,
|
|
|
b8a464 |
- NM_SETTING_IP6_CONFIG_METHOD_AUTO,
|
|
|
b8a464 |
- NM_SETTING_IP6_CONFIG_METHOD_MANUAL,
|
|
|
b8a464 |
- NULL
|
|
|
b8a464 |
- };
|
|
|
b8a464 |
|
|
|
b8a464 |
+ /* NMDeviceWifi overwrites this function to always unmanage wifi devices.
|
|
|
b8a464 |
+ *
|
|
|
b8a464 |
+ * For all other types, if the device type can assume connections, we leave
|
|
|
b8a464 |
+ * it up on quit.
|
|
|
b8a464 |
+ *
|
|
|
b8a464 |
+ * Originally, we would only keep devices up that can be assumed afterwards.
|
|
|
b8a464 |
+ * However, that meant we unmanged layer-2 only devices. So, this was step
|
|
|
b8a464 |
+ * by step refined to unmanage less (commit 25aaaab3, rh#1311988, rh#1333983).
|
|
|
b8a464 |
+ * But there are more scenarios where we also want to keep the device up
|
|
|
b8a464 |
+ * (rh#1378418, rh#1371126). */
|
|
|
b8a464 |
if (!nm_device_can_assume_connections (self))
|
|
|
b8a464 |
- return FALSE;
|
|
|
b8a464 |
+ return TRUE;
|
|
|
b8a464 |
|
|
|
b8a464 |
+ /* the only exception are IPv4 shared connections. We unmanage them on quit. */
|
|
|
b8a464 |
connection = nm_device_get_applied_connection (self);
|
|
|
b8a464 |
- if (!connection)
|
|
|
b8a464 |
- return FALSE;
|
|
|
b8a464 |
-
|
|
|
b8a464 |
- /* Can't assume connections that aren't yet configured
|
|
|
b8a464 |
- * FIXME: what about bridges/bonds waiting for slaves?
|
|
|
b8a464 |
- */
|
|
|
b8a464 |
- if (priv->state < NM_DEVICE_STATE_IP_CONFIG)
|
|
|
b8a464 |
- return FALSE;
|
|
|
b8a464 |
- if (priv->ip4_state != IP_DONE && priv->ip6_state != IP_DONE)
|
|
|
b8a464 |
- return FALSE;
|
|
|
b8a464 |
-
|
|
|
b8a464 |
- method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP6_CONFIG);
|
|
|
b8a464 |
- if (!g_strv_contains (assumable_ip6_methods, method))
|
|
|
b8a464 |
- return FALSE;
|
|
|
b8a464 |
-
|
|
|
b8a464 |
- method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
|
|
b8a464 |
- if (!g_strv_contains (assumable_ip4_methods, method))
|
|
|
b8a464 |
- return FALSE;
|
|
|
b8a464 |
-
|
|
|
b8a464 |
- return TRUE;
|
|
|
b8a464 |
-}
|
|
|
b8a464 |
-
|
|
|
b8a464 |
-static gboolean
|
|
|
b8a464 |
-unmanaged_on_quit (NMDevice *self)
|
|
|
b8a464 |
-{
|
|
|
b8a464 |
- /* Leave certain devices alone when quitting so their configuration
|
|
|
b8a464 |
- * can be taken over when NM restarts. This ensures connectivity while
|
|
|
b8a464 |
- * NM is stopped.
|
|
|
b8a464 |
- */
|
|
|
b8a464 |
- if (nm_device_uses_assumed_connection (self)) {
|
|
|
b8a464 |
- /* An assume connection must be left alone */
|
|
|
b8a464 |
- return FALSE;
|
|
|
b8a464 |
- }
|
|
|
b8a464 |
-
|
|
|
b8a464 |
- if (!nm_device_get_act_request (self)) {
|
|
|
b8a464 |
- /* a device without any active connection is either UNAVAILABLE or DISCONNECTED
|
|
|
b8a464 |
- * state. Since we don't know whether the device was upped by NetworkManager,
|
|
|
b8a464 |
- * we must leave it up on exit.
|
|
|
b8a464 |
- */
|
|
|
b8a464 |
- return FALSE;
|
|
|
b8a464 |
- }
|
|
|
b8a464 |
-
|
|
|
b8a464 |
- if (!nm_platform_link_can_assume (NM_PLATFORM_GET, nm_device_get_ifindex (self))) {
|
|
|
b8a464 |
- /* The device has no layer 3 configuration. Leave it up. */
|
|
|
b8a464 |
- return FALSE;
|
|
|
b8a464 |
+ if (connection) {
|
|
|
b8a464 |
+ if (NM_IN_STRSET (nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG),
|
|
|
b8a464 |
+ NM_SETTING_IP4_CONFIG_METHOD_SHARED)) {
|
|
|
b8a464 |
+ /* shared connections are to be unmangaed. */
|
|
|
b8a464 |
+ return TRUE;
|
|
|
b8a464 |
+ }
|
|
|
b8a464 |
}
|
|
|
b8a464 |
|
|
|
b8a464 |
- if (nm_device_can_assume_active_connection (self))
|
|
|
b8a464 |
- return FALSE;
|
|
|
b8a464 |
-
|
|
|
b8a464 |
- return TRUE;
|
|
|
b8a464 |
+ return FALSE;
|
|
|
b8a464 |
}
|
|
|
b8a464 |
|
|
|
b8a464 |
gboolean
|
|
|
b8a464 |
--
|
|
|
b8a464 |
2.7.4
|
|
|
b8a464 |
|