From: Jakub Kicinski <jakub.kicinski@netronome•com>
To: Stephen Hemminger <stephen@networkplumber•org>
Cc: alexei.starovoitov@gmail•com, daniel@iogearbox•net,
dsahern@gmail•com, netdev@vger•kernel.org,
oss-drivers@netronome•com
Subject: Re: [PATCH iproute2-next] iplink: add support for reporting multiple XDP programs
Date: Fri, 13 Jul 2018 15:59:59 -0700 [thread overview]
Message-ID: <20180713155959.70361b7e@cakuba.lan> (raw)
In-Reply-To: <20180713152330.7a2ec1dc@xeon-e3>
On Fri, 13 Jul 2018 15:23:30 -0700, Stephen Hemminger wrote:
> > > I prefer to not use "printf(fp," and use print_string(PRINT_FP, NULL, "%s", ...)
> > > because otherwise you end up mixing strings and json format output in the
> > > same result.
> > >
> > > You should be able to do
> > > tc -j ...
> > > and always get valid JSON output.
> > >
> > > One quick way to test json validation is to pipe it into python:
> > > tc -j ... | python -mjson.tool
> >
> > Note that XDP has separate print functions for plain text and JSON, and
> > the flow gets separated early on:
> >
> > mode = rta_getattr_u8(tb[IFLA_XDP_ATTACHED]);
> > if (mode == XDP_ATTACHED_NONE)
> > return;
> > else if (is_json_context())
> > return details ? (void)0 : xdp_dump_json(tb);
> >
> > ... non-JSON handling follows...
> >
> > The use of fprintfs is therefore okay. Do you have a preference for
> > using the wrapper, even if fprintf is safe? It's brevity vs
> > consistency, I guess. We'd need a separate patch for that, 'cause I'm
> > not touching all the fprintfs in the file, anyway.
>
> The only preference for the wrapper is that it is easy way to make
> sure all code is JSON aware.
Yes...
> Since fp is always stdout in current code, maybe just convert to printf.
...or maybe we could consider adding a wrapper for printf that wouldn't
take all the unnecessary parameters print_string() takes, yet clearly
indicate autor knows about JSON output concerns?
prev parent reply other threads:[~2018-07-13 23:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-13 20:43 [PATCH iproute2-next] iplink: add support for reporting multiple XDP programs Jakub Kicinski
2018-07-13 20:59 ` Stephen Hemminger
2018-07-13 21:20 ` Jakub Kicinski
2018-07-13 22:23 ` Stephen Hemminger
2018-07-13 22:59 ` Jakub Kicinski [this message]
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=20180713155959.70361b7e@cakuba.lan \
--to=jakub.kicinski@netronome$(echo .)com \
--cc=alexei.starovoitov@gmail$(echo .)com \
--cc=daniel@iogearbox$(echo .)net \
--cc=dsahern@gmail$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=oss-drivers@netronome$(echo .)com \
--cc=stephen@networkplumber$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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