The same tag "dst" was being used for both the route destination
and the encap destination. This made it hard for JSON parsers.
Change to put the per-encap information under a nested JSON
object (similar to ip link type info).
Original output
[ {
"dst": "192.168.11.0/24",
"encap": "ip6",
"id": 0,
"src": "::",
"dst": "fd00::c0a8:2dd",
"hoplimit": 0,
"tc": 0,
"protocol": "5",
"scope": "link",
"flags": [ ]
} ]
Revised output
[ {
"dst": "192.168.11.0/24",
"encap": {
"encap_type": "ip6",
"id": 0,
"src": "::",
"dst": "fd00::c0a8:2dd",
"hoplimit": 0,
"tc": 0
},
"protocol": "5",
"scope": "link",
"flags": [ ]
} ]
Reported-by: Lars Ekman <uablrek@gmail.com>
Fixes: 663c3cb23103 ("iproute: implement JSON and color output")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
return;
et = rta_getattr_u16(encap_type);
-
- print_string(PRINT_ANY, "encap", " encap %s ", format_encap_type(et));
+ open_json_object("encap");
+ print_string(PRINT_ANY, "encap_type", " encap %s ",
+ format_encap_type(et));
switch (et) {
case LWTUNNEL_ENCAP_MPLS:
print_encap_xfrm(fp, encap);
break;
}
+ close_json_object();
}
static struct ipv6_sr_hdr *parse_srh(char *segbuf, int hmac, bool encap)