From 86db3df6ac331558b8cf48ab3747cabc4f3c249c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 31 Oct 2023 12:11:55 +0100 Subject: [PATCH] core: honor ID_NET_MANAGED_BY="org.freedesktop.NetworkManager" to manage device If ID_NET_MANAGED_BY= attribute is set, we have an indication who is responsible for the device. If this is set to anything but "org.freedesktop.NetworkManager", then the device is unmanaged. The effect is the same as setting NM_UNMANAGED= attribute. NM_UNMANAGED= takes precedence over this setting. See-also: https://github.com/systemd/systemd/issues/29768 See-also: https://github.com/systemd/systemd/pull/29782 --- NEWS | 2 ++ man/NetworkManager.xml | 9 +++++++++ src/libnm-platform/nm-platform.c | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/NEWS b/NEWS index 0079fd8487..e7838bd35f 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,8 @@ Overview of changes since NetworkManager-1.44 should not be noticeable. * Honor udev property ID_NET_AUTO_LINK_LOCAL_ONLY=1 for enabling link local addresses on default wired connection. +* Honor udev property ID_NET_MANAGED_BY to only manage an interface + when set to "org.freedesktop.NetworkManager". ============================================= NetworkManager-1.44 diff --git a/man/NetworkManager.xml b/man/NetworkManager.xml index 5c17bd52fc..ff1635cd29 100644 --- a/man/NetworkManager.xml +++ b/man/NetworkManager.xml @@ -193,6 +193,15 @@ + + ID_NET_MANAGED_BY + + If NM_UNMANAGED is set, this has no effect. Otherwise, + if the attribute is set to anything but + "org.freedesktop.NetworkManager", the device is unmanaged. + + + NM_AUTO_DEFAULT_LINK_LOCAL_ONLY diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index e55c749931..d5acec98f5 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -1673,6 +1673,15 @@ nm_platform_link_get_unmanaged(NMPlatform *self, int ifindex) if (val) return _nm_utils_ascii_str_to_bool(val, FALSE); + val = udev_device_get_property_value(udevice, "ID_NET_MANAGED_BY"); + if (val) { + if (!nm_streq(val, "org.freedesktop.NetworkManager")) { + /* There is another manager. UNMANAGED. */ + return TRUE; + } + return FALSE; + } + return NM_OPTION_BOOL_DEFAULT; }