Commit a2acfdd4 authored by Dan Williams's avatar Dan Williams

core: simplify device activation precheck

The FIXME is correct; comparing the whole connection is just dumb now
since all connections are owned by NM, so we can simply compare pointers
to figure out of the incoming activation request is using the same
connection as the current activation request.  Plus, this comparison
would fail entirely if the connection has transient/always-ask secrets.
parent f1329b48
......@@ -2890,34 +2890,6 @@ check_connection_compatible (NMDeviceInterface *dev_iface,
return TRUE;
}
static gboolean
device_activation_precheck (NMDevice *self, NMConnection *connection, GError **error)
{
NMConnection *current_connection;
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
if (nm_device_get_state (self) != NM_DEVICE_STATE_ACTIVATED)
return TRUE;
if (!nm_device_is_activating (self))
return TRUE;
// FIXME: why not just check connection path & service?
current_connection = nm_act_request_get_connection (nm_device_get_act_request (self));
if (nm_connection_compare (connection, current_connection, NM_SETTING_COMPARE_FLAG_EXACT)) {
/* Already activating or activated with the same connection */
g_set_error (error,
NM_DEVICE_INTERFACE_ERROR,
NM_DEVICE_INTERFACE_ERROR_CONNECTION_ACTIVATING,
"%s", "Connection is already activating");
return FALSE;
}
return TRUE;
}
static gboolean
nm_device_activate (NMDeviceInterface *device,
NMActRequest *req,
......@@ -2926,9 +2898,21 @@ nm_device_activate (NMDeviceInterface *device,
NMDevice *self = NM_DEVICE (device);
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
if (!device_activation_precheck (self, nm_act_request_get_connection (req), error)) {
g_assert (*error);
return FALSE;
/* Make sure this connection isn't activated already, or in the process of
* being activated.
*/
if ( nm_device_is_activating (self)
|| (nm_device_get_state (self) == NM_DEVICE_STATE_ACTIVATED)) {
NMConnection *new = nm_act_request_get_connection (req);
NMConnection *current = nm_act_request_get_connection (priv->act_request);
if (new == current) {
g_set_error_literal (error,
NM_DEVICE_INTERFACE_ERROR,
NM_DEVICE_INTERFACE_ERROR_CONNECTION_ACTIVATING,
"Connection is already activating");
return FALSE;
}
}
priv->act_request = g_object_ref (req);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment