aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Mashak <mrv@mojatatu.com>2020-05-19 20:59:44 -0400
committerStephen Hemminger <stephen@networkplumber.org>2020-05-19 21:19:04 -0700
commitdb35e411ec17bf9da67f22f995fe1e8d5edcda98 (patch)
tree87ca6da5e34a845ceea3ec36cc26bff2effcd03d
parent1c7aa121045c5e4de17b7e8a909c158c975b8578 (diff)
downloadiproute2-db35e411ec17bf9da67f22f995fe1e8d5edcda98.tar.gz
tc: action: fix time values output in JSON format
Report tcf_t values in seconds, not jiffies, in JSON format as it is now for stdout. v2: use PRINT_ANY, drop the useless casts and fix the style (Stephen Hemminger) Fixes: 2704bd625583 ("tc: jsonify actions core") Cc: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Roman Mashak <mrv@mojatatu.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
-rw-r--r--tc/tc_util.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 12f865cc7..fd5fcb242 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -750,21 +750,17 @@ void print_tm(FILE *f, const struct tcf_t *tm)
{
int hz = get_user_hz();
- if (tm->install != 0) {
- print_uint(PRINT_JSON, "installed", NULL, tm->install);
- print_uint(PRINT_FP, NULL, " installed %u sec",
- (unsigned int)(tm->install/hz));
- }
- if (tm->lastuse != 0) {
- print_uint(PRINT_JSON, "last_used", NULL, tm->lastuse);
- print_uint(PRINT_FP, NULL, " used %u sec",
- (unsigned int)(tm->lastuse/hz));
- }
- if (tm->expires != 0) {
- print_uint(PRINT_JSON, "expires", NULL, tm->expires);
- print_uint(PRINT_FP, NULL, " expires %u sec",
- (unsigned int)(tm->expires/hz));
- }
+ if (tm->install != 0)
+ print_uint(PRINT_ANY, "installed", " installed %u sec",
+ tm->install / hz);
+
+ if (tm->lastuse != 0)
+ print_uint(PRINT_ANY, "last_used", " used %u sec",
+ tm->lastuse / hz);
+
+ if (tm->expires != 0)
+ print_uint(PRINT_ANY, "expires", " expires %u sec",
+ tm->expires / hz);
}
static void print_tcstats_basic_hw(struct rtattr **tbs, char *prefix)