summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-20 22:12:14 +0100
committerLennart Poettering <lennart@poettering.net>2016-02-21 20:40:57 +0100
commit33d5013db09729d3453d60a1a194016e27ef4fab (patch)
tree709eccdabc2035881a7ec9dfcddd7e1ddba42fe5 /src
parent5f02f341c08c2a1cd05cc5066ca94bc6aa43243c (diff)
networkctl: if there's no data from networkd about an iface show as "unmanaged"
After all, if we know that an interface exists but networkd did not store any info about it, then it's definitely unmanaged by it. (Note that we add this fix-up to networkctl, and not to sd-network, simply because a missing file might also be result of the interface not existing.)
Diffstat (limited to 'src')
-rw-r--r--src/network/networkctl.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 21ad776d0d..b7b3b51325 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -321,7 +321,9 @@ static int list_links(int argc, char *argv[], void *userdata) {
(void) sd_network_link_get_operational_state(links[i].ifindex, &operational_state);
operational_state_to_color(operational_state, &on_color_operational, &off_color_operational);
- (void) sd_network_link_get_setup_state(links[i].ifindex, &setup_state);
+ 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 */
+ setup_state = strdup("unmanaged");
setup_state_to_color(setup_state, &on_color_setup, &off_color_setup);
xsprintf(devid, "n%i", links[i].ifindex);
@@ -722,7 +724,9 @@ static int link_status_one(
(void) sd_network_link_get_operational_state(info->ifindex, &operational_state);
operational_state_to_color(operational_state, &on_color_operational, &off_color_operational);
- (void) sd_network_link_get_setup_state(info->ifindex, &setup_state);
+ 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 */
+ setup_state = strdup("unmanaged");
setup_state_to_color(setup_state, &on_color_setup, &off_color_setup);
(void) sd_network_link_get_dns(info->ifindex, &dns);