Re: [RFC iproute2] tc/mqprio: json-ify output

Stephen Hemminger
2020-11-28T22:17:58Z

[-- Attachment #1: Type: text/plain, Size: 1624 bytes --]

On Sat, 28 Nov 2020 12:17:00 +0000
Luca Boccassi <bluca@debian.org> wrote:

> On Fri, 2020-11-27 at 21:21 -0800, Stephen Hemminger wrote:
> > On Fri, 27 Nov 2020 15:26:25 +0000
> > Luca Boccassi <bluca@debian.org> wrote:
> >
> > > As reported by a Debian user, mqprio output in json mode is
> > > invalid:
> > >
> > > {
> > >      "kind": "mqprio",
> > >      "handle": "8021:",
> > >      "dev": "enp1s0f0",
> > >      "root": true,
> > >      "options": { tc 2 map 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0
> > >           queues:(0:3) (4:7)
> > >           mode:channel
> > >           shaper:dcb}
> > > }
> > >
> > > json-ify it, while trying to maintain the same formatting
> > > for standard output.
> > >
> > > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=972784
> > >
> > > Signed-off-by: Luca Boccassi <bluca@debian.org>
> >
> > Did you try feeding that into the python parser?
> > What is before/after?
>
> Uh, which python parser?
>
> The reporter tested the patch, there's a small error. Before is above,
> after is:
>
> {
> "kind": "mqprio",
> "handle": "8001:",
> "root": true,
> "options": {
> "tc": 2,
> "map": [ 0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0 ],
> "queues": [
> "": [ 0,3 ],
> "": [ 4,7 ] ],
> "mode": "channel",
> "shaper": "dcb"
> }
> }
>
> Will fix the "queues" to remove the empty name in v2.

Try:
$ tc -j qdisc | pythom -m json.tools

The empty tags are non-standard practice can it be done better?

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]