Skip to content

Commit b6caf4d

Browse files
committed
systemd: fix unmanaged interface in networkd
1 parent 0647c69 commit b6caf4d

3 files changed

Lines changed: 152 additions & 2 deletions

File tree

SPECS-SIGNED/systemd-boot-signed/systemd-boot-signed.spec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Version: 255
2020
# determine the build information from local checkout
2121
Version: %(tools/meson-vcs-tag.sh . error | sed -r 's/-([0-9])/.^\1/; s/-g/_g/')
2222
%endif
23-
Release: 27%{?dist}
23+
Release: 28%{?dist}
2424
License: LGPL-2.1-or-later AND MIT AND GPL-2.0-or-later
2525
Vendor: Microsoft Corporation
2626
Distribution: Azure Linux
@@ -98,6 +98,9 @@ popd
9898
/boot/efi/EFI/BOOT/%{grubefiname}
9999

100100
%changelog
101+
* Tue May 05 2026 Nikola Bojanic <nbojanic@microsoft.com> - 255-28
102+
- Bump release to match systemd spec
103+
101104
* Thu Mar 26 2026 Lanze Liu <lanzeliu@microsoft.com> - 255-27
102105
- Bump release to match systemd spec
103106

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
From 2485443518b3bc6ef322696f96293041974bc8fc Mon Sep 17 00:00:00 2001
2+
From: Yu Watanabe <watanabe.yu+github@gmail.com>
3+
Date: Wed, 11 Jun 2025 18:05:46 +0900
4+
Subject: [PATCH] network: also check ID_NET_MANAGED_BY property on reconfigure
5+
6+
Previously, the property was checked only when an uevent is received,
7+
so even if an interface has ID_NET_MANAGED_BY property, the interface
8+
will be configured by networkd when reconfiguration is triggered e.g.
9+
when interface state is changed.
10+
11+
Follow-up for ba87a61d05d637be9f0b21707f7fe3b0a74c5a05.
12+
Fixes #36997.
13+
14+
(cherry picked from commit 78f8d5ed71ecc16ad36d1c215d2d57433d127679)
15+
---
16+
src/network/networkd-link.c | 44 ++++++++++++++-----
17+
.../test-network/conf/11-dummy-unmanaged.link | 8 ++++
18+
test/test-network/systemd-networkd-tests.py | 11 +++++
19+
3 files changed, 53 insertions(+), 10 deletions(-)
20+
create mode 100644 test/test-network/conf/11-dummy-unmanaged.link
21+
22+
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
23+
index 2caf4ff249..6814ef09f0 100644
24+
--- a/src/network/networkd-link.c
25+
+++ b/src/network/networkd-link.c
26+
@@ -1213,6 +1213,32 @@ static int link_get_network(Link *link, Network **ret) {
27+
return -ENOENT;
28+
}
29+
30+
+static int link_managed_by_us(Link *link) {
31+
+ int r;
32+
+
33+
+ assert(link);
34+
+
35+
+ if (!link->dev)
36+
+ return true;
37+
+
38+
+ const char *s;
39+
+ r = sd_device_get_property_value(link->dev, "ID_NET_MANAGED_BY", &s);
40+
+ if (r == -ENOENT)
41+
+ return true;
42+
+ if (r < 0)
43+
+ return log_link_warning_errno(link, r, "Failed to get ID_NET_MANAGED_BY udev property: %m");
44+
+
45+
+ if (streq(s, "io.systemd.Network"))
46+
+ return true;
47+
+
48+
+ if (link->state == LINK_STATE_UNMANAGED)
49+
+ return false; /* Already in unmanaged state */
50+
+
51+
+ log_link_debug(link, "Interface is requested to be managed by '%s', unmanaging the interface.", s);
52+
+ link_set_state(link, LINK_STATE_UNMANAGED);
53+
+ return false;
54+
+}
55+
+
56+
int link_reconfigure_impl(Link *link, bool force) {
57+
Network *network = NULL;
58+
NetDev *netdev = NULL;
59+
@@ -1223,6 +1249,10 @@ int link_reconfigure_impl(Link *link, bool force) {
60+
if (IN_SET(link->state, LINK_STATE_PENDING, LINK_STATE_LINGER))
61+
return 0;
62+
63+
+ r = link_managed_by_us(link);
64+
+ if (r <= 0)
65+
+ return r;
66+
+
67+
r = netdev_get(link->manager, link->ifname, &netdev);
68+
if (r < 0 && r != -ENOENT)
69+
return r;
70+
@@ -1398,6 +1428,10 @@ static int link_initialized(Link *link, sd_device *device) {
71+
* or sysattrs) may be outdated. */
72+
device_unref_and_replace(link->dev, device);
73+
74+
+ r = link_managed_by_us(link);
75+
+ if (r <= 0)
76+
+ return r;
77+
+
78+
if (link->dhcp_client) {
79+
r = sd_dhcp_client_attach_device(link->dhcp_client, link->dev);
80+
if (r < 0)
81+
@@ -1465,7 +1499,6 @@ static int link_check_initialized(Link *link) {
82+
83+
int manager_udev_process_link(Manager *m, sd_device *device, sd_device_action_t action) {
84+
int r, ifindex;
85+
- const char *s;
86+
Link *link;
87+
88+
assert(m);
89+
@@ -1500,15 +1533,6 @@ int manager_udev_process_link(Manager *m, sd_device *device, sd_device_action_t
90+
return 0;
91+
}
92+
93+
- r = sd_device_get_property_value(device, "ID_NET_MANAGED_BY", &s);
94+
- if (r < 0 && r != -ENOENT)
95+
- log_device_debug_errno(device, r, "Failed to get ID_NET_MANAGED_BY udev property, ignoring: %m");
96+
- if (r >= 0 && !streq(s, "io.systemd.Network")) {
97+
- log_device_debug(device, "Interface is requested to be managed by '%s', not managing the interface.", s);
98+
- link_set_state(link, LINK_STATE_UNMANAGED);
99+
- return 0;
100+
- }
101+
-
102+
r = link_initialized(link, device);
103+
if (r < 0)
104+
link_enter_failed(link);
105+
diff --git a/test/test-network/conf/11-dummy-unmanaged.link b/test/test-network/conf/11-dummy-unmanaged.link
106+
new file mode 100644
107+
index 0000000000..99c07a72ce
108+
--- /dev/null
109+
+++ b/test/test-network/conf/11-dummy-unmanaged.link
110+
@@ -0,0 +1,8 @@
111+
+# SPDX-License-Identifier: MIT-0
112+
+[Match]
113+
+Kind=dummy
114+
+OriginalName=test1
115+
+
116+
+[Link]
117+
+NamePolicy=keep
118+
+Property=ID_NET_MANAGED_BY=hoge
119+
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py
120+
index f49438ecd1..80085b919a 100755
121+
--- a/test/test-network/systemd-networkd-tests.py
122+
+++ b/test/test-network/systemd-networkd-tests.py
123+
@@ -2436,6 +2436,17 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
124+
def tearDown(self):
125+
tear_down_common()
126+
127+
+ def test_ID_NET_MANAGED_BY(self):
128+
+ copy_network_unit('11-dummy.netdev', '11-dummy-unmanaged.link', '11-dummy.network')
129+
+ start_networkd()
130+
+ self.wait_online('test1:off', setup_state='unmanaged')
131+
+
132+
+ check_output('ip link set dev test1 up')
133+
+ self.wait_online('test1:degraded', setup_state='unmanaged')
134+
+
135+
+ check_output('ip link set dev test1 down')
136+
+ self.wait_online('test1:off', setup_state='unmanaged')
137+
+
138+
def verify_address_static(
139+
self,
140+
label1: str,
141+
--
142+
2.45.4

SPECS/systemd/systemd.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Version: 255
5050
# determine the build information from local checkout
5151
Version: %(tools/meson-vcs-tag.sh . error | sed -r 's/-([0-9])/.^\1/; s/-g/_g/')
5252
%endif
53-
Release: 27%{?dist}
53+
Release: 28%{?dist}
5454

5555
# FIXME - hardcode to 'stable' for now as that's what we have in our blobstore
5656
%global stable 1
@@ -150,6 +150,7 @@ Patch0906: ipc-call-0003-core-cgroup-avoid-one-unnecessary-strjoina.patch
150150
Patch0907: ipc-call-0002-path-util-invert-PATH_STARTSWITH_ACCEPT_DOT_DOT-flag.patch
151151
Patch0908: ipc-call-0004-core-validate-input-cgroup-path-more-prudently.patch
152152
Patch0909: fix-pcrlock-hyperv-hash-algorithm-ordering.patch
153+
Patch0910: network-also-check-ID_NET_MANAGED_BY-property-on-rec.patch
153154

154155
%ifarch %{ix86} x86_64 aarch64
155156
%global want_bootloader 1
@@ -1235,6 +1236,10 @@ rm -f %{name}.lang
12351236
# %autochangelog. So we need to continue manually maintaining the
12361237
# changelog here.
12371238
%changelog
1239+
* Tue May 05 2026 Nikola Bojanic <nbojanic@microsoft.com> - 255-28
1240+
- Backport upstream commit 78f8d5e: network: also check ID_NET_MANAGED_BY
1241+
property on reconfigure.
1242+
12381243
* Thu Mar 26 2026 Lanze Liu <lanzeliu@microsoft.com> - 255-27
12391244
- Fix pcrlock failure on Hyper-V/Azure VMs with vTPM by backporting upstream
12401245
commit e90a255 from systemd v256 (PR #31429).

0 commit comments

Comments
 (0)