diff options
author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-04-10 09:27:06 +0200 |
---|---|---|
committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-04-13 21:06:32 +0200 |
commit | f280c93b118be645e7b6ef334f7c30e9f9f08303 (patch) | |
tree | 18b3af1754263f3fe52d8d106d54c6c28e420053 | |
parent | Merge pull request #8153 from reubendowle/nhrp-multicast (diff) | |
download | frr-f280c93b118be645e7b6ef334f7c30e9f9f08303.tar.xz frr-f280c93b118be645e7b6ef334f7c30e9f9f08303.zip |
bgpd: Add `show bgp json detail` command
Print detailed version for JSON output when dumping ALL BGP table with
`show bgp <afi> <safi> json detail`.
This output should be at some sort of identical to show_ip_bgp_route_cmd.
To avoid breaking backward-compatibility for `show bgp json`, adding
'detail' keyword for that.
In long-term it's easier for operators to compare stuff just looking at global
view instead of per-prefix for details.
Before:
```
],"192.168.100.1/32": [
{
"valid":true,
"bestpath":true,
"selectionReason":"First path received",
"pathFrom":"external",
"prefix":"192.168.100.1",
"prefixLen":32,
"network":"192.168.100.1\/32",
"metric":0,
"weight":32768,
"peerId":"(unspec)",
"path":"",
"origin":"incomplete",
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"exit1-debian-9",
"afi":"ipv4",
"used":true
}
]
}
] } }
```
After:
```
],"192.168.100.1/32": [
{
"aspath":{
"string":"Local",
"segments":[
],
"length":0
},
"origin":"incomplete",
"metric":0,
"weight":32768,
"valid":true,
"sourced":true,
"bestpath":{
"overall":true,
"selectionReason":"First path received"
},
"lastUpdate":{
"epoch":1618040124,
"string":"Sat Apr 10 07:35:24 2021\n"
},
"nexthops":[
{
"ip":"0.0.0.0",
"hostname":"exit1-debian-9",
"afi":"ipv4",
"metric":0,
"accessible":true,
"used":true
}
],
"peer":{
"peerId":"0.0.0.0",
"routerId":"192.168.100.1"
}
}
] } }
```
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
-rw-r--r-- | bgpd/bgp_route.c | 20 | ||||
-rw-r--r-- | bgpd/bgp_route.h | 1 |
2 files changed, 17 insertions, 4 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 1c2ad7fc7..cdf6748f5 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10830,9 +10830,17 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, flap_route_vty_out(vty, dest_p, pi, display, AFI_IP, safi, use_json, json_paths); - else - route_vty_out(vty, dest_p, pi, display, safi, - json_paths, wide); + else { + if (CHECK_FLAG(show_flags, BGP_SHOW_OPT_DETAIL)) + route_vty_out_detail( + vty, bgp, dest, pi, + family2afi(dest_p->family), + safi, RPKI_NOT_BEING_USED, + json_paths); + else + route_vty_out(vty, dest_p, pi, display, + safi, json_paths, wide); + } display++; } @@ -11905,7 +11913,7 @@ DEFPY (show_ip_bgp_json, |route-filter-translated-v4] [exact-match]\ |rpki <invalid|valid|notfound>\ |version (1-4294967295)\ - ] [json$uj | wide$wide]", + ] [json$uj [detail$detail] | wide$wide]", SHOW_STR IP_STR BGP_STR @@ -11941,6 +11949,7 @@ DEFPY (show_ip_bgp_json, "Display prefixes with matching version numbers\n" "Version number and above\n" JSON_STR + "Display detailed version of JSON output\n" "Increase table width for longer prefixes\n") { afi_t afi = AFI_IP6; @@ -11960,6 +11969,9 @@ DEFPY (show_ip_bgp_json, SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); } + if (detail) + SET_FLAG(show_flags, BGP_SHOW_OPT_DETAIL); + /* [<ipv4|ipv6> [all]] */ if (all) { SET_FLAG(show_flags, BGP_SHOW_OPT_AFI_ALL); diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index 1bf5dcf18..1de453b3c 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -586,6 +586,7 @@ DECLARE_HOOK(bgp_process, #define BGP_SHOW_OPT_AFI_IP6 (1 << 4) #define BGP_SHOW_OPT_ESTABLISHED (1 << 5) #define BGP_SHOW_OPT_FAILED (1 << 6) +#define BGP_SHOW_OPT_DETAIL (1 << 7) /* Prototypes. */ extern void bgp_rib_remove(struct bgp_dest *dest, struct bgp_path_info *pi, |