summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-23 11:10:32 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-23 11:10:32 +0200
commitceb366df29c2541f333b1ca3e75a4dda75dd0cf7 (patch)
treefc5e1fda4780e7b408e62fddec002d05564f3c04
parent277ba8d1ab968f4c699c623a6bb17bd3b5fd17eb (diff)
downloadsystemd-ceb366df29c2541f333b1ca3e75a4dda75dd0cf7.tar.gz
networkctl: show carrier in green for loopback iface
We don't ever expect anything different, so let's hightlight that carrier in this case is OK.
-rw-r--r--src/network/networkctl.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 5e8dce0b73..7c8f25ffae 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -76,11 +76,12 @@ static char *link_get_type_string(unsigned short iftype, sd_device *d) {
return p;
}
-static void operational_state_to_color(const char *state, const char **on, const char **off) {
+static void operational_state_to_color(const char *name, const char *state, const char **on, const char **off) {
assert(on);
assert(off);
- if (STRPTR_IN_SET(state, "routable", "enslaved")) {
+ if (STRPTR_IN_SET(state, "routable", "enslaved") ||
+ (streq_ptr(name, "lo") && streq_ptr(state, "carrier"))) {
*on = ansi_highlight_green();
*off = ansi_normal();
} else if (streq_ptr(state, "degraded")) {
@@ -442,7 +443,7 @@ static int list_links(int argc, char *argv[], void *userdata) {
_cleanup_free_ char *t = NULL;
(void) sd_network_link_get_operational_state(links[i].ifindex, &operational_state);
- operational_state_to_color(operational_state, &on_color_operational, &off_color_operational);
+ operational_state_to_color(links[i].name, operational_state, &on_color_operational, &off_color_operational);
r = sd_network_link_get_setup_state(links[i].ifindex, &setup_state);
if (r == -ENODATA) /* If there's no info available about this iface, it's unmanaged by networkd */
@@ -1013,7 +1014,7 @@ static int link_status_one(
assert(info);
(void) sd_network_link_get_operational_state(info->ifindex, &operational_state);
- operational_state_to_color(operational_state, &on_color_operational, &off_color_operational);
+ operational_state_to_color(info->name, operational_state, &on_color_operational, &off_color_operational);
r = sd_network_link_get_setup_state(info->ifindex, &setup_state);
if (r == -ENODATA) /* If there's no info available about this iface, it's unmanaged by networkd */
@@ -1368,7 +1369,7 @@ static int system_status(sd_netlink *rtnl, sd_hwdb *hwdb) {
assert(rtnl);
(void) sd_network_get_operational_state(&operational_state);
- operational_state_to_color(operational_state, &on_color_operational, &off_color_operational);
+ operational_state_to_color(NULL, operational_state, &on_color_operational, &off_color_operational);
table = table_new("dot", "key", "value");
if (!table)