device: fix wrongly managing external-down device due to not setting EXTERNAL_DOWN

The unmanaged-flag NM_UNMANAGED_EXTERNAL_DOWN is initially set during
nm_device_finish_init(). But it was only set if the device was down at
that point.

If due to a race the platform device was not yet initialized, a later
initialization in device_link_changed() would clear NM_UNMANAGED_PLATFORM_INIT.
If the device is not external-down (because it was already up during
nm_device_finish_init()), the device will be managed right away with
reason NM_DEVICE_STATE_REASON_NOW_MANAGED.

Together with commit e29ab54335, this
is a race that causes a failure to assume the external-down device.

https://bugzilla.redhat.com/show_bug.cgi?id=1269199
This commit is contained in:
Thomas Haller 2015-10-09 21:45:23 +02:00
parent 9f1eb190f7
commit 120847c8a3

View file

@ -1146,8 +1146,9 @@ nm_device_finish_init (NMDevice *self)
/* Do not manage externally created software devices until they are IFF_UP */
if ( NM_DEVICE_GET_CLASS (self)->can_unmanaged_external_down (self)
&& !nm_platform_link_is_up (NM_PLATFORM_GET, priv->ifindex)
&& priv->ifindex > 0)
&& priv->ifindex > 0
&& ( !priv->up
|| !priv->platform_link_initialized))
nm_device_set_unmanaged_initial (self, NM_UNMANAGED_EXTERNAL_DOWN, TRUE);
if (priv->master)