public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Luca Boccassi <bluca@debian.org>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: Re: [RFC iproute2] tc/mqprio: json-ify output
Date: Sat, 28 Nov 2020 17:59:56 +0000	[thread overview]
Message-ID: <9fbd551fd077af9cfced7d6b75b79019caa9547f.camel@debian.org> (raw)
In-Reply-To: <20201128093420.3d9f6aea@hermes.local>

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

On Sat, 2020-11-28 at 09:34 -0800, Stephen Hemminger wrote:
> 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?

Yes, v2 that I sent earlier fixed the empty tags. Python's json.tools
is happy.

The test of v2 from the reporter gave this output:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=972784#27

[{"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"}},{"kind":"pfifo_fast","handle":"0:","parent":"8001:8","options":{"bands":3,"priomap ":[1,2,2,2,1,2,0,0,1,1,1,1,1,1,1,1],"multiqueue":false}},{"kind":"pfifo_fast","handle":"0:","parent":"8001:7","options":{"bands":3,"priomap ":[1,2,2,2,1,2,0,0,1,1,1,1,1,1,1,1],"multiqueue":false}},{"kind":"pfifo_fast","handle":"0:","parent":"8001:6","options":{"bands":3,"priomap ":[1,2,2,2,1,2,0,0,1,1,1,1,1,1,1,1],"multiqueue":false}},{"kind":"pfifo_fast","handle":"0:","parent":"8001:5","options":{"bands":3,"priomap ":[1,2,2,2,1,2,0,0,1,1,1,1,1,1,1,1],"multiqueue":false}},{"kind":"pfifo_fast","handle":"0:","parent":"8001:4","options":{"bands":3,"priomap ":[1,2,2,2,1,2,0,0,1,1,1,1,1,1,1,1],"multiqueue":false}},{"kind":"pfifo_fast","handle":"0:","parent":"8001:3","options":{"bands":3,"priomap ":[1,2,2,2,1,2,0,0,1,1,1,1,1,1,1,1],"multiqueue":false}},{"kind":"pfifo_fast","handle":"0:","parent":"8001:2","options":{"bands":3,"priomap ":[1,2,2,2,1,2,0,0,1,1,1,1,1,1,1,1],"multiqueue":false}},{"kind":"pfifo_fast","handle":"0:","parent":"8001:1","options":{"bands":3,"priomap ":[1,2,2,2,1,2,0,0,1,1,1,1,1,1,1,1],"multiqueue":false}}]

Which when fed to python3 -m json.utils gives:

[
    {
        "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"
        }
    },
    {
        "kind": "pfifo_fast",
        "handle": "0:",
        "parent": "8001:8",
        "options": {
            "bands": 3,
            "priomap ": [
                1,
                2,
                2,
                2,
                1,
                2,
                0,
                0,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1
            ],
            "multiqueue": false
        }
    },
    {
        "kind": "pfifo_fast",
        "handle": "0:",
        "parent": "8001:7",
        "options": {
            "bands": 3,
            "priomap ": [
                1,
                2,
                2,
                2,
                1,
                2,
                0,
                0,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1
            ],
            "multiqueue": false
        }
    },
    {
        "kind": "pfifo_fast",
        "handle": "0:",
        "parent": "8001:6",
        "options": {
            "bands": 3,
            "priomap ": [
                1,
                2,
                2,
                2,
                1,
                2,
                0,
                0,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1
            ],
            "multiqueue": false
        }
    },
    {
        "kind": "pfifo_fast",
        "handle": "0:",
        "parent": "8001:5",
        "options": {
            "bands": 3,
            "priomap ": [
                1,
                2,
                2,
                2,
                1,
                2,
                0,
                0,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1
            ],
            "multiqueue": false
        }
    },
    {
        "kind": "pfifo_fast",
        "handle": "0:",
        "parent": "8001:4",
        "options": {
            "bands": 3,
            "priomap ": [
                1,
                2,
                2,
                2,
                1,
                2,
                0,
                0,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1
            ],
            "multiqueue": false
        }
    },
    {
        "kind": "pfifo_fast",
        "handle": "0:",
        "parent": "8001:3",
        "options": {
            "bands": 3,
            "priomap ": [
                1,
                2,
                2,
                2,
                1,
                2,
                0,
                0,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1
            ],
            "multiqueue": false
        }
    },
    {
        "kind": "pfifo_fast",
        "handle": "0:",
        "parent": "8001:2",
        "options": {
            "bands": 3,
            "priomap ": [
                1,
                2,
                2,
                2,
                1,
                2,
                0,
                0,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1
            ],
            "multiqueue": false
        }
    },
    {
        "kind": "pfifo_fast",
        "handle": "0:",
        "parent": "8001:1",
        "options": {
            "bands": 3,
            "priomap ": [
                1,
                2,
                2,
                2,
                1,
                2,
                0,
                0,
                1,
                1,
                1,
                1,
                1,
                1,
                1,
                1
            ],
            "multiqueue": false
        }
    }
]

-- 
Kind regards,
Luca Boccassi

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-11-28 22:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27 15:26 [RFC iproute2] tc/mqprio: json-ify output Luca Boccassi
2020-11-28  5:21 ` Stephen Hemminger
2020-11-28 12:17   ` Luca Boccassi
2020-11-28 17:34     ` Stephen Hemminger
2020-11-28 17:59       ` Luca Boccassi [this message]
2020-11-28 12:21 ` [PATCH iproute2 v2] " Luca Boccassi
2020-11-28 15:24   ` Luca Boccassi
2020-11-28 18:30 ` Luca Boccassi
2020-12-02 16:42   ` David Ahern
2020-12-02 17:09     ` Luca Boccassi
2020-12-02 17:08   ` [PATCH v3] " luca.boccassi
2020-12-03 16:40     ` patchwork-bot+netdevbpf

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=9fbd551fd077af9cfced7d6b75b79019caa9547f.camel@debian.org \
    --to=bluca@debian.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox