device: update address in nm_device_update_from_platform_link()

When a software device is deactivated, normally we schedule a idle
task to unrealize the device (delete_on_deactivate). However, if a new
activation is enqueued on the same device (and that implies that the
new profile is compatible with the device), then the idle task is not
scheduled and the device will normally transition to the different
states (disconnected, prepare, config, etc.).

For ovs-interfaces, we remove the db entry on disconnect and that
makes the link go away; however, we don't clear the hw_addr* fields of
the device struct.

When the new link appears, we try to set the new cloned MAC but the
stale hw_addr field indicates that it's already set. Avoid this
problem by updating the address as soon as the link appears.

https://bugzilla.redhat.com/show_bug.cgi?id=2168477
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1532
(cherry picked from commit d403ac3d40)
This commit is contained in:
Beniamino Galvani 2023-02-10 17:33:23 +01:00
parent a2026a8b24
commit b87fa496ce

View file

@ -7168,6 +7168,9 @@ nm_device_update_from_platform_link(NMDevice *self, const NMPlatformLink *plink)
ifindex_changed = _set_ifindex(self, plink ? plink->ifindex : 0, FALSE);
nm_device_update_hw_address(self);
nm_device_update_permanent_hw_address(self, FALSE);
if (ifindex_changed)
NM_DEVICE_GET_CLASS(self)->link_changed(self, plink);