diff options
author | Stephen Hemminger <stephen@networkplumber.org> | 2022-12-01 07:30:54 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen@networkplumber.org> | 2022-12-01 07:30:54 -0800 |
commit | d4b01c0f4187e5c7c902223d96f845b8d21ce03c (patch) | |
tree | fa634cf7820f5b89a7ce9b543d28a59d1672d064 /tc | |
parent | f38059746dcd9184ed131a01dc30858b64a9306a (diff) | |
download | iproute2-d4b01c0f4187e5c7c902223d96f845b8d21ce03c.tar.gz |
tc/basic: fix json output filter
The flowid and handle in basic were not using JSON routines to print.
To reproduce the issue:
$ tc qdisc add dev eth1 handle ffff: ingress
$ tc filter add dev eth1 parent ffff: prio 20 protocol all u32 match ip dport 22 \
0xffff action police conform-exceed drop/ok rate 100000 burst 15k flowid ffff:1
$ tc filter add dev eth1 parent ffff: prio 255 protocol all basic action police \
conform-exceed drop/ok rate 100000 burst 15k flowid ffff:3
Reported-by: Christian Pössinger <christian@poessinger.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Diffstat (limited to 'tc')
-rw-r--r-- | tc/f_basic.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tc/f_basic.c b/tc/f_basic.c index 9a60758e..9055370e 100644 --- a/tc/f_basic.c +++ b/tc/f_basic.c @@ -119,19 +119,22 @@ static int basic_print_opt(struct filter_util *qu, FILE *f, parse_rtattr_nested(tb, TCA_BASIC_MAX, opt); if (handle) - fprintf(f, "handle 0x%x ", handle); + print_hex(PRINT_ANY, "handle", + "handle 0x%x ", handle); if (tb[TCA_BASIC_CLASSID]) { + uint32_t classid = rta_getattr_u32(tb[TCA_BASIC_CLASSID]); SPRINT_BUF(b1); - fprintf(f, "flowid %s ", - sprint_tc_classid(rta_getattr_u32(tb[TCA_BASIC_CLASSID]), b1)); + + print_string(PRINT_ANY, "flowid", "flowid %s ", + sprint_tc_classid(classid, b1)); } if (tb[TCA_BASIC_EMATCHES]) print_ematch(f, tb[TCA_BASIC_EMATCHES]); if (tb[TCA_BASIC_POLICE]) { - fprintf(f, "\n"); + print_nl(); tc_print_police(f, tb[TCA_BASIC_POLICE]); } |