Skip to content

Commit

Permalink
wait-online: request that at least one managed online interface exists
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
yuwata authored and bluca committed Jul 7, 2023
1 parent ff63a08 commit abbd24e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 15 additions & 7 deletions src/network/wait-online/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,13 @@ bool manager_configured(Manager *m) {
return true;
}

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

/* wait for all links networkd manages */
bool has_online = false;
HASHMAP_FOREACH(l, m->links_by_index) {
if (manager_ignore_link(m, l)) {
log_link_debug(l, "link is ignored");
Expand All @@ -179,13 +180,20 @@ bool manager_configured(Manager *m) {
_LINK_OPERSTATE_INVALID });
if (r < 0 && !m->any) /* Unlike the above loop, unmanaged interfaces are ignored here. */
return false;
if (r > 0 && m->any)
return true;
if (r > 0) {
if (m->any)
return true;
has_online = true;
}
}

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

static int manager_process_link(sd_netlink *rtnl, sd_netlink_message *mm, void *userdata) {
Expand Down
4 changes: 0 additions & 4 deletions test/test-network/systemd-networkd-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,10 +1149,6 @@ def setUp(self):
def tearDown(self):
tear_down_common()

def test_wait_online_all_unmanaged(self):
start_networkd()
self.wait_online([])

def test_wait_online_any(self):
copy_network_unit('25-bridge.netdev', '25-bridge.network', '11-dummy.netdev', '11-dummy.network')
start_networkd()
Expand Down

0 comments on commit abbd24e

Please sign in to comment.