Skip to content

manager: fix race condition while enumerating devices at startup

Beniamino Galvani requested to merge bg/link-rename-race-rhel25808 into main

Summary

While enumerating devices at startup, we take a snapshot of existing links from platform and we start creating device instances for them. It's possible that in the meantime, while processing netlink events in platform_link_added(), a link gets renamed. If that happens, then we have two different views of the same ifindex: the cached link from links and the link in platform.

This can cause issues: in platform_link_added() we create the device with the cached name; then in NMDevice's constructor(), we look up from platform the ifindex for the given name. Because of the rename, this lookup can match a newly created, different link.

The end result is that the ifindex from the initial snapshot doesn't get a NMDevice and is not handled by NetworkManager.

Fix this problem by fetching the latest version of the link from platform to make sure we have a consistent view of the state.

Resolves: https://issues.redhat.com/browse/RHEL-25808

Checklist

Please read https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/CONTRIBUTING.md before opening the merge request. In particular, check that:

  • the subject for all commits is concise and explicative
  • the message for all commits explains the reason for the change
  • the source is properly formatted
  • any relevant documentation is up to date
  • you have added unit tests if applicable
  • the NEWS file is updated when the change deserves to be mentioned, for example for new features, behavior changes, API deprecations, etc.
Edited by Beniamino Galvani

Merge request reports