]> git.ipfire.org Git - thirdparty/iproute2.git/commit
devlink: fix JSON output of mon command
authorJiri Pirko <jiri@mellanox.com>
Thu, 9 Apr 2020 18:29:51 +0000 (20:29 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 13 Apr 2020 20:59:12 +0000 (13:59 -0700)
commitc4dfddccef4e092065d7bb696d64bb46f4223567
tree2d71f18e559dc4dfb7d50f6b6c83d7fc5ba25cba
parent5c762c3bc226cbfc2d7384b46985a885267961a7
devlink: fix JSON output of mon command

The current JSON output of mon command is broken. Fix it and make sure
that the output is a valid JSON. Also, handle SIGINT gracefully to allow
to end the JSON properly.

Example:
$ devlink mon -j -p
{
    "mon": [ {
            "command": "new",
            "dev": {
                "netdevsim/netdevsim10": {}
            }
        },{
            "command": "new",
            "port": {
                "netdevsim/netdevsim10/0": {
                    "type": "notset",
                    "flavour": "physical",
                    "port": 1
                }
            }
        },{
            "command": "new",
            "port": {
                "netdevsim/netdevsim10/0": {
                    "type": "eth",
                    "netdev": "eth0",
                    "flavour": "physical",
                    "port": 1
                }
            }
        },{
            "command": "new",
            "port": {
                "netdevsim/netdevsim10/0": {
                    "type": "notset",
                    "flavour": "physical",
                    "port": 1
                }
            }
        },{
            "command": "del",
            "port": {
                "netdevsim/netdevsim10/0": {
                    "type": "notset",
                    "flavour": "physical",
                    "port": 1
                }
            }
        },{
            "command": "del",
            "dev": {
                "netdevsim/netdevsim10": {}
            }
        } ]
}

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
devlink/devlink.c