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.
This commit is contained in:
Beniamino Galvani 2021-06-07 16:31:18 +02:00
parent bb37e30867
commit b1644fa826
3 changed files with 8 additions and 1 deletions

View file

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

View file

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

View file

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