summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2020-02-14 17:46:31 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2020-02-14 22:31:29 +0100
commit38977d8dcc410d1e33c369d8516f83fe34e945f4 (patch)
tree5c197ac36c5d5ed1c30db1643928d06864a71338
parent2aa0a0576ebc21db12d7c0da8f0afa5f7122eac7 (diff)
downloadNetworkManager-bg/ovs-deactivate-async-pt2.tar.gz
ovs: discard link updates when deactivatingbg/ovs-deactivate-async-pt2
When the ovs interface gets deactivated, it is released from the master port and we call nm_device_update_from_platform_link (dev, NULL) to ignore any later event for the interface. This is important especially because it sets a zero ifindex on the interface and so, later when the link disappears, we don't unmanage the device but directly remove it. However, since ovs commands are queued, the link could appear during the deactivation and we need to ignore such events. Add a new device method can_update_from_platform_link() for such purpose.
-rw-r--r--src/devices/nm-device.c10
-rw-r--r--src/devices/nm-device.h2
-rw-r--r--src/devices/ovs/nm-device-ovs-interface.c13
3 files changed, 25 insertions, 0 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 1622e19cdd..2df0a1adea 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -4293,6 +4293,12 @@ nm_device_create_and_realize (NMDevice *self,
return TRUE;
}
+static gboolean
+can_update_from_platform_link (NMDevice *self, const NMPlatformLink *plink)
+{
+ return TRUE;
+}
+
void
nm_device_update_from_platform_link (NMDevice *self, const NMPlatformLink *plink)
{
@@ -4301,6 +4307,9 @@ nm_device_update_from_platform_link (NMDevice *self, const NMPlatformLink *plink
int ifindex;
guint32 mtu;
+ if (!NM_DEVICE_GET_CLASS (self)->can_update_from_platform_link (self, plink))
+ return;
+
g_return_if_fail (plink == NULL || link_type_compatible (self, plink->type, NULL, NULL));
str = plink ? nm_platform_link_get_udi (nm_device_get_platform (self), plink->ifindex) : NULL;
@@ -17631,6 +17640,7 @@ nm_device_class_init (NMDeviceClass *klass)
klass->get_type_description = get_type_description;
klass->can_auto_connect = can_auto_connect;
+ klass->can_update_from_platform_link = can_update_from_platform_link;
klass->check_connection_compatible = check_connection_compatible;
klass->check_connection_available = check_connection_available;
klass->can_unmanaged_external_down = can_unmanaged_external_down;
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 0a0ea6250e..7222acf37f 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -442,6 +442,8 @@ typedef struct _NMDeviceClass {
gboolean (* get_guessed_metered) (NMDevice *self);
+ gboolean (* can_update_from_platform_link) (NMDevice *self, const NMPlatformLink *plink);
+
/* Controls, whether to call act_stage2_config() callback also for assuming
* a device or for external activations. In this case, act_stage2_config() must
* take care not to touch the device's configuration. */
diff --git a/src/devices/ovs/nm-device-ovs-interface.c b/src/devices/ovs/nm-device-ovs-interface.c
index 763a5d0d8b..2868dee093 100644
--- a/src/devices/ovs/nm-device-ovs-interface.c
+++ b/src/devices/ovs/nm-device-ovs-interface.c
@@ -299,6 +299,18 @@ deactivate_async (NMDevice *device,
data);
}
+static gboolean
+can_update_from_platform_link (NMDevice *device, const NMPlatformLink *plink)
+{
+ /* If the device is deactivating, we already sent the
+ * deletion command to ovsdb and we don't want to deal
+ * with any new link appearing from the previous
+ * activation.
+ */
+ return !plink
+ || nm_device_get_state (device) != NM_DEVICE_STATE_DEACTIVATING;
+}
+
/*****************************************************************************/
static void
@@ -328,6 +340,7 @@ nm_device_ovs_interface_class_init (NMDeviceOvsInterfaceClass *klass)
device_class->connection_type_check_compatible = NM_SETTING_OVS_INTERFACE_SETTING_NAME;
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES (NM_LINK_TYPE_OPENVSWITCH);
+ device_class->can_update_from_platform_link = can_update_from_platform_link;
device_class->deactivate = deactivate;
device_class->deactivate_async = deactivate_async;
device_class->get_type_description = get_type_description;