From: Roman Mashak <mrv@mojatatu.com>
To: dsahern@gmail.com
Cc: stephen@networkplumber.org, netdev@vger.kernel.org,
kernel@mojatatu.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com,
jiri@resnulli.us, Roman Mashak <mrv@mojatatu.com>
Subject: [PATCH iproute2-next 1/1] tc: jsonify sample action
Date: Sat, 31 Mar 2018 00:20:45 -0400 [thread overview]
Message-ID: <1522470045-22397-1-git-send-email-mrv@mojatatu.com> (raw)
Signed-off-by: Roman Mashak <mrv@mojatatu.com>
---
tc/m_sample.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/tc/m_sample.c b/tc/m_sample.c
index 1e18c5154fe6..39a99246a8ea 100644
--- a/tc/m_sample.c
+++ b/tc/m_sample.c
@@ -149,23 +149,27 @@ static int print_sample(struct action_util *au, FILE *f, struct rtattr *arg)
if (!tb[TCA_SAMPLE_PARMS] || !tb[TCA_SAMPLE_RATE] ||
!tb[TCA_SAMPLE_PSAMPLE_GROUP]) {
- fprintf(f, "[NULL sample parameters]");
+ print_string(PRINT_FP, NULL, "%s", "[NULL sample parameters]");
return -1;
}
p = RTA_DATA(tb[TCA_SAMPLE_PARMS]);
- fprintf(f, "sample rate 1/%d group %d",
- rta_getattr_u32(tb[TCA_SAMPLE_RATE]),
- rta_getattr_u32(tb[TCA_SAMPLE_PSAMPLE_GROUP]));
+ print_string(PRINT_ANY, "kind", "%s ", "sample");
+ print_uint(PRINT_ANY, "rate", "rate 1/%u ",
+ rta_getattr_u32(tb[TCA_SAMPLE_RATE]));
+ print_uint(PRINT_ANY, "group", "group %u",
+ rta_getattr_u32(tb[TCA_SAMPLE_PSAMPLE_GROUP]));
if (tb[TCA_SAMPLE_TRUNC_SIZE])
- fprintf(f, " trunc_size %d",
- rta_getattr_u32(tb[TCA_SAMPLE_TRUNC_SIZE]));
+ print_uint(PRINT_ANY, "trunc_size", " trunc_size %u",
+ rta_getattr_u32(tb[TCA_SAMPLE_TRUNC_SIZE]));
print_action_control(f, " ", p->action, "");
- fprintf(f, "\n\tindex %d ref %d bind %d", p->index, p->refcnt,
- p->bindcnt);
+ print_string(PRINT_FP, NULL, "%s", _SL_);
+ print_uint(PRINT_ANY, "index", "\t index %u", p->index);
+ print_int(PRINT_ANY, "ref", " ref %d", p->refcnt);
+ print_int(PRINT_ANY, "bind", " bind %d", p->bindcnt);
if (show_stats) {
if (tb[TCA_SAMPLE_TM]) {
@@ -174,7 +178,7 @@ static int print_sample(struct action_util *au, FILE *f, struct rtattr *arg)
print_tm(f, tm);
}
}
- fprintf(f, "\n");
+ print_string(PRINT_FP, NULL, "%s", _SL_);
return 0;
}
--
2.7.4
next reply other threads:[~2018-03-31 4:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-31 4:20 Roman Mashak [this message]
2018-04-01 15:47 ` [PATCH iproute2-next 1/1] tc: jsonify sample action David Ahern
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=1522470045-22397-1-git-send-email-mrv@mojatatu.com \
--to=mrv@mojatatu.com \
--cc=dsahern@gmail.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kernel@mojatatu.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.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