manager: don't autoconnect a port if it's already activating

This commit is contained in:
Beniamino Galvani 2025-02-12 14:05:55 +01:00
parent 237b878ce1
commit c58993a366

View file

@ -5283,6 +5283,7 @@ ensure_controller_active_connection(NMManager *self,
typedef struct { typedef struct {
NMSettingsConnection *connection; NMSettingsConnection *connection;
NMDevice *device; NMDevice *device;
gboolean ac_found;
} PortConnectionInfo; } PortConnectionInfo;
/** /**
@ -5332,6 +5333,7 @@ find_ports(NMManager *manager,
NMDevice *controller_device = NULL; NMDevice *controller_device = NULL;
NMDevice *port_device; NMDevice *port_device;
NMSettingsConnection *candidate = all_connections[i]; NMSettingsConnection *candidate = all_connections[i];
NMActiveConnection *candidate_ac;
find_controller(manager, find_controller(manager,
nm_settings_connection_get_connection(candidate), nm_settings_connection_get_connection(candidate),
@ -5347,9 +5349,18 @@ find_ports(NMManager *manager,
NULL, NULL,
for_user_request, for_user_request,
devices, devices,
NULL, &candidate_ac,
NULL); NULL);
nm_log_err(
LOGD_CORE,
" find ports: controller conn %s, port conn %s, port dev %s, AC %p, AC state %d",
nm_settings_connection_get_id(sett_conn),
nm_settings_connection_get_id(candidate),
port_device ? nm_device_get_iface(port_device) : NULL,
candidate_ac,
candidate_ac ? nm_active_connection_get_state(candidate_ac) : -1);
if (!ports) { if (!ports) {
/* what we allocate is quite likely much too large. Don't bother, it is only /* what we allocate is quite likely much too large. Don't bother, it is only
* a temporary buffer. */ * a temporary buffer. */
@ -5360,6 +5371,9 @@ find_ports(NMManager *manager,
ports[n_ports++] = (PortConnectionInfo) { ports[n_ports++] = (PortConnectionInfo) {
.connection = candidate, .connection = candidate,
.device = port_device, .device = port_device,
.ac_found = candidate_ac
&& nm_active_connection_get_state(candidate_ac)
<= NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
}; };
if (port_device) if (port_device)
@ -5493,6 +5507,19 @@ autoconnect_ports(NMManager *self,
continue; continue;
} }
if (port->ac_found) {
_LOGW(LOGD_CORE,
"will NOT activate port connection '%s' (%s) as a dependency for "
"controller "
"'%s' (%s): "
"an active connection already exists",
nm_settings_connection_get_id(port->connection),
nm_settings_connection_get_uuid(port->connection),
nm_settings_connection_get_id(controller_connection),
nm_settings_connection_get_uuid(controller_connection));
continue;
}
_LOGD( _LOGD(
LOGD_CORE, LOGD_CORE,
"will activate port connection '%s' (%s) as a dependency for controller '%s' (%s)", "will activate port connection '%s' (%s) as a dependency for controller '%s' (%s)",