Blob Blame History Raw
From 4c9d7e7797274b4eeecad89811afbea424d417c0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
Date: Wed, 21 Oct 2015 14:57:23 +0200
Subject: [PATCH] vlan: fix unmanaged VLAN interface problem (rh #1273879)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit 285ee1fda2052e5b59110a323082c9423bf882e0 added NM_UNMANAGED_PLATFORM_INIT
flag marking platform uninitialized devices. The flags is set by
NM_DEVICE_PLATFORM_DEVICE property and on link changes. However, for virtual
devices, the platform device property was not set at NM device construction time
and link change event happened even before. That resulted in the device having
platform_link_initialized=FALSE and thus it was left unmanaged.

Make the change for other software devices too.

https://bugzilla.redhat.com/show_bug.cgi?id=1273879
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
---
 src/devices/nm-device-bond.c       | 14 ++++++++------
 src/devices/nm-device-bridge.c     |  4 +++-
 src/devices/nm-device-infiniband.c |  4 +++-
 src/devices/nm-device-vlan.c       |  4 +++-
 src/devices/team/nm-device-team.c  |  4 +++-
 5 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 7f13942..afcba3b 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -572,6 +572,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
 {
 	const char *iface = nm_connection_get_interface_name (connection);
 	NMPlatformError plerr;
+	const NMPlatformLink *plink;
 
 	g_assert (iface);
 
@@ -584,14 +585,15 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
 		             nm_platform_error_to_string (plerr));
 		return NULL;
 	}
+	plink = nm_platform_link_get_by_ifname (NM_PLATFORM_GET, iface);
 
 	return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BOND,
-		                              NM_DEVICE_IFACE, iface,
-		                              NM_DEVICE_DRIVER, "bonding",
-		                              NM_DEVICE_TYPE_DESC, "Bond",
-		                              NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BOND,
-		                              NM_DEVICE_IS_MASTER, TRUE,
-		                              NULL);
+	                                  NM_DEVICE_PLATFORM_DEVICE, plink,
+	                                  NM_DEVICE_DRIVER, "bonding",
+	                                  NM_DEVICE_TYPE_DESC, "Bond",
+	                                  NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BOND,
+	                                  NM_DEVICE_IS_MASTER, TRUE,
+	                                  NULL);
 }
 
 NM_DEVICE_FACTORY_DEFINE_INTERNAL (BOND, Bond, bond,
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index e1cafd6..d643553 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -498,6 +498,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
 	const char *mac_address_str;
 	guint8 mac_address[NM_UTILS_HWADDR_LEN_MAX];
 	NMPlatformError plerr;
+	const NMPlatformLink *plink;
 
 	g_assert (iface);
 
@@ -523,9 +524,10 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
 		             nm_platform_error_to_string (plerr));
 		return NULL;
 	}
+	plink = nm_platform_link_get_by_ifname (NM_PLATFORM_GET, iface);
 
 	return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BRIDGE,
-	                                  NM_DEVICE_IFACE, iface,
+	                                  NM_DEVICE_PLATFORM_DEVICE, plink,
 	                                  NM_DEVICE_DRIVER, "bridge",
 	                                  NM_DEVICE_TYPE_DESC, "Bridge",
 	                                  NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BRIDGE,
diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c
index 2d519f6..c1571fd 100644
--- a/src/devices/nm-device-infiniband.c
+++ b/src/devices/nm-device-infiniband.c
@@ -327,6 +327,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
 	int p_key, parent_ifindex;
 	const char *iface;
 	NMPlatformError plerr;
+	const NMPlatformLink *plink;
 
 	if (!NM_IS_DEVICE_INFINIBAND (parent)) {
 		g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
@@ -352,9 +353,10 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
 		             nm_platform_error_to_string (plerr));
 		return NULL;
 	}
+	plink = nm_platform_link_get_by_ifname (NM_PLATFORM_GET, iface);
 
 	return (NMDevice *) g_object_new (NM_TYPE_DEVICE_INFINIBAND,
-	                                  NM_DEVICE_IFACE, iface,
+	                                  NM_DEVICE_PLATFORM_DEVICE, plink,
 	                                  NM_DEVICE_DRIVER, nm_device_get_driver (parent),
 	                                  NM_DEVICE_TYPE_DESC, "InfiniBand",
 	                                  NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_INFINIBAND,
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index adfcef3..b330397 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -698,6 +698,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
 	NMSettingVlan *s_vlan;
 	gs_free char *iface = NULL;
 	NMPlatformError plerr;
+	const NMPlatformLink *plink;
 
 	if (!NM_IS_DEVICE (parent)) {
 		g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED,
@@ -728,9 +729,10 @@ create_virtual_device_for_connection (NMDeviceFactory *factory,
 		             nm_platform_error_to_string (plerr));
 		return NULL;
 	}
+	plink = nm_platform_link_get_by_ifname (NM_PLATFORM_GET, iface);
 
 	device = (NMDevice *) g_object_new (NM_TYPE_DEVICE_VLAN,
-	                                    NM_DEVICE_IFACE, iface,
+	                                    NM_DEVICE_PLATFORM_DEVICE, plink,
 	                                    NM_DEVICE_VLAN_INT_PARENT_DEVICE, parent,
 	                                    NM_DEVICE_DRIVER, "8021q",
 	                                    NM_DEVICE_TYPE_DESC, "VLAN",
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index 09b2dd7..1950fd2 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -710,6 +710,7 @@ nm_device_team_new_for_connection (NMConnection *connection, GError **error)
 {
 	const char *iface = nm_connection_get_interface_name (connection);
 	NMPlatformError plerr;
+	const NMPlatformLink *plink;
 
 	g_assert (iface);
 
@@ -722,9 +723,10 @@ nm_device_team_new_for_connection (NMConnection *connection, GError **error)
 		             nm_platform_error_to_string (plerr));
 		return NULL;
 	}
+	plink = nm_platform_link_get_by_ifname (NM_PLATFORM_GET, iface);
 
 	return (NMDevice *) g_object_new (NM_TYPE_DEVICE_TEAM,
-	                                  NM_DEVICE_IFACE, iface,
+	                                  NM_DEVICE_PLATFORM_DEVICE, plink,
 	                                  NM_DEVICE_DRIVER, "team",
 	                                  NM_DEVICE_TYPE_DESC, "Team",
 	                                  NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_TEAM,
-- 
2.1.0