Skip to content

Commit abbd24e

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)
1 parent ff63a08 commit abbd24e

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
@@ -162,12 +162,13 @@ bool manager_configured(Manager *m) {
162162
return true;
163163
}
164164

165-
/* With '--any' : no interface is ready
166-
* Without '--any': all interfaces are ready */
165+
/* With '--any' : no interface is ready → return false
166+
* Without '--any': all interfaces are ready → return true */
167167
return !m->any;
168168
}
169169

170170
/* wait for all links networkd manages */
171+
bool has_online = false;
171172
HASHMAP_FOREACH(l, m->links_by_index) {
172173
if (manager_ignore_link(m, l)) {
173174
log_link_debug(l, "link is ignored");
@@ -179,13 +180,20 @@ bool manager_configured(Manager *m) {
179180
_LINK_OPERSTATE_INVALID });
180181
if (r < 0 && !m->any) /* Unlike the above loop, unmanaged interfaces are ignored here. */
181182
return false;
182-
if (r > 0 && m->any)
183-
return true;
183+
if (r > 0) {
184+
if (m->any)
185+
return true;
186+
has_online = true;
187+
}
184188
}
185189

186-
/* With '--any' : no interface is ready
187-
* Without '--any': all interfaces are ready or unmanaged */
188-
return !m->any;
190+
/* With '--any' : no interface is ready → return false
191+
* Without '--any': all interfaces are ready or unmanaged
192+
*
193+
* In this stage, drivers for interfaces may not be loaded yet, and there may be only lo.
194+
* To avoid that wait-online exits earlier than that drivers are loaded, let's request at least one
195+
* managed online interface exists. See issue #27822. */
196+
return !m->any && has_online;
189197
}
190198

191199
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
@@ -1149,10 +1149,6 @@ def setUp(self):
11491149
def tearDown(self):
11501150
tear_down_common()
11511151

1152-
def test_wait_online_all_unmanaged(self):
1153-
start_networkd()
1154-
self.wait_online([])
1155-
11561152
def test_wait_online_any(self):
11571153
copy_network_unit('25-bridge.netdev', '25-bridge.network', '11-dummy.netdev', '11-dummy.network')
11581154
start_networkd()

0 commit comments

Comments
 (0)