From b1644fa826bafe95dfe338e56541c59468ba763c Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 7 Jun 2021 16:31:18 +0200 Subject: [PATCH] manager: exit early in get_existing_connection() Later the function will become more complex. Add a check to exit early if the device can't assume connections. --- src/core/devices/nm-device.c | 2 +- src/core/devices/nm-device.h | 1 + src/core/nm-manager.c | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 9b4b0303bc..f8aca987c9 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -7649,7 +7649,7 @@ nm_device_check_slave_connection_compatible(NMDevice *self, NMConnection *slave) * * Returns: %TRUE if the device is capable of assuming connections, %FALSE if not */ -static gboolean +gboolean nm_device_can_assume_connections(NMDevice *self) { return !!NM_DEVICE_GET_CLASS(self)->update_connection; diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index 53211c6f2f..f59b6fa845 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -527,6 +527,7 @@ nm_device_check_connection_compatible(NMDevice *device, NMConnection *connection gboolean nm_device_check_slave_connection_compatible(NMDevice *device, NMConnection *connection); +gboolean nm_device_can_assume_connections(NMDevice *self); gboolean nm_device_unmanage_on_quit(NMDevice *self); gboolean nm_device_spec_match_list(NMDevice *device, const GSList *specs); diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 8fe9cdc8ad..978cf09d0e 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -2595,6 +2595,12 @@ get_existing_connection(NMManager *self, NMDevice *device, gboolean *out_generat nm_device_capture_initial_config(device); + if (!nm_device_can_assume_connections(device)) { + nm_device_assume_state_reset(device); + _LOG2D(LOGD_DEVICE, device, "assume: device cannot assume connection"); + return NULL; + } + if (ifindex) { int master_ifindex = nm_platform_link_get_master(priv->platform, ifindex);