]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkctl: if there's no data from networkd about an iface show as "unmanaged"
authorLennart Poettering <lennart@poettering.net>
Sat, 20 Feb 2016 21:12:14 +0000 (22:12 +0100)
committerLennart Poettering <lennart@poettering.net>
Sun, 21 Feb 2016 19:40:57 +0000 (20:40 +0100)
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.)

src/network/networkctl.c

index 21ad776d0dfa4107cb991f5641230a1aaf54dc83..b7b3b51325c85ef63d1f45b4ab3f75e39294b380 100644 (file)
@@ -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);