]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: make 'carrier' as the default required operational state for CAN device
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Jan 2024 16:35:34 +0000 (01:35 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Jan 2024 19:05:43 +0000 (04:05 +0900)
As CAN devices do not support IP address, hence the state never goes to
higher than 'carrier'.

Prompted by https://github.com/linux-can/can-utils/issues/68#issuecomment-1327987724.

man/systemd.network.xml
src/network/networkd-link.c
src/network/networkd-network.c

index 76f9f4d042c584f33ad563eb3d9f90ad4fdeff17..35c897af398efdcf94091db15e64bc7a9669fe6a 100644 (file)
       <varlistentry>
         <term><varname>RequiredForOnline=</varname></term>
         <listitem>
-          <para>Takes a boolean or a minimum operational state and an optional maximum operational
-          state. Please see
+          <para>Takes a boolean, a minimum operational state (e.g., <literal>carrier</literal>), or a range
+          of operational state separated with a colon (e.g., <literal>degraded:routable</literal>).
+          Please see
           <citerefentry><refentrytitle>networkctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
           for possible operational states. When <literal>yes</literal>, the network is deemed required
           when determining whether the system is online (including when running
           minimum and maximum operational state required for the network interface to be considered
           online.</para>
 
+          <para>When <literal>yes</literal> is specified for a CAN device,
+          <command>systemd-networkd-wait-online</command> deems that the interface is online when its
+          operational state becomes <literal>carrier</literal>. For an interface with other type, e.g.
+          <literal>ether</literal>, the interface is deened online when its online state is
+          <literal>degraded</literal> or <literal>routable</literal>.</para>
+
           <para>Defaults to <literal>yes</literal> when <varname>ActivationPolicy=</varname> is not
           set, or set to <literal>up</literal>, <literal>always-up</literal>, or
           <literal>bound</literal>. Defaults to <literal>no</literal> when
index d553a716fa497b87048801ec02c4168ac73cbe19..57ea9ecb75d1f13ecd23bbe02f3396efa4395e90 100644 (file)
@@ -77,6 +77,11 @@ void link_required_operstate_for_online(Link *link, LinkOperationalStateRange *r
 
         if (link->network && operational_state_range_is_valid(&link->network->required_operstate_for_online))
                 *ret = link->network->required_operstate_for_online;
+        else if (link->iftype == ARPHRD_CAN)
+                *ret = (const LinkOperationalStateRange) {
+                        .min = LINK_OPERSTATE_CARRIER,
+                        .max = LINK_OPERSTATE_CARRIER,
+                };
         else
                 *ret = LINK_OPERSTATE_RANGE_DEFAULT;
 }
index 845a8130bde3ef464b8a58bdb91d57844558de8b..08c7da56997422a82a36ed9cc9f7b9f0b3880f21 100644 (file)
@@ -372,7 +372,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
                 .n_ref = 1,
 
                 .required_for_online = -1,
-                .required_operstate_for_online = LINK_OPERSTATE_RANGE_DEFAULT,
+                .required_operstate_for_online = LINK_OPERSTATE_RANGE_INVALID,
                 .activation_policy = _ACTIVATION_POLICY_INVALID,
                 .group = -1,
                 .arp = -1,
@@ -1221,7 +1221,7 @@ int config_parse_required_for_online(
 
         if (isempty(rvalue)) {
                 network->required_for_online = -1;
-                network->required_operstate_for_online = LINK_OPERSTATE_RANGE_DEFAULT;
+                network->required_operstate_for_online = LINK_OPERSTATE_RANGE_INVALID;
                 return 0;
         }