chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
networkd: log when finished enumerating links and addresses
[elogind.git]
/
src
/
network
/
networkctl.c
diff --git
a/src/network/networkctl.c
b/src/network/networkctl.c
index 15dfb81e2a260cde3af8344fc4cb7544c6825dba..aa83f32f5371d7ed35b5e0387a1bfd5271e33fad 100644
(file)
--- a/
src/network/networkctl.c
+++ b/
src/network/networkctl.c
@@
-898,9
+898,8
@@
static int link_lldp_status(int argc, char *argv[], void *userdata) {
_cleanup_free_ LinkInfo *links = NULL;
const char *state, *word;
_cleanup_free_ LinkInfo *links = NULL;
const char *state, *word;
-
usec_t time, until, ttl
;
+
double ttl = -1
;
uint32_t capability;
uint32_t capability;
- char buf[LINE_MAX];
int i, r, c, j;
size_t ll;
char **s;
int i, r, c, j;
size_t ll;
char **s;
@@
-955,27
+954,29
@@
static int link_lldp_status(int argc, char *argv[], void *userdata) {
continue;
if (streq(a, "_Chassis")) {
continue;
if (streq(a, "_Chassis")) {
-
- memzero(buf, LINE_MAX);
-
chassis = strdup(b);
if (!chassis)
return -ENOMEM;
} else if (streq(a, "_Port")) {
chassis = strdup(b);
if (!chassis)
return -ENOMEM;
} else if (streq(a, "_Port")) {
-
port = strdup(b);
if (!port)
return -ENOMEM;
} else if (streq(a, "_TTL")) {
port = strdup(b);
if (!port)
return -ENOMEM;
} else if (streq(a, "_TTL")) {
+ long long unsigned x;
+ usec_t time;
- time = now(CLOCK_BOOTTIME);
-
- sscanf(b, "%lu", &until);
+ r = safe_atollu(b, &x);
+ if (r < 0 || (usec_t) x != x)
+ return log_warning_errno(r < 0 ? r : ERANGE,
+ "Failed to parse TTL \"%s\": %m", b);
- ttl = (until - time) / USEC_PER_SEC;
+ time = now(CLOCK_BOOTTIME);
+ if (x < time)
+ continue;
+ ttl = (double) (x - time) / USEC_PER_SEC;
} else if (streq(a, "_CAP")) {
sscanf(b, "%x", &capability);
} else if (streq(a, "_CAP")) {
sscanf(b, "%x", &capability);
@@
-985,8
+986,11
@@
static int link_lldp_status(int argc, char *argv[], void *userdata) {
}
}
- if (until > time) {
- printf("%10s %24s %16s %16lu %16s\n", links[i].name, chassis, port, ttl, cap);
+ if (ttl >= 0) {
+ printf("%10s %24s %16s %16f %16s\n",
+ links[i].name,
+ strna(chassis), strna(port),
+ ttl, cap);
j++;
}
}
j++;
}
}
@@
-1014,7
+1018,7
@@
static void help(void) {
" -a --all Show status for all links\n\n"
"Commands:\n"
" list List links\n"
" -a --all Show status for all links\n\n"
"Commands:\n"
" list List links\n"
- " status
LINK
Show link status\n"
+ " status
[LINK...]
Show link status\n"
" lldp Show lldp information\n"
, program_invocation_short_name);
}
" lldp Show lldp information\n"
, program_invocation_short_name);
}