* [PATCH iproute2 0/5] tc: more JSON fixes
@ 2024-03-12 22:53 Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 1/5] tc: support JSON for legacy stats Stephen Hemminger
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-12 22:53 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
Some more places in TC where JSON output is missing or could
be corrupted. And some things found while reviewing tc-simple
man page.
Stephen Hemminger (5):
tc: support JSON for legacy stats
pedit: log errors to stderr
skbmod: support json in print
simple: support json output
tc-simple.8: take Jamal's prompt off examples
man/man8/tc-simple.8 | 12 ++++++------
tc/m_pedit.c | 6 +++---
tc/m_simple.c | 8 +++++---
tc/m_skbmod.c | 37 +++++++++++++++++++++----------------
tc/tc_util.c | 28 +++++++++++++++-------------
5 files changed, 50 insertions(+), 41 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH iproute2 1/5] tc: support JSON for legacy stats
2024-03-12 22:53 [PATCH iproute2 0/5] tc: more JSON fixes Stephen Hemminger
@ 2024-03-12 22:53 ` Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 2/5] pedit: log errors to stderr Stephen Hemminger
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-12 22:53 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
The extended stats already supported JSON output, add to the
legacy stats as well.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/tc_util.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/tc/tc_util.c b/tc/tc_util.c
index aa7cf60faa6d..615e3e9cc377 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -804,28 +804,30 @@ void print_tcstats_attr(FILE *fp, struct rtattr *tb[], const char *prefix,
memcpy(&st, RTA_DATA(tb[TCA_STATS]),
MIN(RTA_PAYLOAD(tb[TCA_STATS]), sizeof(st)));
- fprintf(fp,
- "%sSent %llu bytes %u pkts (dropped %u, overlimits %u) ",
- prefix, (unsigned long long)st.bytes,
- st.packets, st.drops, st.overlimits);
+ print_string(PRINT_FP, NULL, "%s", prefix);
+ print_lluint(PRINT_ANY, "bytes", "Sent %llu bytes",
+ (unsigned long long)st.bytes);
+ print_uint(PRINT_ANY, "packets", " %u pkts", st.packets);
+ print_uint(PRINT_ANY, "dropped", " (dropped %u,", st.drops);
+ print_uint(PRINT_ANY, "overlimits", " overlimits %u) ", st.overlimits);
if (st.bps || st.pps || st.qlen || st.backlog) {
- fprintf(fp, "\n%s", prefix);
+ print_nl();
+ print_string(PRINT_FP, NULL, "%s", prefix);
+
if (st.bps || st.pps) {
- fprintf(fp, "rate ");
+ print_string(PRINT_FP, NULL, "rate ", NULL);
if (st.bps)
- tc_print_rate(PRINT_FP, NULL, "%s ",
- st.bps);
+ tc_print_rate(PRINT_ANY, "rate", "%s ", st.bps);
if (st.pps)
- fprintf(fp, "%upps ", st.pps);
+ print_uint(PRINT_ANY, "pps", "%upps ", st.pps);
}
if (st.qlen || st.backlog) {
- fprintf(fp, "backlog ");
+ print_string(PRINT_FP, NULL, "backlog ", NULL);
if (st.backlog)
- print_size(PRINT_FP, NULL, "%s ",
- st.backlog);
+ print_size(PRINT_ANY, "backlog", "%s ", st.backlog);
if (st.qlen)
- fprintf(fp, "%up ", st.qlen);
+ print_uint(PRINT_ANY, "qlen", "%up ", st.qlen);
}
}
}
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH iproute2 2/5] pedit: log errors to stderr
2024-03-12 22:53 [PATCH iproute2 0/5] tc: more JSON fixes Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 1/5] tc: support JSON for legacy stats Stephen Hemminger
@ 2024-03-12 22:53 ` Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 3/5] skbmod: support json in print Stephen Hemminger
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-12 22:53 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
The errors should bo to stderr, not to stdout.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/m_pedit.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tc/m_pedit.c b/tc/m_pedit.c
index 32f03415d61c..f954221da393 100644
--- a/tc/m_pedit.c
+++ b/tc/m_pedit.c
@@ -771,20 +771,20 @@ static int print_pedit(struct action_util *au, FILE *f, struct rtattr *arg)
sel = RTA_DATA(tb[TCA_PEDIT_PARMS_EX]);
if (!tb[TCA_PEDIT_KEYS_EX]) {
- fprintf(f, "Netlink error\n");
+ fprintf(stderr, "Netlink error\n");
return -1;
}
keys_ex = calloc(sel->nkeys, sizeof(*keys_ex));
if (!keys_ex) {
- fprintf(f, "Out of memory\n");
+ fprintf(stderr, "Out of memory\n");
return -1;
}
err = pedit_keys_ex_getattr(tb[TCA_PEDIT_KEYS_EX], keys_ex,
sel->nkeys);
if (err) {
- fprintf(f, "Netlink error\n");
+ fprintf(stderr, "Netlink error\n");
free(keys_ex);
return -1;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH iproute2 3/5] skbmod: support json in print
2024-03-12 22:53 [PATCH iproute2 0/5] tc: more JSON fixes Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 1/5] tc: support JSON for legacy stats Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 2/5] pedit: log errors to stderr Stephen Hemminger
@ 2024-03-12 22:53 ` Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 4/5] simple: support json output Stephen Hemminger
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-12 22:53 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
This tc action never got jsonized.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/m_skbmod.c | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/tc/m_skbmod.c b/tc/m_skbmod.c
index b1c8d00dfe47..87de59cf60bb 100644
--- a/tc/m_skbmod.c
+++ b/tc/m_skbmod.c
@@ -177,43 +177,48 @@ static int print_skbmod(struct action_util *au, FILE *f, struct rtattr *arg)
p = RTA_DATA(tb[TCA_SKBMOD_PARMS]);
- fprintf(f, "skbmod ");
+ print_string(PRINT_FP, NULL, "skbmod ", NULL);
print_action_control(f, "", p->action, " ");
if (tb[TCA_SKBMOD_ETYPE]) {
skbmod_etype = rta_getattr_u16(tb[TCA_SKBMOD_ETYPE]);
has_optional = 1;
- fprintf(f, "set etype 0x%X ", skbmod_etype);
+ print_0xhex(PRINT_ANY, "etype", "set etype 0x%X ", skbmod_etype);
}
if (has_optional)
- fprintf(f, "\n\t ");
+ print_string(PRINT_FP, NULL, "%s\t ", _SL_);
if (tb[TCA_SKBMOD_DMAC]) {
has_optional = 1;
- fprintf(f, "set dmac %s ",
- ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_DMAC]),
- RTA_PAYLOAD(tb[TCA_SKBMOD_DMAC]), 0, b1,
- sizeof(b1)));
+ print_color_string(PRINT_ANY, COLOR_MAC, "dmac",
+ "set dmac %s ",
+ ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_DMAC]),
+ RTA_PAYLOAD(tb[TCA_SKBMOD_DMAC]), 0, b1,
+ sizeof(b1)));
}
if (tb[TCA_SKBMOD_SMAC]) {
has_optional = 1;
- fprintf(f, "set smac %s ",
- ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_SMAC]),
- RTA_PAYLOAD(tb[TCA_SKBMOD_SMAC]), 0, b2,
- sizeof(b2)));
+ print_color_string(PRINT_ANY, COLOR_MAC, "smac",
+ "set smac %s ",
+ ll_addr_n2a(RTA_DATA(tb[TCA_SKBMOD_SMAC]),
+ RTA_PAYLOAD(tb[TCA_SKBMOD_SMAC]), 0, b2,
+ sizeof(b2)));
}
if (p->flags & SKBMOD_F_SWAPMAC)
- fprintf(f, "swap mac ");
+ print_null(PRINT_ANY, "swapmac", "swap mac ", NULL);
if (p->flags & SKBMOD_F_ECN)
- fprintf(f, "ecn ");
+ print_null(PRINT_ANY, "ecn", "ecn ", NULL);
+
+ print_nl();
+ 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);
- fprintf(f, "\n\t index %u ref %d bind %d", p->index, p->refcnt,
- p->bindcnt);
if (show_stats) {
if (tb[TCA_SKBMOD_TM]) {
struct tcf_t *tm = RTA_DATA(tb[TCA_SKBMOD_TM]);
@@ -222,7 +227,7 @@ static int print_skbmod(struct action_util *au, FILE *f, struct rtattr *arg)
}
}
- fprintf(f, "\n");
+ print_string(PRINT_FP, NULL, "\n", NULL);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH iproute2 4/5] simple: support json output
2024-03-12 22:53 [PATCH iproute2 0/5] tc: more JSON fixes Stephen Hemminger
` (2 preceding siblings ...)
2024-03-12 22:53 ` [PATCH iproute2 3/5] skbmod: support json in print Stephen Hemminger
@ 2024-03-12 22:53 ` Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 5/5] tc-simple.8: take Jamal's prompt off examples Stephen Hemminger
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-12 22:53 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
Last action that never got JSON support.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/m_simple.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tc/m_simple.c b/tc/m_simple.c
index fe2bca21ae46..6eb60bd8a924 100644
--- a/tc/m_simple.c
+++ b/tc/m_simple.c
@@ -179,9 +179,11 @@ static int print_simple(struct action_util *au, FILE *f, struct rtattr *arg)
simpdata = RTA_DATA(tb[TCA_DEF_DATA]);
- fprintf(f, "Simple <%s>\n", simpdata);
- fprintf(f, "\t index %u ref %d bind %d", sel->index,
- sel->refcnt, sel->bindcnt);
+ print_string(PRINT_ANY, "simple", "Simple <%s>", simpdata);
+ print_nl();
+ print_uint(PRINT_ANY, "index", "\t index %u ", sel->index);
+ print_int(PRINT_ANY, "ref", "ref %d ", sel->refcnt);
+ print_int(PRINT_ANY, "bind","bind %d", sel->bindcnt);
if (show_stats) {
if (tb[TCA_DEF_TM]) {
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH iproute2 5/5] tc-simple.8: take Jamal's prompt off examples
2024-03-12 22:53 [PATCH iproute2 0/5] tc: more JSON fixes Stephen Hemminger
` (3 preceding siblings ...)
2024-03-12 22:53 ` [PATCH iproute2 4/5] simple: support json output Stephen Hemminger
@ 2024-03-12 22:53 ` Stephen Hemminger
2024-03-13 11:08 ` [PATCH iproute2 0/5] tc: more JSON fixes Denis Kirjanov
2024-03-14 0:50 ` patchwork-bot+netdevbpf
6 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-12 22:53 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
The examples on tc-simple man page had extra stuff in
the prompt which is not necessary.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
man/man8/tc-simple.8 | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/man/man8/tc-simple.8 b/man/man8/tc-simple.8
index f565755e5e11..ae1aec31d099 100644
--- a/man/man8/tc-simple.8
+++ b/man/man8/tc-simple.8
@@ -55,11 +55,11 @@ grep the logs to see the logged message
display stats again and observe increment by 1
.EX
- hadi@noma1:$ tc qdisc add dev eth0 ingress
- hadi@noma1:$tc filter add dev eth0 parent ffff: protocol ip prio 5 \\
+ $ tc qdisc add dev eth0 ingress
+ $ tc filter add dev eth0 parent ffff: protocol ip prio 5 \\
u32 match ip protocol 1 0xff flowid 1:1 action simple sdata "Incoming ICMP"
- hadi@noma1:$ sudo tc -s filter ls dev eth0 parent ffff:
+ $ sudo tc -s filter ls dev eth0 parent ffff:
filter protocol ip pref 5 u32
filter protocol ip pref 5 u32 fh 800: ht divisor 1
filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
@@ -71,7 +71,7 @@ display stats again and observe increment by 1
backlog 0b 0p requeues 0
- hadi@noma1$ ping -c 1 www.google.ca
+ $ ping -c 1 www.google.ca
PING www.google.ca (74.125.225.120) 56(84) bytes of data.
64 bytes from ord08s08-in-f24.1e100.net (74.125.225.120): icmp_req=1 ttl=53 time=31.3 ms
@@ -79,10 +79,10 @@ display stats again and observe increment by 1
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 31.316/31.316/31.316/0.000 ms
- hadi@noma1$ dmesg | grep simple
+ $ dmesg | grep simple
[135354.473951] simple: Incoming ICMP_1
- hadi@noma1$ sudo tc/tc -s filter ls dev eth0 parent ffff:
+ $ sudo tc/tc -s filter ls dev eth0 parent ffff:
filter protocol ip pref 5 u32
filter protocol ip pref 5 u32 fh 800: ht divisor 1
filter protocol ip pref 5 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH iproute2 0/5] tc: more JSON fixes
2024-03-12 22:53 [PATCH iproute2 0/5] tc: more JSON fixes Stephen Hemminger
` (4 preceding siblings ...)
2024-03-12 22:53 ` [PATCH iproute2 5/5] tc-simple.8: take Jamal's prompt off examples Stephen Hemminger
@ 2024-03-13 11:08 ` Denis Kirjanov
2024-03-13 17:00 ` Stephen Hemminger
2024-03-14 0:50 ` patchwork-bot+netdevbpf
6 siblings, 1 reply; 9+ messages in thread
From: Denis Kirjanov @ 2024-03-13 11:08 UTC (permalink / raw)
To: Stephen Hemminger, netdev
On 3/13/24 01:53, Stephen Hemminger wrote:
> Some more places in TC where JSON output is missing or could
> be corrupted. And some things found while reviewing tc-simple
> man page.
The series mixes the fixes with new features like json support.
It makes sense to split fixes and new features
>
> Stephen Hemminger (5):
> tc: support JSON for legacy stats
> pedit: log errors to stderr
> skbmod: support json in print
> simple: support json output
> tc-simple.8: take Jamal's prompt off examples
>
> man/man8/tc-simple.8 | 12 ++++++------
> tc/m_pedit.c | 6 +++---
> tc/m_simple.c | 8 +++++---
> tc/m_skbmod.c | 37 +++++++++++++++++++++----------------
> tc/tc_util.c | 28 +++++++++++++++-------------
> 5 files changed, 50 insertions(+), 41 deletions(-)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH iproute2 0/5] tc: more JSON fixes
2024-03-13 11:08 ` [PATCH iproute2 0/5] tc: more JSON fixes Denis Kirjanov
@ 2024-03-13 17:00 ` Stephen Hemminger
0 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-03-13 17:00 UTC (permalink / raw)
To: Denis Kirjanov; +Cc: netdev
On Wed, 13 Mar 2024 14:08:27 +0300
Denis Kirjanov <dkirjanov@suse.de> wrote:
> On 3/13/24 01:53, Stephen Hemminger wrote:
> > Some more places in TC where JSON output is missing or could
> > be corrupted. And some things found while reviewing tc-simple
> > man page.
>
> The series mixes the fixes with new features like json support.
> It makes sense to split fixes and new features
>
> >
> > Stephen Hemminger (5):
> > tc: support JSON for legacy stats
> > pedit: log errors to stderr
> > skbmod: support json in print
> > simple: support json output
> > tc-simple.8: take Jamal's prompt off examples
> >
> > man/man8/tc-simple.8 | 12 ++++++------
> > tc/m_pedit.c | 6 +++---
> > tc/m_simple.c | 8 +++++---
> > tc/m_skbmod.c | 37 +++++++++++++++++++++----------------
> > tc/tc_util.c | 28 +++++++++++++++-------------
> > 5 files changed, 50 insertions(+), 41 deletions(-)
> >
Not supporting JSON is a bug at this point
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH iproute2 0/5] tc: more JSON fixes
2024-03-12 22:53 [PATCH iproute2 0/5] tc: more JSON fixes Stephen Hemminger
` (5 preceding siblings ...)
2024-03-13 11:08 ` [PATCH iproute2 0/5] tc: more JSON fixes Denis Kirjanov
@ 2024-03-14 0:50 ` patchwork-bot+netdevbpf
6 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-14 0:50 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
Hello:
This series was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:
On Tue, 12 Mar 2024 15:53:27 -0700 you wrote:
> Some more places in TC where JSON output is missing or could
> be corrupted. And some things found while reviewing tc-simple
> man page.
>
> Stephen Hemminger (5):
> tc: support JSON for legacy stats
> pedit: log errors to stderr
> skbmod: support json in print
> simple: support json output
> tc-simple.8: take Jamal's prompt off examples
>
> [...]
Here is the summary with links:
- [iproute2,1/5] tc: support JSON for legacy stats
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=fc4226d2475a
- [iproute2,2/5] pedit: log errors to stderr
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=ba52b3d4dd4f
- [iproute2,3/5] skbmod: support json in print
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=af0ddbfa51f9
- [iproute2,4/5] simple: support json output
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=69d55c213da8
- [iproute2,5/5] tc-simple.8: take Jamal's prompt off examples
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=11740815bfe6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-03-14 0:50 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-12 22:53 [PATCH iproute2 0/5] tc: more JSON fixes Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 1/5] tc: support JSON for legacy stats Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 2/5] pedit: log errors to stderr Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 3/5] skbmod: support json in print Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 4/5] simple: support json output Stephen Hemminger
2024-03-12 22:53 ` [PATCH iproute2 5/5] tc-simple.8: take Jamal's prompt off examples Stephen Hemminger
2024-03-13 11:08 ` [PATCH iproute2 0/5] tc: more JSON fixes Denis Kirjanov
2024-03-13 17:00 ` Stephen Hemminger
2024-03-14 0:50 ` patchwork-bot+netdevbpf
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).