iproute2/ip
Matteo Croce 0736617738 ip route: print route type in JSON output
ip route generates an invalid JSON if the route type has to be printed,
eg. when detailed mode is active, or the type is different that unicast:

    $ ip -d -j -p route show
    [ {"unicast",
            "dst": "192.168.122.0/24",
            "dev": "virbr0",
            "protocol": "kernel",
            "scope": "link",
            "prefsrc": "192.168.122.1",
            "flags": [ "linkdown" ]
        } ]

    $ ip -j -p route show
    [ {"unreachable",
            "dst": "192.168.23.0/24",
            "flags": [ ]
        },{"prohibit",
            "dst": "192.168.24.0/24",
            "flags": [ ]
        },{"blackhole",
            "dst": "192.168.25.0/24",
            "flags": [ ]
        } ]

Fix it by printing the route type as the "type" attribute:

    $ ip -d -j -p route show
    [ {
            "type": "unicast",
            "dst": "default",
            "gateway": "192.168.85.1",
            "dev": "wlp3s0",
            "protocol": "dhcp",
            "scope": "global",
            "metric": 600,
            "flags": [ ]
        },{
            "type": "unreachable",
            "dst": "192.168.23.0/24",
            "protocol": "boot",
            "scope": "global",
            "flags": [ ]
        },{
            "type": "prohibit",
            "dst": "192.168.24.0/24",
            "protocol": "boot",
            "scope": "global",
            "flags": [ ]
        },{
            "type": "blackhole",
            "dst": "192.168.25.0/24",
            "protocol": "boot",
            "scope": "global",
            "flags": [ ]
        } ]

Fixes: 663c3cb231 ("iproute: implement JSON and color output")
Acked-by: Phil Sutter <phil@nwl.cc>
Reviewed-and-tested-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-03-19 09:49:36 -07:00
..
.gitignore Another .gitignore file. 2006-08-08 12:11:23 -07:00
Makefile ip: add rmnet initial support 2018-06-15 11:15:14 -07:00
ifcfg ifcfg/rtpr: convert to POSIX shell 2018-01-10 08:26:09 -08:00
ila_common.h SPDX license identifiers 2017-11-24 12:21:35 -08:00
ip.c ip bridge: Set NETLINK_GET_STRICT_CHK on socket 2018-12-27 15:36:29 -08:00
ip6tunnel.c utils: Introduce and use nodev() helper routine 2018-03-11 17:58:36 -07:00
ip_common.h ip address: Split ip_linkaddr_list into link and addr functions 2018-12-27 15:35:14 -08:00
ipaddress.c ipaddress: print error message on stderr 2019-03-15 08:30:26 -07:00
ipaddrlabel.c Tree wide: Drop sockaddr_nl arg 2018-10-22 09:43:48 -07:00
ipfou.c Tree wide: Drop sockaddr_nl arg 2018-10-22 09:43:48 -07:00
ipila.c Tree wide: Drop sockaddr_nl arg 2018-10-22 09:43:48 -07:00
ipl2tp.c l2tp: Fix printing of cookie and peer_cookie values 2018-12-03 14:35:58 -08:00
iplink.c iplink: document XDP subcommand to force the XDP mode. 2019-02-13 14:02:44 -08:00
iplink_bond.c utils: Introduce and use nodev() helper routine 2018-03-11 17:58:36 -07:00
iplink_bond_slave.c ip: iplink_bond_slave.c: add json output support (info_slave_data) 2017-08-17 18:02:40 -07:00
iplink_bridge.c fix print_0xhex on 32 bit 2018-12-10 14:20:32 -08:00
iplink_bridge_slave.c fix print_0xhex on 32 bit 2018-12-10 14:20:32 -08:00
iplink_can.c ip: iplink_can.c: fix json formatting 2018-12-07 09:22:29 -08:00
iplink_dummy.c SPDX license identifiers 2017-11-24 12:21:35 -08:00
iplink_geneve.c Merge branch 'iproute2-master' into iproute2-next 2018-12-19 12:02:17 -08:00
iplink_hsr.c ip: iplink_hsr.c: add json output support 2017-08-17 18:02:40 -07:00
iplink_ifb.c SPDX license identifiers 2017-11-24 12:21:35 -08:00
iplink_ipoib.c ip: iplink_ipoib.c: add json output support 2017-08-17 18:02:41 -07:00
iplink_ipvlan.c iplink: add ipvtap support 2018-09-20 17:53:56 -07:00
iplink_macvlan.c ip: link_macvlan.c: add json output support 2017-08-17 18:02:41 -07:00
iplink_netdevsim.c ip: link: add support for netdevsim device type 2018-01-02 20:46:19 -08:00
iplink_nlmon.c SPDX license identifiers 2017-11-24 12:21:35 -08:00
iplink_rmnet.c ip: add rmnet initial support 2018-06-15 11:15:14 -07:00
iplink_team.c SPDX license identifiers 2017-11-24 12:21:35 -08:00
iplink_vcan.c SPDX license identifiers 2017-11-24 12:21:35 -08:00
iplink_vlan.c treewide: Use addattr_nest()/addattr_nest_end() to handle nested attributes 2018-02-02 15:01:09 -08:00
iplink_vrf.c iplink_vrf: Save device index from response for return code 2018-06-01 15:45:09 -04:00
iplink_vxcan.c iplink: Perform most of request buffer setups and checks in iplink_parse() 2018-03-11 17:59:03 -07:00
iplink_vxlan.c Merge branch 'iproute2-master' into iproute2-next 2018-12-19 12:02:17 -08:00
iplink_xdp.c iplink: add support for reporting multiple XDP programs 2018-07-15 13:10:03 -07:00
iplink_xstats.c libnetlink: Rename rtnl_wilddump_stats_req_filter to rtnl_statsdump_req_filter 2018-10-02 18:39:36 -07:00
ipmacsec.c ipmacsec: fix warning on 32bit platform 2018-12-10 13:47:58 -08:00
ipmaddr.c lib: introduce print_nl 2018-09-11 08:29:33 -07:00
ipmonitor.c ipmonitor: make local variable static 2018-11-19 11:42:44 -08:00
ipmroute.c mroute: Add table id attribute for kernel side filtering 2018-12-27 15:34:50 -08:00
ipneigh.c Merge ../iproute2-next 2019-01-07 11:36:41 -08:00
ipnetconf.c Tree wide: Drop sockaddr_nl arg 2018-10-22 09:43:48 -07:00
ipnetns.c ipnetns: parse nsid as a signed integer 2018-11-21 09:35:37 -08:00
ipntable.c fix print_0xhex on 32 bit 2018-12-10 14:20:32 -08:00
ipprefix.c Tree wide: Drop sockaddr_nl arg 2018-10-22 09:43:48 -07:00
iproute.c ip route: print route type in JSON output 2019-03-19 09:49:36 -07:00
iproute_lwtunnel.c iproute: Set ip/ip6 lwtunnel flags 2019-01-25 09:17:27 +13:00
iprule.c iprule: fix printing hint about unresolved iifname and oifname 2019-03-07 16:14:09 -08:00
ipseg6.c Tree wide: Drop sockaddr_nl arg 2018-10-22 09:43:48 -07:00
iptoken.c Tree wide: Drop sockaddr_nl arg 2018-10-22 09:43:48 -07:00
iptunnel.c utils: Introduce and use nodev() helper routine 2018-03-11 17:58:36 -07:00
iptuntap.c fix print_0xhex on 32 bit 2018-12-10 14:20:32 -08:00
ipvrf.c ip address: Split ip_linkaddr_list into link and addr functions 2018-12-27 15:35:14 -08:00
ipxfrm.c ipxfrm: make local functions static 2018-11-19 11:42:44 -08:00
link_gre.c fix print_0xhex on 32 bit 2018-12-10 14:20:32 -08:00
link_gre6.c fix print_0xhex on 32 bit 2018-12-10 14:20:32 -08:00
link_ip6tnl.c fix print_0xhex on 32 bit 2018-12-10 14:20:32 -08:00
link_iptnl.c fix print_0xhex on 32 bit 2018-12-10 14:20:32 -08:00
link_veth.c iplink: Perform most of request buffer setups and checks in iplink_parse() 2018-03-11 17:59:03 -07:00
link_vti.c fix print_0xhex on 32 bit 2018-12-10 14:20:32 -08:00
link_vti6.c fix print_0xhex on 32 bit 2018-12-10 14:20:32 -08:00
routef mark shell scripts +x 2018-01-10 08:23:49 -08:00
routel mark shell scripts +x 2018-01-10 08:23:49 -08:00
rtm_map.c drop unneeded include of syslog.h 2017-11-12 16:22:36 -08:00
rtmon.c Tree wide: Drop sockaddr_nl arg 2018-10-22 09:43:48 -07:00
rtpr ifcfg/rtpr: convert to POSIX shell 2018-01-10 08:26:09 -08:00
static-syms.c SPDX license identifiers 2017-11-24 12:21:35 -08:00
tcp_metrics.c Tree wide: Drop sockaddr_nl arg 2018-10-22 09:43:48 -07:00
tunnel.c Include bsd/string.h only in include/utils.h 2018-11-05 08:38:32 -08:00
tunnel.h iptunnel/ip6tunnel: Use netlink to walk through tunnels list 2018-02-07 16:15:42 -08:00
xfrm.h ipxfrm: make local functions static 2018-11-19 11:42:44 -08:00
xfrm_monitor.c ipxfrm: make local functions static 2018-11-19 11:42:44 -08:00
xfrm_policy.c Tree wide: Drop sockaddr_nl arg 2018-10-22 09:43:48 -07:00
xfrm_state.c Include bsd/string.h only in include/utils.h 2018-11-05 08:38:32 -08:00