Skip to content

Commit 0531c47

Browse files
yuwatabluca
authored andcommitted
wait-online: request that at least one managed online interface exists
Fixes a regression caused by ab3aed4. I thought the commit does not cause any severe regression. However, drivers for network interfaces may be loaded later. So, we should wait if no network interface is found. Fixes #27822. (cherry picked from commit 2f96a29) (cherry picked from commit abbd24e)
1 parent 5ad5807 commit 0531c47

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/network/wait-online/manager.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,13 @@ bool manager_configured(Manager *m) {
142142
return true;
143143
}
144144

145-
/* With '--any' : no interface is ready
146-
* Without '--any': all interfaces are ready */
145+
/* With '--any' : no interface is ready → return false
146+
* Without '--any': all interfaces are ready → return true */
147147
return !m->any;
148148
}
149149

150150
/* wait for all links networkd manages */
151+
bool has_online = false;
151152
HASHMAP_FOREACH(l, m->links_by_index) {
152153
if (manager_ignore_link(m, l)) {
153154
log_link_debug(l, "link is ignored");
@@ -159,13 +160,20 @@ bool manager_configured(Manager *m) {
159160
_LINK_OPERSTATE_INVALID });
160161
if (r < 0 && !m->any) /* Unlike the above loop, unmanaged interfaces are ignored here. */
161162
return false;
162-
if (r > 0 && m->any)
163-
return true;
163+
if (r > 0) {
164+
if (m->any)
165+
return true;
166+
has_online = true;
167+
}
164168
}
165169

166-
/* With '--any' : no interface is ready
167-
* Without '--any': all interfaces are ready or unmanaged */
168-
return !m->any;
170+
/* With '--any' : no interface is ready → return false
171+
* Without '--any': all interfaces are ready or unmanaged
172+
*
173+
* In this stage, drivers for interfaces may not be loaded yet, and there may be only lo.
174+
* To avoid that wait-online exits earlier than that drivers are loaded, let's request at least one
175+
* managed online interface exists. See issue #27822. */
176+
return !m->any && has_online;
169177
}
170178

171179
static int manager_process_link(sd_netlink *rtnl, sd_netlink_message *mm, void *userdata) {

test/test-network/systemd-networkd-tests.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,10 +1103,6 @@ def setUp(self):
11031103
def tearDown(self):
11041104
tear_down_common()
11051105

1106-
def test_wait_online_all_unmanaged(self):
1107-
start_networkd()
1108-
self.wait_online([])
1109-
11101106
def test_wait_online_any(self):
11111107
copy_network_unit('25-bridge.netdev', '25-bridge.network', '11-dummy.netdev', '11-dummy.network')
11121108
start_networkd()

0 commit comments

Comments
 (0)