1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

network: introduce 'degraded-carrier' operstate to order all states

Previously, 'degraded' state is ambiguous for bonding or bridge master:
1. one or more slave interfaces does not have carrier,
2. no link local address is assigned to the master,
3. combination of the above two.

This makes the above case 1 and 3 are in the new 'degraded-carrier'
state, and makes 'degraded' state as all slaves are active but no
link local address on master.
This commit is contained in:
Yu Watanabe 2019-03-05 14:41:56 +09:00
parent 2cd6b9326c
commit c9cc038343
6 changed files with 24 additions and 18 deletions

View File

@ -115,6 +115,13 @@
<para>the device has a carrier, but is not yet ready for normal traffic</para>
</listitem>
</varlistentry>
<varlistentry>
<term>degraded-carrier</term>
<listitem>
<para>for bond or bridge master, one of the bonding or bridge slave network interfaces is
in off, no-carrier, or dormant state</para>
</listitem>
</varlistentry>
<varlistentry>
<term>carrier</term>
<listitem>
@ -125,9 +132,7 @@
<varlistentry>
<term>degraded</term>
<listitem>
<para>the link has carrier and addresses valid on the local link configured, or for bond
or bridge master, one of the bonding or bridge slave network interfaces is in off,
no-carrier, or dormant</para>
<para>the link has carrier and addresses valid on the local link configured</para>
</listitem>
</varlistentry>
<varlistentry>

View File

@ -21,13 +21,14 @@ bool network_is_online(void) {
}
static const char* const link_operstate_table[_LINK_OPERSTATE_MAX] = {
[LINK_OPERSTATE_OFF] = "off",
[LINK_OPERSTATE_NO_CARRIER] = "no-carrier",
[LINK_OPERSTATE_DORMANT] = "dormant",
[LINK_OPERSTATE_CARRIER] = "carrier",
[LINK_OPERSTATE_DEGRADED] = "degraded",
[LINK_OPERSTATE_ENSLAVED] = "enslaved",
[LINK_OPERSTATE_ROUTABLE] = "routable",
[LINK_OPERSTATE_OFF] = "off",
[LINK_OPERSTATE_NO_CARRIER] = "no-carrier",
[LINK_OPERSTATE_DORMANT] = "dormant",
[LINK_OPERSTATE_DEGRADED_CARRIER] = "degraded-carrier",
[LINK_OPERSTATE_CARRIER] = "carrier",
[LINK_OPERSTATE_DEGRADED] = "degraded",
[LINK_OPERSTATE_ENSLAVED] = "enslaved",
[LINK_OPERSTATE_ROUTABLE] = "routable",
};
DEFINE_STRING_TABLE_LOOKUP(link_operstate, LinkOperationalState);

View File

@ -11,6 +11,7 @@ typedef enum LinkOperationalState {
LINK_OPERSTATE_OFF,
LINK_OPERSTATE_NO_CARRIER,
LINK_OPERSTATE_DORMANT,
LINK_OPERSTATE_DEGRADED_CARRIER,
LINK_OPERSTATE_CARRIER,
LINK_OPERSTATE_DEGRADED,
LINK_OPERSTATE_ENSLAVED,

View File

@ -213,7 +213,7 @@ static int list_links(int argc, char *argv[], void *userdata) {
(void) pager_open(arg_pager_flags);
if (arg_legend)
printf("%3s %-16s %-18s %-11s %-10s\n",
printf("%3s %-16s %-18s %-16s %-10s\n",
"IDX",
"LINK",
"TYPE",
@ -241,7 +241,7 @@ static int list_links(int argc, char *argv[], void *userdata) {
t = link_get_type_string(links[i].iftype, d);
printf("%3i %-16s %-18s %s%-11s%s %s%-10s%s\n",
printf("%3i %-16s %-18s %s%-16s%s %s%-10s%s\n",
links[i].ifindex, links[i].name, strna(t),
on_color_operational, strna(operational_state), off_color_operational,
on_color_setup, strna(setup_state), off_color_setup);

View File

@ -407,15 +407,14 @@ void link_update_operstate(Link *link, bool also_update_master) {
link_is_enslaved(link))
operstate = LINK_OPERSTATE_ENSLAVED;
if (IN_SET(operstate, LINK_OPERSTATE_CARRIER, LINK_OPERSTATE_ENSLAVED, LINK_OPERSTATE_ROUTABLE)) {
if (operstate >= LINK_OPERSTATE_CARRIER) {
Link *slave;
HASHMAP_FOREACH(slave, link->slaves, i) {
link_update_operstate(slave, false);
if (IN_SET(slave->operstate,
LINK_OPERSTATE_OFF, LINK_OPERSTATE_NO_CARRIER, LINK_OPERSTATE_DORMANT))
operstate = LINK_OPERSTATE_DEGRADED;
if (slave->operstate < LINK_OPERSTATE_CARRIER)
operstate = LINK_OPERSTATE_DEGRADED_CARRIER;
}
}

View File

@ -1200,7 +1200,7 @@ class NetworkdNetWorkBondTests(unittest.TestCase, Utilities):
output = subprocess.check_output(['networkctl', 'status', 'bond99']).rstrip().decode('utf-8')
print(output)
self.assertRegex(output, 'State: degraded \(configured\)')
self.assertRegex(output, 'State: degraded-carrier \(configured\)')
self.assertEqual(subprocess.call(['ip', 'link', 'set', 'dummy98', 'up']), 0)
time.sleep(2)
@ -1313,7 +1313,7 @@ class NetworkdNetWorkBridgeTests(unittest.TestCase, Utilities):
time.sleep(3)
output = subprocess.check_output(['networkctl', 'status', 'bridge99']).rstrip().decode('utf-8')
self.assertRegex(output, 'State: degraded \(configured\)')
self.assertRegex(output, 'State: degraded-carrier \(configured\)')
self.assertEqual(subprocess.call(['ip', 'link', 'del', 'dummy98']), 0)
time.sleep(3)