* [PATCH iproute2 1/1] tc: action: fix time values output in JSON format
@ 2020-05-18 17:29 Roman Mashak
2020-05-19 21:29 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: Roman Mashak @ 2020-05-18 17:29 UTC (permalink / raw)
To: stephen
Cc: dsahern, netdev, kernel, jhs, xiyou.wangcong, jiri, Roman Mashak,
Jiri Pirko
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));
}
if (tm->lastuse != 0) {
- print_uint(PRINT_JSON, "last_used", NULL, tm->lastuse);
+ print_uint(PRINT_JSON, "last_used", NULL,
+ (unsigned int)(tm->lastuse/hz));
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_JSON, "expires", NULL,
+ (unsigned int)(tm->expires/hz));
print_uint(PRINT_FP, NULL, " expires %u sec",
(unsigned int)(tm->expires/hz));
}
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH iproute2 1/1] tc: action: fix time values output in JSON format
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
2020-05-19 22:09 ` Roman Mashak
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2020-05-19 21:29 UTC (permalink / raw)
To: Roman Mashak
Cc: dsahern, netdev, kernel, jhs, xiyou.wangcong, jiri, Jiri Pirko
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);
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH iproute2 1/1] tc: action: fix time values output in JSON format
2020-05-19 21:29 ` Stephen Hemminger
@ 2020-05-19 22:09 ` Roman Mashak
0 siblings, 0 replies; 3+ messages in thread
From: Roman Mashak @ 2020-05-19 22:09 UTC (permalink / raw)
To: Stephen Hemminger
Cc: dsahern, netdev, kernel, jhs, xiyou.wangcong, jiri, Jiri Pirko
Stephen Hemminger <stephen@networkplumber.org> writes:
> 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.
>
Thanks Stephen. I will send v2.
> 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();
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-19 22:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2020-05-19 22:09 ` Roman Mashak
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).