Blame SOURCES/0021-rh1108167-nm-crash-on-device-removal.patch

043740
From 222d392527d3c74d31d08166eb1580b9c4f5204f Mon Sep 17 00:00:00 2001
043740
From: Thomas Haller <thaller@redhat.com>
043740
Date: Wed, 11 Jun 2014 16:47:07 +0200
043740
Subject: [PATCH 1/1] core: fix deactivation of assumed connections on device
043740
 removal (bgo #729833)
043740
043740
The following procedure leaves an NMActiveConnection around for a deactivated
043740
device, which causes errors in libnm-glib clients when they cannot create the
043740
GObject for the non-existent device of the AC.
043740
043740
1) allow a device which can assume connections to be activated
043740
2) stop NM, which should leave the device's IP configuration up
043740
3) start NM and allow it to assume the device's existing connection
043740
4) remove the device, either by unplugging it or 'rmmod'
043740
043740
The device is removed by nm-manager.c::remove_device(), but the device object
043740
is not moved to UNMANAGED state, leaving the NMActiveConnection completely
043740
unaware the device has gone away.
043740
043740
The nm-manager.c::remove_device() code did not correctly handle moving a
043740
forcibly removed (eg, by unplugging or 'ip link del' or 'rmmod') device to
043740
the UNMANAGED state when the device was active with an assumed connection.
043740
To fix this, make the conditions when the device should be deactivated
043740
on removal much more explicit.
043740
043740
A device should be deactivated on removal if:
043740
043740
1) it is forcibly removed, eg by the kernel network interface being
043740
removed due to 'ip link del' or hotplugging, or internally by NM due
043740
to a parent WWAN interface taking priority over a WWAN ethernet interface
043740
043740
2) if the device cannot assume connections, in which case NetworkManager
043740
must have activated the device and since we cannot assume the connection
043740
on restart, we should deactivate it
043740
043740
3) if the device is not activated, to ensure that its IPv6 parameters
043740
and other things get reset to the pre-NetworkManager values
043740
043740
https://bugzilla.gnome.org/show_bug.cgi?id=729833
043740
https://bugzilla.gnome.org/show_bug.cgi?id=731277
043740
https://bugzilla.redhat.com/show_bug.cgi?id=1108167
043740
Related: https://bugzilla.gnome.org/show_bug.cgi?id=729832
043740
043740
(cherry picked from commit 4b6f0d50a456a29e17785fb8b13c11ce018b31db)
043740
043740
Signed-off-by: Thomas Haller <thaller@redhat.com>
043740
---
043740
 src/nm-manager.c | 29 ++++++++++++++++-------------
043740
 1 file changed, 16 insertions(+), 13 deletions(-)
043740
043740
diff --git a/src/nm-manager.c b/src/nm-manager.c
043740
index b7e89d7..d45226b 100644
043740
--- a/src/nm-manager.c
043740
+++ b/src/nm-manager.c
043740
@@ -746,20 +746,23 @@ remove_device (NMManager *manager, NMDevice *device, gboolean quitting)
043740
 	NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
043740
 
043740
 	if (nm_device_get_managed (device)) {
043740
-		/* Leave configured interfaces up when quitting so they can be
043740
-		 * taken over again if NM starts up, and to ensure connectivity while
043740
-		 * NM is gone.  Assumed connections don't get taken down even if they
043740
-		 * haven't been fully activated.
043740
-		 */
043740
-
043740
-		if (   !nm_device_can_assume_connections (device)
043740
-		    || (nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED)
043740
-		    || !quitting) {
043740
-				NMActRequest *req = nm_device_get_act_request (device);
043740
+		NMActRequest *req = nm_device_get_act_request (device);
043740
+		gboolean unmanage = FALSE;
043740
 
043740
-				if (!req || !nm_active_connection_get_assumed (NM_ACTIVE_CONNECTION (req)))
043740
-					nm_device_set_manager_managed (device, FALSE, NM_DEVICE_STATE_REASON_REMOVED);
043740
-			}
043740
+		/* Leave activated interfaces up when quitting so their configuration
043740
+		 * can be taken over when NM restarts.  This ensures connectivity while
043740
+		 * NM is stopped. Devices which do not support connection assumption
043740
+		 * cannot be left up.
043740
+		 */
043740
+		if (!quitting)  /* Forced removal; device already gone */
043740
+			unmanage = TRUE;
043740
+		else if (!nm_device_can_assume_connections (device))
043740
+			unmanage = TRUE;
043740
+		else if (!req)
043740
+			unmanage = TRUE;
043740
+
043740
+		if (unmanage)
043740
+			nm_device_set_manager_managed (device, FALSE, NM_DEVICE_STATE_REASON_REMOVED);
043740
 	}
043740
 
043740
 	g_signal_handlers_disconnect_matched (device, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, manager);
043740
-- 
043740
1.8.3.1
043740