mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +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:
parent
2cd6b9326c
commit
c9cc038343
@ -115,6 +115,13 @@
|
|||||||
<para>the device has a carrier, but is not yet ready for normal traffic</para>
|
<para>the device has a carrier, but is not yet ready for normal traffic</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</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>
|
<varlistentry>
|
||||||
<term>carrier</term>
|
<term>carrier</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -125,9 +132,7 @@
|
|||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>degraded</term>
|
<term>degraded</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>the link has carrier and addresses valid on the local link configured, or for bond
|
<para>the link has carrier and addresses valid on the local link configured</para>
|
||||||
or bridge master, one of the bonding or bridge slave network interfaces is in off,
|
|
||||||
no-carrier, or dormant</para>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
@ -24,6 +24,7 @@ static const char* const link_operstate_table[_LINK_OPERSTATE_MAX] = {
|
|||||||
[LINK_OPERSTATE_OFF] = "off",
|
[LINK_OPERSTATE_OFF] = "off",
|
||||||
[LINK_OPERSTATE_NO_CARRIER] = "no-carrier",
|
[LINK_OPERSTATE_NO_CARRIER] = "no-carrier",
|
||||||
[LINK_OPERSTATE_DORMANT] = "dormant",
|
[LINK_OPERSTATE_DORMANT] = "dormant",
|
||||||
|
[LINK_OPERSTATE_DEGRADED_CARRIER] = "degraded-carrier",
|
||||||
[LINK_OPERSTATE_CARRIER] = "carrier",
|
[LINK_OPERSTATE_CARRIER] = "carrier",
|
||||||
[LINK_OPERSTATE_DEGRADED] = "degraded",
|
[LINK_OPERSTATE_DEGRADED] = "degraded",
|
||||||
[LINK_OPERSTATE_ENSLAVED] = "enslaved",
|
[LINK_OPERSTATE_ENSLAVED] = "enslaved",
|
||||||
|
@ -11,6 +11,7 @@ typedef enum LinkOperationalState {
|
|||||||
LINK_OPERSTATE_OFF,
|
LINK_OPERSTATE_OFF,
|
||||||
LINK_OPERSTATE_NO_CARRIER,
|
LINK_OPERSTATE_NO_CARRIER,
|
||||||
LINK_OPERSTATE_DORMANT,
|
LINK_OPERSTATE_DORMANT,
|
||||||
|
LINK_OPERSTATE_DEGRADED_CARRIER,
|
||||||
LINK_OPERSTATE_CARRIER,
|
LINK_OPERSTATE_CARRIER,
|
||||||
LINK_OPERSTATE_DEGRADED,
|
LINK_OPERSTATE_DEGRADED,
|
||||||
LINK_OPERSTATE_ENSLAVED,
|
LINK_OPERSTATE_ENSLAVED,
|
||||||
|
@ -213,7 +213,7 @@ static int list_links(int argc, char *argv[], void *userdata) {
|
|||||||
(void) pager_open(arg_pager_flags);
|
(void) pager_open(arg_pager_flags);
|
||||||
|
|
||||||
if (arg_legend)
|
if (arg_legend)
|
||||||
printf("%3s %-16s %-18s %-11s %-10s\n",
|
printf("%3s %-16s %-18s %-16s %-10s\n",
|
||||||
"IDX",
|
"IDX",
|
||||||
"LINK",
|
"LINK",
|
||||||
"TYPE",
|
"TYPE",
|
||||||
@ -241,7 +241,7 @@ static int list_links(int argc, char *argv[], void *userdata) {
|
|||||||
|
|
||||||
t = link_get_type_string(links[i].iftype, d);
|
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),
|
links[i].ifindex, links[i].name, strna(t),
|
||||||
on_color_operational, strna(operational_state), off_color_operational,
|
on_color_operational, strna(operational_state), off_color_operational,
|
||||||
on_color_setup, strna(setup_state), off_color_setup);
|
on_color_setup, strna(setup_state), off_color_setup);
|
||||||
|
@ -407,15 +407,14 @@ void link_update_operstate(Link *link, bool also_update_master) {
|
|||||||
link_is_enslaved(link))
|
link_is_enslaved(link))
|
||||||
operstate = LINK_OPERSTATE_ENSLAVED;
|
operstate = LINK_OPERSTATE_ENSLAVED;
|
||||||
|
|
||||||
if (IN_SET(operstate, LINK_OPERSTATE_CARRIER, LINK_OPERSTATE_ENSLAVED, LINK_OPERSTATE_ROUTABLE)) {
|
if (operstate >= LINK_OPERSTATE_CARRIER) {
|
||||||
Link *slave;
|
Link *slave;
|
||||||
|
|
||||||
HASHMAP_FOREACH(slave, link->slaves, i) {
|
HASHMAP_FOREACH(slave, link->slaves, i) {
|
||||||
link_update_operstate(slave, false);
|
link_update_operstate(slave, false);
|
||||||
|
|
||||||
if (IN_SET(slave->operstate,
|
if (slave->operstate < LINK_OPERSTATE_CARRIER)
|
||||||
LINK_OPERSTATE_OFF, LINK_OPERSTATE_NO_CARRIER, LINK_OPERSTATE_DORMANT))
|
operstate = LINK_OPERSTATE_DEGRADED_CARRIER;
|
||||||
operstate = LINK_OPERSTATE_DEGRADED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1200,7 +1200,7 @@ class NetworkdNetWorkBondTests(unittest.TestCase, Utilities):
|
|||||||
|
|
||||||
output = subprocess.check_output(['networkctl', 'status', 'bond99']).rstrip().decode('utf-8')
|
output = subprocess.check_output(['networkctl', 'status', 'bond99']).rstrip().decode('utf-8')
|
||||||
print(output)
|
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)
|
self.assertEqual(subprocess.call(['ip', 'link', 'set', 'dummy98', 'up']), 0)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
@ -1313,7 +1313,7 @@ class NetworkdNetWorkBridgeTests(unittest.TestCase, Utilities):
|
|||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
|
||||||
output = subprocess.check_output(['networkctl', 'status', 'bridge99']).rstrip().decode('utf-8')
|
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)
|
self.assertEqual(subprocess.call(['ip', 'link', 'del', 'dummy98']), 0)
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
|
Loading…
Reference in New Issue
Block a user