Blame SOURCES/1013-ovs-slaves-restart-fixes-rh1733709.patch

a31528
From 8775e71d12bf26f4153d12dcb20e8e92ba6f0189 Mon Sep 17 00:00:00 2001
a31528
From: Beniamino Galvani <bgalvani@redhat.com>
a31528
Date: Mon, 29 Jul 2019 16:13:27 +0200
a31528
Subject: [PATCH 1/3] ovs: don't release slaves on quit
a31528
a31528
An OVS bridge and its slaves can continue to work even after NM has
a31528
quit. Keep the interface enslaved when the @configure argument of
a31528
device->release_slave() is FALSE, which happens on quit and in other
a31528
circumstances when we don't really want to release the slave from its
a31528
master.
a31528
a31528
https://bugzilla.redhat.com/show_bug.cgi?id=1733709
a31528
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/215
a31528
(cherry picked from commit ccd4be4014f9f4cfdd0d298ff387ee7558d5f3a5)
a31528
(cherry picked from commit a1f39b69e0b09b7ab02513e34bd41276808ad778)
a31528
---
a31528
 src/devices/ovs/nm-device-ovs-port.c | 19 ++++++++++++-------
a31528
 1 file changed, 12 insertions(+), 7 deletions(-)
a31528
a31528
diff --git a/src/devices/ovs/nm-device-ovs-port.c b/src/devices/ovs/nm-device-ovs-port.c
a31528
index 35eb739f9..8a93a5a9d 100644
a31528
--- a/src/devices/ovs/nm-device-ovs-port.c
a31528
+++ b/src/devices/ovs/nm-device-ovs-port.c
a31528
@@ -140,13 +140,18 @@ del_iface_cb (GError *error, gpointer user_data)
a31528
 static void
a31528
 release_slave (NMDevice *device, NMDevice *slave, gboolean configure)
a31528
 {
a31528
-	nm_ovsdb_del_interface (nm_ovsdb_get (), nm_device_get_iface (slave),
a31528
-	                        del_iface_cb, g_object_ref (slave));
a31528
-
a31528
-	/* Open VSwitch is going to delete this one. We must ignore what happens
a31528
-	 * next with the interface. */
a31528
-	if (NM_IS_DEVICE_OVS_INTERFACE (slave))
a31528
-		nm_device_update_from_platform_link (slave, NULL);
a31528
+	NMDeviceOvsPort *self = NM_DEVICE_OVS_PORT (device);
a31528
+
a31528
+	if (configure) {
a31528
+		_LOGI (LOGD_DEVICE, "releasing ovs interface %s", nm_device_get_ip_iface (slave));
a31528
+		nm_ovsdb_del_interface (nm_ovsdb_get (), nm_device_get_iface (slave),
a31528
+		                        del_iface_cb, g_object_ref (slave));
a31528
+		/* Open VSwitch is going to delete this one. We must ignore what happens
a31528
+		 * next with the interface. */
a31528
+		if (NM_IS_DEVICE_OVS_INTERFACE (slave))
a31528
+			nm_device_update_from_platform_link (slave, NULL);
a31528
+	} else
a31528
+		_LOGI (LOGD_DEVICE, "ovs interface %s was released", nm_device_get_ip_iface (slave));
a31528
 }
a31528
 
a31528
 /*****************************************************************************/
a31528
-- 
a31528
2.21.0
a31528
a31528
From 846a67ab95bc5f3e36099a45b0f2131c6346ef6a Mon Sep 17 00:00:00 2001
a31528
From: Beniamino Galvani <bgalvani@redhat.com>
a31528
Date: Tue, 30 Jul 2019 11:03:59 +0200
a31528
Subject: [PATCH 2/3] device: check platform link compatibility when setting
a31528
 nm-owned flag
a31528
a31528
We set nm-owned to indicate whether a software device was created by
a31528
NM or it was pre-existing. When checking the existence, we must verify
a31528
also whether the link type is compatible with the device, otherwise it
a31528
is possible to match unrelated interfaces. For example, when checking
a31528
for the existence of an ovs-bridge (which is not compatible with any
a31528
platform link) we could match a unrelated platform link with the same
a31528
name.
a31528
a31528
https://bugzilla.redhat.com/show_bug.cgi?id=1733709
a31528
(cherry picked from commit 3cb4b36261684aa3d2676f922c6d53bc31085153)
a31528
(cherry picked from commit cb20d0791a6daf20d64f4cd57d6bd4b60e35a9a0)
a31528
(cherry picked from commit 511ef27d5eaf6fd0577b867d9d31de3bee0440fe)
a31528
---
a31528
 src/devices/nm-device.c | 7 ++++---
a31528
 1 file changed, 4 insertions(+), 3 deletions(-)
a31528
a31528
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
a31528
index 9ad69998b..eaf72a7a0 100644
a31528
--- a/src/devices/nm-device.c
a31528
+++ b/src/devices/nm-device.c
a31528
@@ -4106,13 +4106,14 @@ nm_device_create_and_realize (NMDevice *self,
a31528
 {
a31528
 	nm_auto_nmpobj const NMPObject *plink_keep_alive = NULL;
a31528
 	NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
a31528
-	const NMPlatformLink *plink = NULL;
a31528
+	const NMPlatformLink *plink;
a31528
 
a31528
 	/* Must be set before device is realized */
a31528
-	priv->nm_owned = !nm_platform_link_get_by_ifname (nm_device_get_platform (self), priv->iface);
a31528
-
a31528
+	plink = nm_platform_link_get_by_ifname (nm_device_get_platform (self), priv->iface);
a31528
+	priv->nm_owned = !plink || !link_type_compatible (self, plink->type, NULL, NULL);
a31528
 	_LOGD (LOGD_DEVICE, "create (is %snm-owned)", priv->nm_owned ? "" : "not ");
a31528
 
a31528
+	plink = NULL;
a31528
 	/* Create any resources the device needs */
a31528
 	if (NM_DEVICE_GET_CLASS (self)->create_and_realize) {
a31528
 		if (!NM_DEVICE_GET_CLASS (self)->create_and_realize (self, connection, parent, &plink, error))
a31528
-- 
a31528
2.21.0
a31528
a31528
From 70ada1a2c9e936ec5abe737e1eb80463ff4fba60 Mon Sep 17 00:00:00 2001
a31528
From: Beniamino Galvani <bgalvani@redhat.com>
a31528
Date: Wed, 31 Jul 2019 11:40:35 +0200
a31528
Subject: [PATCH 3/3] device: fix releasing slaves
a31528
a31528
Not all masters type have a platform link and so it's wrong to check
a31528
for it to decide whether the slave should be really released. Move the
a31528
check to master devices that need it (bond, bridge and team).
a31528
a31528
OVS ports don't need the check because they don't call to platform to
a31528
remove a slave.
a31528
a31528
https://bugzilla.redhat.com/show_bug.cgi?id=1733709
a31528
(cherry picked from commit 57e3734b6cc1bb453216c7e2150a698114507a46)
a31528
(cherry picked from commit ec1b5fb019929441fdcdf6bf7c54a2856ad61976)
a31528
(cherry picked from commit f6a90b899ab01d6dc2635faf6bc8d72839a9064c)
a31528
---
a31528
 src/devices/nm-device-bond.c      | 6 ++++++
a31528
 src/devices/nm-device-bridge.c    | 6 ++++++
a31528
 src/devices/nm-device.c           | 7 +------
a31528
 src/devices/team/nm-device-team.c | 6 ++++++
a31528
 4 files changed, 19 insertions(+), 6 deletions(-)
a31528
a31528
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
a31528
index 37159fca8..790f00d44 100644
a31528
--- a/src/devices/nm-device-bond.c
a31528
+++ b/src/devices/nm-device-bond.c
a31528
@@ -413,6 +413,12 @@ release_slave (NMDevice *device,
a31528
 	NMDeviceBond *self = NM_DEVICE_BOND (device);
a31528
 	gboolean success;
a31528
 	gs_free char *address = NULL;
a31528
+	int ifindex;
a31528
+
a31528
+	ifindex = nm_device_get_ifindex (device);
a31528
+	if (   ifindex <= 0
a31528
+	    || !nm_platform_link_get (nm_device_get_platform (device), ifindex))
a31528
+		configure = FALSE;
a31528
 
a31528
 	if (configure) {
a31528
 		/* When the last slave is released the bond MAC will be set to a random
a31528
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
a31528
index 4275af912..e81bcd5d2 100644
a31528
--- a/src/devices/nm-device-bridge.c
a31528
+++ b/src/devices/nm-device-bridge.c
a31528
@@ -625,6 +625,12 @@ release_slave (NMDevice *device,
a31528
 {
a31528
 	NMDeviceBridge *self = NM_DEVICE_BRIDGE (device);
a31528
 	gboolean success;
a31528
+	int ifindex;
a31528
+
a31528
+	ifindex = nm_device_get_ifindex (device);
a31528
+	if (   ifindex <= 0
a31528
+	    || !nm_platform_link_get (nm_device_get_platform (device), ifindex))
a31528
+		configure = FALSE;
a31528
 
a31528
 	if (configure) {
a31528
 		success = nm_platform_link_release (nm_device_get_platform (device),
a31528
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
a31528
index eaf72a7a0..5bb7a592e 100644
a31528
--- a/src/devices/nm-device.c
a31528
+++ b/src/devices/nm-device.c
a31528
@@ -4851,7 +4851,6 @@ nm_device_master_release_slaves (NMDevice *self)
a31528
 {
a31528
 	NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
a31528
 	NMDeviceStateReason reason;
a31528
-	gboolean configure = TRUE;
a31528
 	CList *iter, *safe;
a31528
 
a31528
 	/* Don't release the slaves if this connection doesn't belong to NM. */
a31528
@@ -4862,14 +4861,10 @@ nm_device_master_release_slaves (NMDevice *self)
a31528
 	if (priv->state == NM_DEVICE_STATE_FAILED)
a31528
 		reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED;
a31528
 
a31528
-	if (   priv->ifindex <= 0
a31528
-	    || !nm_platform_link_get (nm_device_get_platform (self), priv->ifindex))
a31528
-		configure = FALSE;
a31528
-
a31528
 	c_list_for_each_safe (iter, safe, &priv->slaves) {
a31528
 		SlaveInfo *info = c_list_entry (iter, SlaveInfo, lst_slave);
a31528
 
a31528
-		nm_device_master_release_one_slave (self, info->slave, configure, reason);
a31528
+		nm_device_master_release_one_slave (self, info->slave, TRUE, reason);
a31528
 	}
a31528
 }
a31528
 
a31528
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
a31528
index 4ae276dbf..7afd18606 100644
a31528
--- a/src/devices/team/nm-device-team.c
a31528
+++ b/src/devices/team/nm-device-team.c
a31528
@@ -774,6 +774,12 @@ release_slave (NMDevice *device,
a31528
 	NMDeviceTeam *self = NM_DEVICE_TEAM (device);
a31528
 	NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (self);
a31528
 	gboolean success;
a31528
+	int ifindex;
a31528
+
a31528
+	ifindex = nm_device_get_ifindex (device);
a31528
+	if (   ifindex <= 0
a31528
+	    || !nm_platform_link_get (nm_device_get_platform (device), ifindex))
a31528
+		configure = FALSE;
a31528
 
a31528
 	if (configure) {
a31528
 		success = nm_platform_link_release (nm_device_get_platform (device),
a31528
-- 
a31528
2.21.0
a31528