From: Stephen Hemminger <stephen@networkplumber.org>
To: Roman Mashak <mrv@mojatatu.com>
Cc: dsahern@gmail.com, netdev@vger.kernel.org, kernel@mojatatu.com,
jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
Jiri Pirko <jiri@mellanox.com>
Subject: Re: [PATCH iproute2 1/1] tc: action: fix time values output in JSON format
Date: Tue, 19 May 2020 14:29:25 -0700 [thread overview]
Message-ID: <20200519142925.282bf732@hermes.lan> (raw)
In-Reply-To: <1589822958-30545-1-git-send-email-mrv@mojatatu.com>
On Mon, 18 May 2020 13:29:18 -0400
Roman Mashak <mrv@mojatatu.com> wrote:
> Report tcf_t values in seconds, not jiffies, in JSON format as it is now
> for stdout.
>
> Fixes: 2704bd625583 ("tc: jsonify actions core")
> Cc: Jiri Pirko <jiri@mellanox.com>
> Signed-off-by: Roman Mashak <mrv@mojatatu.com>
> ---
> tc/tc_util.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tc/tc_util.c b/tc/tc_util.c
> index 12f865cc71bf..118e19da35bb 100644
> --- a/tc/tc_util.c
> +++ b/tc/tc_util.c
> @@ -751,17 +751,20 @@ 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_JSON, "installed", NULL,
> + (unsigned int)(tm->install/hz));
> print_uint(PRINT_FP, NULL, " installed %u sec",
> (unsigned int)(tm->install/hz));
> }
Please use PRINT_ANY, drop the useless casts and fix the style.
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 12f865cc71bf..fd5fcb242b64 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);
}
next prev parent reply other threads:[~2020-05-19 21:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-18 17:29 [PATCH iproute2 1/1] tc: action: fix time values output in JSON format Roman Mashak
2020-05-19 21:29 ` Stephen Hemminger [this message]
2020-05-19 22:09 ` Roman Mashak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200519142925.282bf732@hermes.lan \
--to=stephen@networkplumber.org \
--cc=dsahern@gmail.com \
--cc=jhs@mojatatu.com \
--cc=jiri@mellanox.com \
--cc=jiri@resnulli.us \
--cc=kernel@mojatatu.com \
--cc=mrv@mojatatu.com \
--cc=netdev@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).