From 3ef2da25598bc386e84a8ccc407692eb804cb044 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 20 Oct 2023 17:06:55 +0200 Subject: [PATCH] ovs-interface: make sure handlers are disconnected on deactivate The deactivation can happen while we are waiting for the ifindex, and it can happen via two code paths, depending on the state. For a regular deactivation, method deactivate_async() is called. Otherwise, if the device goes directly to UNMANAGED or UNAVAILABLE, deactivate() is called. We need to make sure that signal and source handlers are disconnected, so that they are not called at the wrong time. Fixes: 99a6c6eda6e1 ('ovs, dpdk: fix creating ovs-interface when the ovs-bridge is netdev') (cherry picked from commit 164a3435745ac05e8f7251233c749fa0390ddfee) --- src/core/devices/ovs/nm-device-ovs-interface.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/devices/ovs/nm-device-ovs-interface.c b/src/core/devices/ovs/nm-device-ovs-interface.c index fd48c2fd0f..c797e86afb 100644 --- a/src/core/devices/ovs/nm-device-ovs-interface.c +++ b/src/core/devices/ovs/nm-device-ovs-interface.c @@ -326,6 +326,7 @@ deactivate(NMDevice *device) NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); priv->wait_link_is_waiting = FALSE; + nm_clear_g_signal_handler(nm_device_get_platform(device), &priv->wait_link_signal_id); nm_clear_g_source_inst(&priv->wait_link_idle_source); } @@ -418,6 +419,9 @@ deactivate_async(NMDevice *device, _LOGT(LOGD_CORE, "deactivate: start async"); + nm_clear_g_signal_handler(nm_device_get_platform(device), &priv->wait_link_signal_id); + nm_clear_g_source_inst(&priv->wait_link_idle_source); + /* We want to ensure that the kernel link for this device is * removed upon disconnection so that it will not interfere with * later activations of the same device. Unfortunately there is @@ -442,8 +446,6 @@ deactivate_async(NMDevice *device, return; } - nm_clear_g_source_inst(&priv->wait_link_idle_source); - if (priv->wait_link_is_waiting) { /* At this point we have issued an INSERT and a DELETE * command for the interface to ovsdb. We don't know if @@ -456,6 +458,7 @@ deactivate_async(NMDevice *device, } else _LOGT(LOGD_DEVICE, "deactivate: waiting for link to disappear"); + priv->wait_link_is_waiting = FALSE; data->cancelled_id = g_cancellable_connect(cancellable, G_CALLBACK(deactivate_cancelled_cb), data, NULL); data->link_changed_id = g_signal_connect(nm_device_get_platform(device), @@ -506,6 +509,10 @@ dispose(GObject *object) NMDeviceOvsInterface *self = NM_DEVICE_OVS_INTERFACE(object); NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); + nm_assert(!priv->wait_link_is_waiting); + nm_assert(!priv->wait_link_signal_id == 0); + nm_assert(!priv->wait_link_idle_source); + if (priv->ovsdb) { g_signal_handlers_disconnect_by_func(priv->ovsdb, G_CALLBACK(ovsdb_ready), self); g_clear_object(&priv->ovsdb);