mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-22 22:03:43 +03:00
wait-online: request that at least one managed online interface exists
Fixes a regression caused by ab3aed4a0349bbaa26f53340770c1b59b463e05d. 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.
This commit is contained in:
parent
505c501c67
commit
2f96a29c2c
@ -162,12 +162,13 @@ bool manager_configured(Manager *m) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* With '--any' : no interface is ready
|
/* With '--any' : no interface is ready → return false
|
||||||
* Without '--any': all interfaces are ready */
|
* Without '--any': all interfaces are ready → return true */
|
||||||
return !m->any;
|
return !m->any;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wait for all links networkd manages */
|
/* wait for all links networkd manages */
|
||||||
|
bool has_online = false;
|
||||||
HASHMAP_FOREACH(l, m->links_by_index) {
|
HASHMAP_FOREACH(l, m->links_by_index) {
|
||||||
if (manager_ignore_link(m, l)) {
|
if (manager_ignore_link(m, l)) {
|
||||||
log_link_debug(l, "link is ignored");
|
log_link_debug(l, "link is ignored");
|
||||||
@ -179,13 +180,20 @@ bool manager_configured(Manager *m) {
|
|||||||
_LINK_OPERSTATE_INVALID });
|
_LINK_OPERSTATE_INVALID });
|
||||||
if (r < 0 && !m->any) /* Unlike the above loop, unmanaged interfaces are ignored here. */
|
if (r < 0 && !m->any) /* Unlike the above loop, unmanaged interfaces are ignored here. */
|
||||||
return false;
|
return false;
|
||||||
if (r > 0 && m->any)
|
if (r > 0) {
|
||||||
return true;
|
if (m->any)
|
||||||
|
return true;
|
||||||
|
has_online = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* With '--any' : no interface is ready
|
/* With '--any' : no interface is ready → return false
|
||||||
* Without '--any': all interfaces are ready or unmanaged */
|
* Without '--any': all interfaces are ready or unmanaged
|
||||||
return !m->any;
|
*
|
||||||
|
* 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) {
|
static int manager_process_link(sd_netlink *rtnl, sd_netlink_message *mm, void *userdata) {
|
||||||
|
@ -1157,10 +1157,6 @@ class WaitOnlineTests(unittest.TestCase, Utilities):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
tear_down_common()
|
tear_down_common()
|
||||||
|
|
||||||
def test_wait_online_all_unmanaged(self):
|
|
||||||
start_networkd()
|
|
||||||
self.wait_online([])
|
|
||||||
|
|
||||||
def test_wait_online_any(self):
|
def test_wait_online_any(self):
|
||||||
copy_network_unit('25-bridge.netdev', '25-bridge.network', '11-dummy.netdev', '11-dummy.network')
|
copy_network_unit('25-bridge.netdev', '25-bridge.network', '11-dummy.netdev', '11-dummy.network')
|
||||||
start_networkd()
|
start_networkd()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user