]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/network/networkd-state-file.c
network: add an online state for links and manager
authorAlvin Šipraga <alsi@bang-olufsen.dk>
Tue, 30 Mar 2021 19:39:18 +0000 (21:39 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 19 May 2021 01:33:55 +0000 (10:33 +0900)
commitbcdcc59648dabefaed4267a2432a9e7928f93cb5
tree97653a2cd0da13178b6c0dae7d7204e8ae7c4ff8
parente7901aba1480db21e06e21cef4f6486ad71b2ec5
network: add an online state for links and manager

Add a new state of type LinkOnlineState which indicates whether a link
is online or not. The state is also used by networkd's manager to expose
the overall online state of the system.

The possible states are:

  offline  the link (or system) is offline
  partial  at least one required link is online (see below)
  online   all required links are online

For links, a link is defined to be "online" if:
  - it is managed; and
  - its operational state is within the range defined by
    RequiredForOnline=; and
  - it has an IPv4 address if RequiredFamilyForOnline=ipv4 or =both; and
  - it has an IPv6 address if RequiredFamilyForOnline=ipv6 or =both.

A link is defined to be "offline" if:
  - it is managed; and
  - it is not online, i.e. its operational state is not within the range
    defined by RequiredForOnline=, and/or it is missing an IP address in
    a required address family.

Otherwise, the link online state is undefined (represented internally as
_LINK_ONLINE_STATUS_INVALID or -EINVAL). Put another way, networkd will
only offer a meaningful online state for managed links where
RequiredForOnline=yes.

For the manager, the online state is a function of the online state of
all links which are requried for online, i.e. RequiredForOnline=yes. If
all required links are online, then the manager online state is defined
to be "online". If at least one of the required links is online, then
the manager online state is defined to be "partial". If none of
the required links are online, then the manager online state is defined
to be "offline". If there are no managed links, or RequiredForOnline=no
for all managed links, then the manager online state is undefined as
above.

The purpose of the "partial" state is analogous to the --any switch in
systemd-networkd-wait-online.service(8). For example, a required link
which lacks a carrier on boot will not force the overall (manager)
online state to "offline" if there is an alternative link available.
13 files changed:
src/libsystemd/sd-network/network-util.c
src/libsystemd/sd-network/network-util.h
src/libsystemd/sd-network/sd-network.c
src/network/networkd-json.c
src/network/networkd-link-bus.c
src/network/networkd-link-bus.h
src/network/networkd-link.c
src/network/networkd-link.h
src/network/networkd-manager-bus.c
src/network/networkd-manager.c
src/network/networkd-manager.h
src/network/networkd-state-file.c
src/systemd/sd-network.h