[systemd-commits] 3 commits - src/libsystemd src/network src/systemd TODO
Tom Gundersen
tomegun at kemper.freedesktop.org
Wed Aug 13 06:41:17 PDT 2014
TODO | 2 --
src/libsystemd/sd-network/sd-network.c | 2 --
src/network/networkctl.c | 23 +++++++++++++++++++----
src/network/networkd-link.c | 14 +++++++-------
src/network/networkd-link.h | 2 +-
src/systemd/sd-network.h | 9 +++++++--
6 files changed, 34 insertions(+), 18 deletions(-)
New commits:
commit 4acf8f151f1edc082394950efb52238030c2c6e6
Author: Tom Gundersen <teg at jklm.no>
Date: Wed Aug 13 15:40:59 2014 +0200
TODO
diff --git a/TODO b/TODO
index 27e3794..ebba7ec 100644
--- a/TODO
+++ b/TODO
@@ -31,8 +31,6 @@ Features:
- dhcp and ipv4ll should probably be skipped for "lo" devices, even
if the user has a catchall .network file installed, that might
theoretically match it.
- - when I plug/unplug my wired ethernet the operational state changes
- between "unknown" and "carrier", not "dormant" and "carrier".
- we probably should introduce a new operational state that
indicates that we are trying to acquire some configuration for a
link but haven't acquired any yet. Just to inform the admin that
commit 636db02d54b64fb5bbad86c8015a9ef51299693b
Author: Tom Gundersen <teg at jklm.no>
Date: Wed Aug 13 15:36:11 2014 +0200
networkctl: add colors to admin state and fix alignment
It is useful to color in the admin state both to easily spot failed links, but also to quickly
distinguish between links that are fully configured and in degraded mode (only IPv4LL) or in
degraded mode and still waiting for DHCP.
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 47e918d..731ad27 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -184,7 +184,7 @@ static int list_links(char **args, unsigned n) {
}
if (arg_legend)
- printf("%3s %-16s %-10s %-10s %-10s\n", "IDX", "LINK", "TYPE", "ADMIN", "OPERATIONAL");
+ printf("%3s %-16s %-10s %-11s %-10s\n", "IDX", "LINK", "TYPE", "ADMIN", "OPERATIONAL");
c = decode_and_sort_links(reply, &links);
if (c < 0)
@@ -193,7 +193,8 @@ static int list_links(char **args, unsigned n) {
for (i = 0; i < c; i++) {
_cleanup_free_ char *state = NULL, *operational_state = NULL;
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
- const char *on_color = "", *off_color = "";
+ const char *on_color_oper = "", *off_color_oper = "",
+ *on_color = "", *off_color = "";
char devid[2 + DECIMAL_STR_MAX(int)];
_cleanup_free_ char *t = NULL;
@@ -206,14 +207,28 @@ static int list_links(char **args, unsigned n) {
link_get_type_string(links[i].iftype, d, &t);
if (streq_ptr(operational_state, "routable")) {
+ on_color_oper = ansi_highlight_green();
+ off_color_oper = ansi_highlight_off();
+ } else if (streq_ptr(operational_state, "degraded")) {
+ on_color_oper = ansi_highlight_yellow();
+ off_color_oper = ansi_highlight_off();
+ }
+
+ if (streq_ptr(state, "configured")) {
on_color = ansi_highlight_green();
off_color = ansi_highlight_off();
- } else if (streq_ptr(operational_state, "degraded")) {
+ } else if (streq_ptr(state, "configuring")) {
on_color = ansi_highlight_yellow();
off_color = ansi_highlight_off();
+ } else if (streq_ptr(state, "failed") ||
+ streq_ptr(state, "linger")) {
+ on_color = ansi_highlight_red();
+ off_color = ansi_highlight_off();
}
- printf("%3i %-16s %-10s %-10s %s%-10s%s\n", links[i].ifindex, links[i].name, strna(t), strna(state), on_color, strna(operational_state), off_color);
+ printf("%3i %-16s %-10s %s%-11s%s %s%-10s%s\n", links[i].ifindex,
+ links[i].name, strna(t), on_color, strna(state), off_color,
+ on_color_oper, strna(operational_state), off_color_oper);
}
if (arg_legend)
commit 8434fd5cf23f998a0f3a0f947a4308a8c18ba7a5
Author: Tom Gundersen <teg at jklm.no>
Date: Wed Aug 13 15:34:27 2014 +0200
sd-network: rename state INITALIZING to PENDING and expose as any other state
This is the state when we are waiting for udev to initialize the device, and waiting for
libudev and rtnl to be in sync. In the future we probably will also be waiting for nl80211.
At this point we do not yet have enough information to know whether or not networkd should
be handling the device.
diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c
index d2e608c..1039a2c 100644
--- a/src/libsystemd/sd-network/sd-network.c
+++ b/src/libsystemd/sd-network/sd-network.c
@@ -109,8 +109,6 @@ _public_ int sd_network_get_link_state(int ifindex, char **state) {
return r;
if (isempty(s))
return -ENODATA;
- if (streq(s, "initializing"))
- return -EBUSY;
*state = s;
s = NULL;
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 6a5fe59..398e8ba 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -67,7 +67,7 @@ static int link_new(Manager *manager, sd_rtnl_message *message, Link **ret) {
link->n_ref = 1;
link->manager = manager;
- link->state = LINK_STATE_INITIALIZING;
+ link->state = LINK_STATE_PENDING;
link->ifindex = ifindex;
link->ifname = strdup(ifname);
if (!link->ifname)
@@ -1106,7 +1106,7 @@ static int link_enter_join_netdev(Link *link) {
assert(link);
assert(link->network);
- assert(link->state == LINK_STATE_INITIALIZING);
+ assert(link->state == LINK_STATE_PENDING);
link->state = LINK_STATE_ENSLAVING;
@@ -1196,7 +1196,7 @@ static int link_configure(Link *link) {
assert(link);
assert(link->network);
- assert(link->state == LINK_STATE_INITIALIZING);
+ assert(link->state == LINK_STATE_PENDING);
if (link->network->ipv4ll) {
r = ipv4ll_configure(link);
@@ -1265,7 +1265,7 @@ static int link_initialized_and_synced(sd_rtnl *rtnl, sd_rtnl_message *m,
assert(link->ifname);
assert(link->manager);
- if (link->state != LINK_STATE_INITIALIZING)
+ if (link->state != LINK_STATE_PENDING)
return 1;
log_debug_link(link, "link state is up-to-date");
@@ -1298,7 +1298,7 @@ int link_initialized(Link *link, struct udev_device *device) {
assert(link->manager->rtnl);
assert(device);
- if (link->state != LINK_STATE_INITIALIZING)
+ if (link->state != LINK_STATE_PENDING)
return 0;
if (link->udev_device)
@@ -1509,7 +1509,7 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
if (udev_device_get_is_initialized(device) <= 0) {
/* not yet ready */
- log_debug_link(link, "udev initializing link...");
+ log_debug_link(link, "link pending udev initialization...");
return 0;
}
@@ -1780,7 +1780,7 @@ fail:
}
static const char* const link_state_table[_LINK_STATE_MAX] = {
- [LINK_STATE_INITIALIZING] = "initializing",
+ [LINK_STATE_PENDING] = "pending",
[LINK_STATE_ENSLAVING] = "configuring",
[LINK_STATE_SETTING_ADDRESSES] = "configuring",
[LINK_STATE_SETTING_ROUTES] = "configuring",
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index 144c7c4..6d58fa1 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -24,7 +24,7 @@
#include "networkd.h"
typedef enum LinkState {
- LINK_STATE_INITIALIZING,
+ LINK_STATE_PENDING,
LINK_STATE_ENSLAVING,
LINK_STATE_SETTING_ADDRESSES,
LINK_STATE_SETTING_ROUTES,
diff --git a/src/systemd/sd-network.h b/src/systemd/sd-network.h
index 14373c7..a72e6c4 100644
--- a/src/systemd/sd-network.h
+++ b/src/systemd/sd-network.h
@@ -65,10 +65,15 @@ int sd_network_get_dns(char ***addr);
int sd_network_get_ntp(char ***addr);
/* Get state from ifindex.
- * Possible states: failed, configuring, configured, unmanaged
+ * Possible states:
+ * pending: udev is still processing the link, we don't yet know if we will manage it
+ * failed: networkd failed to manage the link
+ * configuring: in the process of retrieving configuration or configuring the link
+ * configured: link configured successfully
+ * unmanaged: networkd is not handling the link
+ * linger: the link is gone, but has not yet been dropped by networkd
* Possible return codes:
* -ENODATA: networkd is not aware of the link
- * -EBUSY: udev is still processing the link, networkd does not yet know if it will manage it
*/
int sd_network_get_link_state(int ifindex, char **state);
More information about the systemd-commits
mailing list