device: delay capturing permanent MAC address until UDEV is settled

System Internals / NetworkManager - Thomas Haller [redhat.com] - 28 October 2016 09:44 UTC

The permanent MAC address of an NMDevice shall not change as long as the device is realized. That is, we read it only once and don't change it afterwards.

There are two issues that this commit tries to mitigate:

(1) users are advised to use UDEV to rename interfaces. As we lookup the permenent MAC address using ethtool (which uses the interface name), there is a race where we could read the permanent MAC address using the wrong interface name. We should wait until UDEV finished initializing the device and until the interface name is stable (see rh#1388286). This commit still cannot avoid the race of ethtool entirely. It only tries to avoid ethtool until UDEV has done its work. That is, until we expect the interface name no longer to change.

(2) some device types, don't have a permanent MAC address so we fall back to use the currently set address (fake). Again, users are advised to use UDEV to configure the MAC addresses on such software devices. Thus, we should not get the fake MAC address until UDEV initialized the device.

This patch actually doesn't solve the problem at all yet. The reason is that a regular caller of nm_device_get_permanent_hw_address() can not afford to wait until UDEV settled. Thus, any user who requests the permanent MAC address before the link is initialized, runs into the problems above.

In a next step, we shall revisit such calls to nm_device_get_permanent_hw_address() and delay them until the link is initialized.

7b7c653 device: delay capturing permanent MAC address until UDEV is settled
src/devices/nm-device-ethernet.c | 4 +-
src/devices/nm-device.c | 111 ++++++++++++++++++++++++--------------
src/devices/nm-device.h | 3 +-
src/nm-manager.c | 2 +-
4 files changed, 76 insertions(+), 44 deletions(-)

Upstream: cgit.freedesktop.org


  • Share