device: fix taking over device after modifying external connection

For externally managed interfaces, we create an in-memory connection
and keep the device with sys-iface-state=external.

When the user actively modifies the connection, we persist it to
storage. But we also must take over managing the device.

One problem is that nm_device_reapply() errors out if the device
is still activating. It's unclear how to reapply the connection
while the device is in the process of activation. So, if the user
modifies the created connection very quickly, reapplying the settings
will fail.

https://bugzilla.redhat.com/show_bug.cgi?id=1462223
This commit is contained in:
Thomas Haller
2017-06-16 13:06:26 +02:00
parent b84da25713
commit 10c0632df0
3 changed files with 32 additions and 5 deletions

View File

@@ -793,6 +793,8 @@ _settings_connection_notify_flags (NMSettingsConnection *settings_connection,
GParamSpec *param,
NMActiveConnection *self)
{
GError *error = NULL;
nm_assert (NM_IS_ACTIVE_CONNECTION (self));
nm_assert (NM_IS_SETTINGS_CONNECTION (settings_connection));
nm_assert (nm_active_connection_get_activation_type (self) == NM_ACTIVATION_TYPE_EXTERNAL);
@@ -802,7 +804,13 @@ _settings_connection_notify_flags (NMSettingsConnection *settings_connection,
return;
_set_activation_type_managed (self);
nm_device_reapply_settings_immediately (nm_active_connection_get_device (self));
if (!nm_device_reapply (nm_active_connection_get_device (self),
NM_CONNECTION (nm_active_connection_get_settings_connection (self)),
&error)) {
_LOGW ("failed to reapply new device settings on previously externally managed device: %s",
error->message);
g_error_free (error);
}
}
/*****************************************************************************/