From: Yu Watanabe Date: Tue, 31 Oct 2023 09:07:08 +0000 (+0900) Subject: network: support ID_NET_MANAGED_BY udev property X-Git-Tag: v255-rc1~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba87a61d05d637be9f0b21707f7fe3b0a74c5a05;p=thirdparty%2Fsystemd.git network: support ID_NET_MANAGED_BY udev property If the property is set, networkd manages the interface only when its value is "io.systemd.Network". Closes #29768. --- diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 4e360d7a8e8..b08dfbf1b70 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -77,6 +77,14 @@ configured. The first (in alphanumeric order) of the network files that matches a given interface is applied, all later files are ignored, even if they match as well. + Note that any network interfaces that have the ID_NET_MANAGED_BY= udev property + set will never be matched by any .network files – unless the property's value is the string + io.systemd.Network – even if the [Match] section would otherwise match. This may be + used to exclude specific network interfaces from systemd-networkd's management, while + keeping the [Match] section generic. The ID_NET_MANAGED_BY= poperty thus declares + intended ownership of the device, and permits ensuring that concurrent network + management implementations do not compete for management of specific devices. + A network file is said to match a network interface if all matches specified by the [Match] section are satisfied. When a network file does not contain valid settings in [Match] section, then the file will match all interfaces and systemd-networkd warns about that. Hint: diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 555b19d580b..2caf4ff2495 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1465,6 +1465,7 @@ static int link_check_initialized(Link *link) { int manager_udev_process_link(Manager *m, sd_device *device, sd_device_action_t action) { int r, ifindex; + const char *s; Link *link; assert(m); @@ -1499,6 +1500,15 @@ int manager_udev_process_link(Manager *m, sd_device *device, sd_device_action_t return 0; } + r = sd_device_get_property_value(device, "ID_NET_MANAGED_BY", &s); + if (r < 0 && r != -ENOENT) + log_device_debug_errno(device, r, "Failed to get ID_NET_MANAGED_BY udev property, ignoring: %m"); + if (r >= 0 && !streq(s, "io.systemd.Network")) { + log_device_debug(device, "Interface is requested to be managed by '%s', not managing the interface.", s); + link_set_state(link, LINK_STATE_UNMANAGED); + return 0; + } + r = link_initialized(link, device); if (r < 0) link_enter_failed(link);