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
This commit is contained in:
Thomas Haller 2023-10-31 12:11:55 +01:00
parent 175865c8d3
commit 86db3df6ac
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
3 changed files with 20 additions and 0 deletions

2
NEWS
View file

@ -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

View file

@ -193,6 +193,15 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>ID_NET_MANAGED_BY</varname></term>
<listitem><para>
If <varname>NM_UNMANAGED</varname> is set, this has no effect. Otherwise,
if the attribute is set to anything but
<literal>"org.freedesktop.NetworkManager"</literal>, the device is unmanaged.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>NM_AUTO_DEFAULT_LINK_LOCAL_ONLY</varname></term>
<listitem><para>

View file

@ -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;
}