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: 2704bd6255 ("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>
This commit is contained in:
Roman Mashak 2020-05-19 20:59:44 -04:00 committed by Stephen Hemminger
parent 1c7aa12104
commit db35e411ec
1 changed files with 11 additions and 15 deletions

View File

@ -750,21 +750,17 @@ void print_tm(FILE *f, const struct tcf_t *tm)
{ {
int hz = get_user_hz(); int hz = get_user_hz();
if (tm->install != 0) { if (tm->install != 0)
print_uint(PRINT_JSON, "installed", NULL, tm->install); print_uint(PRINT_ANY, "installed", " installed %u sec",
print_uint(PRINT_FP, NULL, " installed %u sec", tm->install / hz);
(unsigned int)(tm->install/hz));
} if (tm->lastuse != 0)
if (tm->lastuse != 0) { print_uint(PRINT_ANY, "last_used", " used %u sec",
print_uint(PRINT_JSON, "last_used", NULL, tm->lastuse); tm->lastuse / hz);
print_uint(PRINT_FP, NULL, " used %u sec",
(unsigned int)(tm->lastuse/hz)); if (tm->expires != 0)
} print_uint(PRINT_ANY, "expires", " expires %u sec",
if (tm->expires != 0) { tm->expires / hz);
print_uint(PRINT_JSON, "expires", NULL, tm->expires);
print_uint(PRINT_FP, NULL, " expires %u sec",
(unsigned int)(tm->expires/hz));
}
} }
static void print_tcstats_basic_hw(struct rtattr **tbs, char *prefix) static void print_tcstats_basic_hw(struct rtattr **tbs, char *prefix)