From: Zbigniew Jędrzejewski-Szmek Date: Wed, 23 Oct 2019 09:10:32 +0000 (+0200) Subject: networkctl: show carrier in green for loopback iface X-Git-Tag: v244~204^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ceb366df29c2541f333b1ca3e75a4dda75dd0cf7;p=platform%2Fupstream%2Fsystemd.git 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. --- diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 5e8dce0..7c8f25f 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)