Merge pull request #3139 from adharkar/frr-bgp_cli

bgpd: BGP JSON show commands enhancements
This commit is contained in:
Russ White 2018-10-31 21:36:23 -04:00 committed by GitHub
commit e008da8e9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 11 deletions

View File

@ -6664,7 +6664,8 @@ void route_vty_out(struct vty *vty, struct prefix *p,
inet_ntoa(attr->nexthop));
json_object_string_add(json_nexthop_global,
"afi", "ipv4");
json_object_boolean_true_add(json_nexthop_global,
json_object_boolean_true_add(
json_nexthop_global,
"used");
} else {
vty_out(vty, "%-16s", inet_ntoa(attr->nexthop));
@ -6791,19 +6792,32 @@ void route_vty_out(struct vty *vty, struct prefix *p,
/* MED/Metric */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
if (json_paths)
if (json_paths) {
/*
* Adding "metric" field to match with corresponding
* CLI. "med" will be deprecated in future.
*/
json_object_int_add(json_path, "med", attr->med);
else
json_object_int_add(json_path, "metric", attr->med);
} else
vty_out(vty, "%10u", attr->med);
else if (!json_paths)
vty_out(vty, " ");
/* Local Pref */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
if (json_paths)
if (json_paths) {
/*
* Adding "locPrf" field to match with corresponding
* CLI. "localPref" will be deprecated in future.
*/
json_object_int_add(json_path, "localpref",
attr->local_pref);
else
json_object_int_add(json_path, "locPrf",
attr->local_pref);
} else
vty_out(vty, "%7u", attr->local_pref);
else if (!json_paths)
vty_out(vty, " ");
@ -6822,10 +6836,17 @@ void route_vty_out(struct vty *vty, struct prefix *p,
/* Print aspath */
if (attr->aspath) {
if (json_paths)
if (json_paths) {
/*
* Adding "path" field to match with corresponding
* CLI. "aspath" will be deprecated in future.
*/
json_object_string_add(json_path, "aspath",
attr->aspath->str);
else
json_object_string_add(json_path, "path",
attr->aspath->str);
} else
aspath_print_vty(vty, "%s", attr->aspath, " ");
}
@ -6941,16 +6962,34 @@ void route_vty_out_tmp(struct vty *vty, struct prefix *p, struct attr *attr,
json_object_int_add(json_net, "metric",
attr->med);
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) {
/*
* Adding "locPrf" field to match with
* corresponding CLI. "localPref" will be
* deprecated in future.
*/
json_object_int_add(json_net, "localPref",
attr->local_pref);
json_object_int_add(json_net, "locPrf",
attr->local_pref);
}
json_object_int_add(json_net, "weight", attr->weight);
/* Print aspath */
if (attr->aspath)
if (attr->aspath) {
/*
* Adding "path" field to match with
* corresponding CLI. "localPref" will be
* deprecated in future.
*/
json_object_string_add(json_net, "asPath",
attr->aspath->str);
json_object_string_add(json_net, "path",
attr->aspath->str);
}
/* Print origin */
json_object_string_add(json_net, "bgpOriginCode",
@ -7853,10 +7892,18 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p,
bgp_origin_long_str[attr->origin]);
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) {
if (json_paths)
if (json_paths) {
/*
* Adding "metric" field to match with
* corresponding CLI. "med" will be
* deprecated in future.
*/
json_object_int_add(json_path, "med",
attr->med);
else
json_object_int_add(json_path, "metric",
attr->med);
} else
vty_out(vty, ", metric %u", attr->med);
}

View File

@ -7982,8 +7982,17 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
json_object_int_add(json_peer, "inq", 0);
peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN,
use_json, json_peer);
/*
* Adding "pfxRcd" field to match with the corresponding
* CLI. "prefixReceivedCount" will be deprecated in
* future.
*/
json_object_int_add(json_peer, "prefixReceivedCount",
peer->pcount[afi][pfx_rcd_safi]);
json_object_int_add(json_peer, "pfxRcd",
peer->pcount[afi][pfx_rcd_safi]);
paf = peer_af_find(peer, afi, pfx_rcd_safi);
if (paf && PAF_SUBGRP(paf))
json_object_int_add(json_peer,