From 5cbaf95ee3110d0a5b28eeb7a89a75a165b12e7b Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 14 Jan 2020 14:08:03 +0100 Subject: [PATCH] wait-online: Support waiting for interfaces to disappear --- man/networkctl.xml | 6 ++++++ src/libsystemd/sd-network/network-util.c | 3 ++- src/libsystemd/sd-network/network-util.h | 1 + src/network/wait-online/manager.c | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/man/networkctl.xml b/man/networkctl.xml index 6b3702bfd3c..b0c8b002c05 100644 --- a/man/networkctl.xml +++ b/man/networkctl.xml @@ -69,6 +69,12 @@ The operational status is one of the following: + + missing + + the device is missing + + off diff --git a/src/libsystemd/sd-network/network-util.c b/src/libsystemd/sd-network/network-util.c index 4eb06b91ac9..0addabe10a2 100644 --- a/src/libsystemd/sd-network/network-util.c +++ b/src/libsystemd/sd-network/network-util.c @@ -26,6 +26,7 @@ bool network_is_online(void) { } static const char* const link_operstate_table[_LINK_OPERSTATE_MAX] = { + [LINK_OPERSTATE_MISSING] = "missing", [LINK_OPERSTATE_OFF] = "off", [LINK_OPERSTATE_NO_CARRIER] = "no-carrier", [LINK_OPERSTATE_DORMANT] = "dormant", @@ -91,7 +92,7 @@ int parse_operational_state_range(const char *str, LinkOperationalStateRange *ou return -EINVAL; if (range.min == _LINK_OPERSTATE_INVALID) - range.min = LINK_OPERSTATE_OFF; + range.min = LINK_OPERSTATE_MISSING; if (range.max == _LINK_OPERSTATE_INVALID) range.max = LINK_OPERSTATE_ROUTABLE; diff --git a/src/libsystemd/sd-network/network-util.h b/src/libsystemd/sd-network/network-util.h index 1087a1c6644..425d192f640 100644 --- a/src/libsystemd/sd-network/network-util.h +++ b/src/libsystemd/sd-network/network-util.h @@ -8,6 +8,7 @@ bool network_is_online(void); typedef enum LinkOperationalState { + LINK_OPERSTATE_MISSING, LINK_OPERSTATE_OFF, LINK_OPERSTATE_NO_CARRIER, LINK_OPERSTATE_DORMANT, diff --git a/src/network/wait-online/manager.c b/src/network/wait-online/manager.c index e4643418a74..4734ce28ee5 100644 --- a/src/network/wait-online/manager.c +++ b/src/network/wait-online/manager.c @@ -78,6 +78,11 @@ bool manager_configured(Manager *m) { LinkOperationalStateRange *range = p; l = hashmap_get(m->links_by_name, ifname); + if (!l && range->min == LINK_OPERSTATE_MISSING) { + one_ready = true; + continue; + } + if (!l) { log_debug("still waiting for %s", ifname); if (!m->any)