summaryrefslogtreecommitdiff
path: root/src/network/networkd-manager.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-05-19 20:44:21 +0200
committerTom Gundersen <teg@jklm.no>2014-05-19 20:44:21 +0200
commite375dcde7202d5df4e29f5258e0f8c2bcea4535c (patch)
tree68b487f54d01cc0fafc6db3364620266435b1171 /src/network/networkd-manager.c
parentbcb7a07e0a785bda1eed658e984ff6b4a11cba9a (diff)
networkd/sd-network: extend operational states
Expose states 'degraded' or 'routable' if a link has a site/link-local or a routable address, respectively.
Diffstat (limited to 'src/network/networkd-manager.c')
-rw-r--r--src/network/networkd-manager.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 2e3b4bb885..c4a325de42 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -424,8 +424,8 @@ int manager_save(Manager *m) {
Iterator i;
_cleanup_free_ char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
- const char *oper_state = "unknown";
- bool dormant = false, carrier = false;
+ LinkOperationalState operstate = LINK_OPERSTATE_UNKNOWN;
+ const char *operstate_str;
int r;
assert(m);
@@ -435,16 +435,12 @@ int manager_save(Manager *m) {
if (link->flags & IFF_LOOPBACK)
continue;
- if (link_has_carrier(link->flags, link->operstate))
- carrier = true;
- else if (link->operstate == IF_OPER_DORMANT)
- dormant = true;
+ if (link->operstate > operstate)
+ operstate = link->operstate;
}
- if (carrier)
- oper_state = "carrier";
- else if (dormant)
- oper_state = "dormant";
+ operstate_str = link_operstate_to_string(operstate);
+ assert(operstate_str);
r = fopen_temporary(m->state_file, &f, &temp_path);
if (r < 0)
@@ -454,7 +450,7 @@ int manager_save(Manager *m) {
fprintf(f,
"# This is private data. Do not parse.\n"
- "OPER_STATE=%s\n", oper_state);
+ "OPER_STATE=%s\n", operstate_str);
fflush(f);