ip: link_iptnl.c: add json output support
Schema
{
"remote": {
"type": "string",
"attr": "IFLA_IPTUN_REMOTE"
},
"local": {
"type": "string",
"attr": "IFLA_IPTUN_LOCAL"
},
"link": {
"type": "string",
"attr": "IFLA_IPTUN_LINK",
"mutually_exclusive": {
"link_index": {
"type": "uint",
}
}
},
"ttl": {
"type": "int",
"attr": "IFLA_IPTUN_TTL"
},
"tos": {
"type": "string",
"attr": "IFLA_IPTUN_TOS"
},
"pmtudisc": {
"type": "bool",
"attr": "IFLA_IPTUN_PMTUDISC"
},
"isatap": {
"type": "bool",
"attr": "SIT_ISATAP & IFLA_IPTUN_FLAGS"
},
"6rd": {
"type": "dict",
"attr": "IFLA_IPTUN_6RD_PREFIXLEN",
"dict": {
"prefix": {
"type": "string"
},
"prefixlen": {
"type": "uint",
"attr": "IFLA_IPTUN_6RD_PREFIXLEN"
},
"relay_prefix": {
"type": "string"
},
"relay_prefixlen": {
"type": "uint",
"attr": "IFLA_IPTUN_6RD_PREFIXLEN"
}
}
},
"encap": {
"type": "dict",
"attr": "IFLA_IPTUN_ENCAP_TYPE",
"dict": {
"type": {
"type": "string",
"attr": "IFLA_IPTUN_ENCAP_TYPE"
},
"sport": {
"type": "uint",
"attr": "IFLA_IPTUN_ENCAP_SPORT"
},
"dport": {
"type": "uint",
"attr": "IFLA_IPTUN_ENCAP_DPORT"
},
"csum": {
"type": "bool",
"attr": "TUNNEL_ENCAP_FLAG_CSUM"
},
"csum6": {
"type": "bool",
"attr": "TUNNEL_ENCAP_FLAG_CSUM6"
},
"remcsum": {
"type": "bool",
"attr": "TUNNEL_ENCAP_FLAG_REMCSUM"
}
}
}
}
$ ip tunnel add tun0 mode ipip local 192.0.2.1 remote 198.51.100.3
$ ip link show
10: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group
default
link/ipip 0.0.0.0 brd 0.0.0.0
11: tun0@NONE: <POINTOPOINT,NOARP> mtu 1480 qdisc noop state DOWN mode
DEFAULT group default
link/ipip 192.0.2.1 peer 198.51.100.3
$ ip -details -json link show
[{
"ifindex": 10,
"ifname": "tunl0",
"link": null,
"flags": ["NOARP"],
"mtu": 1480,
"qdisc": "noop",
"operstate": "DOWN",
"linkmode": "DEFAULT",
"group": "default",
"link_type": "ipip",
"address": "0.0.0.0",
"broadcast": "0.0.0.0",
"promiscuity": 0,
"linkinfo": {
"info_kind": "ipip",
"info_data": {
"remote": "any",
"local": "any",
"ttl": 0,
"pmtudisc": false
}
},
"num_tx_queues": 1,
"num_rx_queues": 1,
"gso_max_size": 65536,
"gso_max_segs": 65535
},{
"ifindex": 11,
"ifname": "tun0",
"link": null,
"flags": ["POINTOPOINT","NOARP"],
"mtu": 1480,
"qdisc": "noop",
"operstate": "DOWN",
"linkmode": "DEFAULT",
"group": "default",
"link_type": "ipip",
"address": "192.0.2.1",
"link_pointtopoint": true,
"broadcast": "198.51.100.3",
"promiscuity": 0,
"linkinfo": {
"info_kind": "ipip",
"info_data": {
"remote": "198.51.100.3",
"local": "192.0.2.1",
"ttl": 0,
"pmtudisc": true
}
},
"num_tx_queues": 1,
"num_rx_queues": 1,
"gso_max_size": 65536,
"gso_max_segs": 65535
}
]
Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>