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: 99a6c6eda6 ('ovs, dpdk: fix creating ovs-interface when the ovs-bridge is netdev')
This commit is contained in:
Beniamino Galvani 2023-10-20 17:06:55 +02:00
parent b88de255fc
commit 164a343574

View file

@ -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);