From: Stephen Hemminger <stephen@networkplumber.org>
To: Puneet Sharma <pusharma@akamai.com>
Cc: dsahern@kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] tc: add print options to fix json output
Date: Thu, 29 Oct 2020 13:17:18 -0700 [thread overview]
Message-ID: <20201029131718.39b87b03@hermes.local> (raw)
In-Reply-To: <20201028183554.18078-1-pusharma@akamai.com>
On Wed, 28 Oct 2020 14:35:54 -0400
Puneet Sharma <pusharma@akamai.com> wrote:
> Currently, json for basic rules output does not produce correct json
> syntax. The following fixes were done to correct it for extended
> matches for use with "basic" filters.
>
> tc/f_basic.c: replace fprintf with print_uint to support json output.
> fixing this prints "handle" tag correctly in json output.
>
> tc/m_ematch.c: replace various fprintf with correct print.
> add new "ematch" tag for json output which represents
> "tc filter add ... basic match '()'" string. Added print_raw_string
> to print raw string instead of key value for json.
>
> lib/json_writer.c: add jsonw_raw_string to print raw text in json.
>
> lib/json_print.c: add print_color_raw_string to print string
> depending on context.
>
> example:
> $ tc -s -d -j filter show dev <eth_name> ingress
> Before:
> ...
> "options": {handle 0x2
> (
> cmp(u8 at 9 layer 1 eq 6)
> OR cmp(u8 at 9 layer 1 eq 17)
> ) AND ipset(test-ipv4 src)
>
> "actions": [{
> ...
>
> After:
> [{
> ...
> "options": {
> "handle": 1,
> "ematch": "(cmp(u8 at 9 layer 1 eq 6)OR cmp(u8 at 9 layer 1 eq 17)) AND ipset(test-ipv4 src)",
> ...
> ]
>
> Signed-off-by: Puneet Sharma <pusharma@akamai.com>
> ---
What is the point of introducing raw string?
The JSON standard says that string fields must use proper escapes.
Please don't emit invalid JSON. It will break consumption by other libraries.
next prev parent reply other threads:[~2020-10-29 20:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-28 18:35 [PATCH iproute2] tc: add print options to fix json output Puneet Sharma
2020-10-29 20:17 ` Stephen Hemminger [this message]
[not found] ` <2B38A297-343E-4DD0-93E2-87F8B2AC1E26@akamai.com>
2020-10-29 23:16 ` Stephen Hemminger
2020-10-30 0:42 ` Sharma, Puneet
2020-10-30 2:47 ` 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=20201029131718.39b87b03@hermes.local \
--to=stephen@networkplumber.org \
--cc=dsahern@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pusharma@akamai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.