GNOME Bugzilla – Bug 772880
[review] cleanup handling of permanent MAC address for devices that don't have one [th/preserve-fake-perm-hwaddr-bgo772880]
Last modified: 2016-10-28 15:18:28 UTC
please review
Seems OK to me.... but we should test what happens with udev rules that assign a stable MAC address to the device like we've been recommending users do for years. Just to make sure that the udev-assigned MAC is considered the permanent one (even though it's fake) and not whatever random address the kernel assigned on hotplug. I'm pretty sure the platform code only exposes the device once all the rules have been applied, but we should check that just in case.
the primary usecase would be containers, where there is no udev. Note that this only takes effect - for devices that have no permanent MAC address (veth) - after restart of NetworkManager, if NetworkManager in the previous run already saw the device. But the issue you raise that udev rules change the MAC address is independent of this change. Platform exposes the device as soon as it sees it in netlink. But it still has an "initalized" flag set to false -- unless running in a container, where there is no udev. Indeed, that would trigger platform_link_added() and nm_device_realize_start(), which then calls nm_device_update_permanent_hw_address() and freezes the device to the possibly wrong MAC address. That should probably be fixed...
ok, added a follow up commit that aims to wait a bit more for UDEV to settle... It's however not clear that this will work in every case, because we might need a permanent MAC address earlier. That is, every access to nm_device_get_permanent_hw_addr() *needs* a MAC address now, it cannot wait for UDEV anymore.
> core: persist the fake permanent hardware address to the device's statefile + dev_state = nm_config_device_state_load (nm_config_get (), priv->ifindex); + if (dev_state) { + if ( dev_state Remove the outer if. > device: delay capturing permanent MAC address until UDEV is settled + /* the user is advised to configure stable MAC addresses for software devices via + * UDEV. Thus, check whether the link is fully initalized. */ s/initalized/initialized/ The rest LGTM.
New branch still looks fine to me.
merged: https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=e2b7da7b8202a3f9da1b73d78f5d210afa610a3e