wait-online: also use address state even when operational state is below degraded
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 13 Dec 2021 11:14:06 +0000 (20:14 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 14 Dec 2021 09:32:56 +0000 (10:32 +0100)
Closes #21706.

man/systemd-networkd-wait-online.service.xml
src/network/wait-online/manager.c

index 31aa02218af8334e318fa9165445993cc669b7f1..9c6b02ac1c80fe5d29b3a96563022ef89fec4352 100644 (file)
         <listitem><para>Waiting for an IPv4 address of each network interface to be configured. If this
         option is specified with <option>--any</option>, then
         <command>systemd-networkd-wait-online</command> exits with success when at least one interface
-        becomes online and has an IPv4 address. The option is applied only for the operational state
-        <literal>degraded</literal> or above. If neither <option>--ipv4</option> nor
+        becomes online and has an IPv4 address. If the required minimum operational state is
+        below <literal>routable</literal>, then each link (or at least one link with
+        <option>--any</option>) must have an IPv4 link-local or routable address. If the required
+        minimum operational state is <literal>routable</literal>, then each link must have an IPv4
+        routable address.</para>
+        <para>If neither <option>--ipv4</option> nor
         <option>--ipv6</option> is specified, then the value from
         <varname>RequiredFamilyForOnline=</varname> in the corresponding <filename>.network</filename>
         file is used if present.</para></listitem>
         <listitem><para>Waiting for an IPv6 address of each network interface to be configured. If this
         option is specified with <option>--any</option>, then
         <command>systemd-networkd-wait-online</command> exits with success when at least one interface
-        becomes online and has an IPv6 address. The option is applied only for the operational state
-        <literal>degraded</literal> or above. If neither <option>--ipv4</option> nor
+        becomes online and has an IPv6 address. If the required minimum operational state is
+        below <literal>routable</literal>, then each link (or at least one link with
+        <option>--any</option>) must have an IPv6 link-local or routable address. If the required
+        minimum operational state is <literal>routable</literal>, then each link must have an IPv6
+        routable address.</para>
+        <para>If neither <option>--ipv4</option> nor
         <option>--ipv6</option> is specified, then the value from
         <varname>RequiredFamilyForOnline=</varname> in the corresponding <filename>.network</filename>
         file is used if present.</para></listitem>
index e1df0345c0de3a5ed773a2659ccf493195b00063..3890e92b61c7138e6142979da30c8574c98fdc16 100644 (file)
@@ -71,7 +71,7 @@ static int manager_link_is_online(Manager *m, Link *l, LinkOperationalStateRange
         needs_ipv4 = required_family & ADDRESS_FAMILY_IPV4;
         needs_ipv6 = required_family & ADDRESS_FAMILY_IPV6;
 
-        if (s.min >= LINK_OPERSTATE_DEGRADED) {
+        if (s.min < LINK_OPERSTATE_ROUTABLE) {
                 if (needs_ipv4 && l->ipv4_address_state < LINK_ADDRESS_STATE_DEGRADED) {
                         log_link_debug(l, "No routable or link-local IPv4 address is configured.");
                         return 0;
@@ -81,9 +81,7 @@ static int manager_link_is_online(Manager *m, Link *l, LinkOperationalStateRange
                         log_link_debug(l, "No routable or link-local IPv6 address is configured.");
                         return 0;
                 }
-        }
-
-        if (s.min >= LINK_OPERSTATE_ROUTABLE) {
+        } else {
                 if (needs_ipv4 && l->ipv4_address_state < LINK_ADDRESS_STATE_ROUTABLE) {
                         log_link_debug(l, "No routable IPv4 address is configured.");
                         return 0;