libnm/client: fix assertions during device-removed event

The current implementation of libnm guarantees that "o" and "ao"
properties are cleared when the device object goes away, i.e. when all
its interfaces disappear from the bus.

The "manager:device-removed" signal is emitted just before the device
is unexported, and usually properties are not cleared at that
time. So, the assertions about empty available connections and active
connection during "device-removed" seem wrong; remove them.

Whether the test passes or not depends on a race condition in the way
the mock NM service is stopped: we first close the pipe to the process
to force a clean shutdown (where all objects are orderly unexported)
but just after that we send SIGTERM which causes the service to drop
from the bus.

If libnm sees the service dropping from the bus, it deletes all
objects (thus clearing properties) and then emits
"device-removed"; in this case the test passes.

However in case of a clean shutdown, NM first emits the
"device-removed" signal and then unexports devices, leading to a
failure.

Fixes: aaa9a9cd25 ('libnm/client: don't reset properties when interface goes away')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1486
This commit is contained in:
Beniamino Galvani
2022-12-21 16:58:31 +01:00
parent 5fe4be6c06
commit c1d234ce30

View File

@@ -868,15 +868,7 @@ test_activate_virtual(void)
static void static void
_client_dev_removed(NMClient *client, NMDevice *device, int *p_count_call) _client_dev_removed(NMClient *client, NMDevice *device, int *p_count_call)
{ {
const GPtrArray *arr;
(*p_count_call)++; (*p_count_call)++;
arr = nm_device_get_available_connections(device);
g_assert(arr);
g_assert_cmpint(arr->len, ==, 0);
g_assert(!nm_device_get_active_connection(device));
} }
static void static void