Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: Fix show neighbor X advertised-routes detail #17674

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 20 additions & 28 deletions bgpd/bgp_evpn_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,9 @@ static void bgp_evpn_show_routes_mac_ip_es(struct vty *vty, esi_t *esi,
json_path = json_object_new_array();

if (detail)
route_vty_out_detail(
vty, bgp, bd, bgp_dest_get_prefix(bd),
pi, AFI_L2VPN, SAFI_EVPN,
RPKI_NOT_BEING_USED, json_path);
route_vty_out_detail(vty, bgp, bd, bgp_dest_get_prefix(bd), pi,
AFI_L2VPN, SAFI_EVPN, RPKI_NOT_BEING_USED,
json_path, NULL);
else
route_vty_out(vty, &bd->rn->p, pi, 0, SAFI_EVPN,
json_path, false);
Expand Down Expand Up @@ -892,10 +891,9 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn,
json_path = json_object_new_array();

if (detail)
route_vty_out_detail(vty, bgp, dest, &tmp_p, pi,
AFI_L2VPN, SAFI_EVPN,
RPKI_NOT_BEING_USED,
json_path);
route_vty_out_detail(vty, bgp, dest, &tmp_p, pi, AFI_L2VPN,
SAFI_EVPN, RPKI_NOT_BEING_USED, json_path,
NULL);

else
route_vty_out(vty, &tmp_p, pi, 0, SAFI_EVPN,
Expand Down Expand Up @@ -2570,9 +2568,8 @@ static void evpn_show_route_vni_multicast(struct vty *vty, struct bgp *bgp,
if (json)
json_path = json_object_new_array();

route_vty_out_detail(vty, bgp, dest, bgp_dest_get_prefix(dest),
pi, afi, safi, RPKI_NOT_BEING_USED,
json_path);
route_vty_out_detail(vty, bgp, dest, bgp_dest_get_prefix(dest), pi, afi, safi,
RPKI_NOT_BEING_USED, json_path, NULL);

if (json)
json_object_array_add(json_paths, json_path);
Expand Down Expand Up @@ -2699,9 +2696,8 @@ static void evpn_show_route_vni_macip(struct vty *vty, struct bgp *bgp,
NULL /* ip */);
}

route_vty_out_detail(vty, bgp, dest, (struct prefix *)&tmp_p,
pi, afi, safi, RPKI_NOT_BEING_USED,
json_path);
route_vty_out_detail(vty, bgp, dest, (struct prefix *)&tmp_p, pi, afi, safi,
RPKI_NOT_BEING_USED, json_path, NULL);

if (json)
json_object_array_add(json_paths, json_path);
Expand Down Expand Up @@ -2810,9 +2806,8 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp,
if (json)
json_path = json_object_new_array();

route_vty_out_detail(vty, bgp, dest, bgp_dest_get_prefix(dest),
pi, afi, safi, RPKI_NOT_BEING_USED,
json_path);
route_vty_out_detail(vty, bgp, dest, bgp_dest_get_prefix(dest), pi, afi, safi,
RPKI_NOT_BEING_USED, json_path, NULL);

if (json)
json_object_array_add(json_paths, json_path);
Expand Down Expand Up @@ -2923,9 +2918,8 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp,
if (json)
json_path = json_object_new_array();

route_vty_out_detail(
vty, bgp, dest, bgp_dest_get_prefix(dest), pi,
afi, safi, RPKI_NOT_BEING_USED, json_path);
route_vty_out_detail(vty, bgp, dest, bgp_dest_get_prefix(dest), pi, afi,
safi, RPKI_NOT_BEING_USED, json_path, NULL);

if (json)
json_object_array_add(json_paths, json_path);
Expand Down Expand Up @@ -3060,9 +3054,8 @@ static void evpn_show_route_rd_all_macip(struct vty *vty, struct bgp *bgp,
if (json)
json_path = json_object_new_array();

route_vty_out_detail(vty, bgp, dest, p, pi, AFI_L2VPN,
SAFI_EVPN, RPKI_NOT_BEING_USED,
json_path);
route_vty_out_detail(vty, bgp, dest, p, pi, AFI_L2VPN, SAFI_EVPN,
RPKI_NOT_BEING_USED, json_path, NULL);

if (json)
json_object_array_add(json_paths, json_path);
Expand Down Expand Up @@ -3223,11 +3216,10 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type,
json_path = json_object_new_array();

if (detail) {
route_vty_out_detail(
vty, bgp, dest,
bgp_dest_get_prefix(dest), pi,
AFI_L2VPN, SAFI_EVPN,
RPKI_NOT_BEING_USED, json_path);
route_vty_out_detail(vty, bgp, dest,
bgp_dest_get_prefix(dest), pi,
AFI_L2VPN, SAFI_EVPN,
RPKI_NOT_BEING_USED, json_path, NULL);
} else
route_vty_out(vty, p, pi, 0, SAFI_EVPN,
json_path, false);
Expand Down
96 changes: 48 additions & 48 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -10552,14 +10552,13 @@ static void route_vty_out_detail_es_info(struct vty *vty,
}

void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
const struct prefix *p, struct bgp_path_info *path,
afi_t afi, safi_t safi,
enum rpki_states rpki_curr_state,
json_object *json_paths)
const struct prefix *p, struct bgp_path_info *path, afi_t afi,
safi_t safi, enum rpki_states rpki_curr_state, json_object *json_paths,
struct attr *pattr)
{
char buf[INET6_ADDRSTRLEN];
char vni_buf[30] = {};
struct attr *attr = path->attr;
struct attr *attr = pattr ? pattr : path->attr;
time_t tbuf;
char timebuf[32];
json_object *json_bestpath = NULL;
Expand Down Expand Up @@ -11284,13 +11283,18 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
json_path, "community",
bgp_attr_get_community(attr)->json);
} else {
if (!bgp_attr_get_community(attr)->str)
community_str(bgp_attr_get_community(attr), true, true);
vty_out(vty, " Community: %s\n",
bgp_attr_get_community(attr)->str);
}
}

/* Line 5 display Extended-community */
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) {
if (!bgp_attr_get_ecommunity(attr)->str)
ecommunity_str(bgp_attr_get_ecommunity(attr));

if (json_paths) {
json_ext_community = json_object_new_object();
json_object_string_add(
Expand All @@ -11305,6 +11309,9 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
}

if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_IPV6_EXT_COMMUNITIES))) {
if (!bgp_attr_get_ipv6_ecommunity(attr)->str)
ecommunity_str(bgp_attr_get_ipv6_ecommunity(attr));

if (json_paths) {
json_ext_ipv6_community = json_object_new_object();
json_object_string_add(json_ext_ipv6_community, "string",
Expand All @@ -11330,6 +11337,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
json_path, "largeCommunity",
bgp_attr_get_lcommunity(attr)->json);
} else {
if (!bgp_attr_get_lcommunity(attr)->str)
lcommunity_str(bgp_attr_get_lcommunity(attr), true, true);
vty_out(vty, " Large Community: %s\n",
bgp_attr_get_lcommunity(attr)->str);
}
Expand Down Expand Up @@ -11997,11 +12006,9 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t sa
prd, table->afi, safi,
NULL, false, false);

route_vty_out_detail(
vty, bgp, dest, dest_p, pi,
family2afi(dest_p->family),
safi, RPKI_NOT_BEING_USED,
json_paths);
route_vty_out_detail(vty, bgp, dest, dest_p, pi,
family2afi(dest_p->family), safi,
RPKI_NOT_BEING_USED, json_paths, NULL);
} else {
route_vty_out(vty, dest_p, pi, display,
safi, json_paths, wide);
Expand Down Expand Up @@ -12114,8 +12121,13 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t sa
}
if (is_last) {
unsigned long i;
for (i = 0; i < *json_header_depth; ++i)
for (i = 0; i < *json_header_depth; ++i) {
vty_out(vty, " } ");
/* Put this information before closing the last `}` */
if (i == *json_header_depth - 2)
vty_out(vty, ", \"totalRoutes\": %ld, \"totalPaths\": %ld",
output_count, total_count);
}
if (!all)
vty_out(vty, "\n");
}
Expand Down Expand Up @@ -12511,11 +12523,10 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
}
}

static void bgp_show_path_info(const struct prefix_rd *pfx_rd,
struct bgp_dest *bgp_node, struct vty *vty,
struct bgp *bgp, afi_t afi, safi_t safi,
json_object *json, enum bgp_path_type pathtype,
int *display, enum rpki_states rpki_target_state)
static void bgp_show_path_info(const struct prefix_rd *pfx_rd, struct bgp_dest *bgp_node,
struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
json_object *json, enum bgp_path_type pathtype, int *display,
enum rpki_states rpki_target_state, struct attr *attr)
{
struct bgp_path_info *pi;
int header = 1;
Expand Down Expand Up @@ -12558,10 +12569,8 @@ static void bgp_show_path_info(const struct prefix_rd *pfx_rd,
|| (pathtype == BGP_PATH_SHOW_MULTIPATH
&& (CHECK_FLAG(pi->flags, BGP_PATH_MULTIPATH)
|| CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))))
route_vty_out_detail(vty, bgp, bgp_node,
bgp_dest_get_prefix(bgp_node), pi,
afi, safi, rpki_curr_state,
json_paths);
route_vty_out_detail(vty, bgp, bgp_node, bgp_dest_get_prefix(bgp_node), pi,
afi, safi, rpki_curr_state, json_paths, attr);
}

if (json && json_paths) {
Expand Down Expand Up @@ -12648,9 +12657,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
continue;
}

bgp_show_path_info((struct prefix_rd *)dest_p, rm, vty,
bgp, afi, safi, json, pathtype,
&display, rpki_target_state);
bgp_show_path_info((struct prefix_rd *)dest_p, rm, vty, bgp, afi, safi,
json, pathtype, &display, rpki_target_state, NULL);

bgp_dest_unlock_node(rm);
}
Expand Down Expand Up @@ -12709,9 +12717,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
rm = longest_pfx;
bgp_dest_lock_node(rm);

bgp_show_path_info((struct prefix_rd *)dest_p, rm, vty,
bgp, afi, safi, json, pathtype,
&display, rpki_target_state);
bgp_show_path_info((struct prefix_rd *)dest_p, rm, vty, bgp, afi, safi,
json, pathtype, &display, rpki_target_state, NULL);

bgp_dest_unlock_node(rm);
}
Expand All @@ -12737,9 +12744,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
const struct prefix *dest_p = bgp_dest_get_prefix(dest);
if (!prefix_check
|| dest_p->prefixlen == match.prefixlen) {
bgp_show_path_info(NULL, dest, vty, bgp, afi,
safi, json, pathtype,
&display, rpki_target_state);
bgp_show_path_info(NULL, dest, vty, bgp, afi, safi, json, pathtype,
&display, rpki_target_state, NULL);
}

bgp_dest_unlock_node(dest);
Expand Down Expand Up @@ -14633,10 +14639,8 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
if (use_json)
json_net = json_object_new_object();

bgp_show_path_info(NULL /* prefix_rd */, dest, vty, bgp,
afi, safi, json_net,
BGP_PATH_SHOW_ALL, &display,
RPKI_NOT_BEING_USED);
bgp_show_path_info(NULL /* prefix_rd */, dest, vty, bgp, afi, safi, json_net,
BGP_PATH_SHOW_ALL, &display, RPKI_NOT_BEING_USED, NULL);
if (use_json)
json_object_object_addf(json_ar, json_net,
"%pFX", rn_p);
Expand Down Expand Up @@ -14770,11 +14774,9 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
pass_in = &buildit;
} else
pass_in = dest;
bgp_show_path_info(
NULL, pass_in, vty, bgp, afi,
safi, json_net,
BGP_PATH_SHOW_ALL, &display,
RPKI_NOT_BEING_USED);
bgp_show_path_info(NULL, pass_in, vty, bgp, afi, safi,
json_net, BGP_PATH_SHOW_ALL, &display,
RPKI_NOT_BEING_USED, NULL);
if (use_json)
json_object_object_addf(
json_ar, json_net,
Expand All @@ -14800,9 +14802,8 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
bgp_dest_get_prefix(dest);

attr = *adj->attr;
ret = bgp_output_modifier(
peer, rn_p, &attr, afi, safi,
rmap_name);
ret = bgp_output_modifier(peer, rn_p, &attr, afi, safi,
rmap_name);

if (ret == RMAP_DENY) {
(*filtered_count)++;
Expand All @@ -14826,7 +14827,8 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
json_net = json_object_new_object();
bgp_show_path_info(NULL, dest, vty, bgp, afi, safi,
json_net, BGP_PATH_SHOW_ALL,
&display, RPKI_NOT_BEING_USED);
&display, RPKI_NOT_BEING_USED,
adj->attr);
if (use_json)
json_object_object_addf(json_ar, json_net,
"%pFX", rn_p);
Expand All @@ -14839,7 +14841,7 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
*/
if (use_json) {
route_vty_out_tmp(vty, bgp, dest, rn_p,
&attr, safi, use_json,
adj->attr, safi, use_json,
json_ar, wide);
} else {
for (bpi = bgp_dest_get_bgp_path_info(dest);
Expand Down Expand Up @@ -14872,11 +14874,9 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
if (use_json)
json_net =
json_object_new_object();
bgp_show_path_info(
NULL /* prefix_rd */, dest, vty,
bgp, afi, safi, json_net,
BGP_PATH_SHOW_BESTPATH,
&display, RPKI_NOT_BEING_USED);
bgp_show_path_info(NULL /* prefix_rd */, dest, vty, bgp, afi,
safi, json_net, BGP_PATH_SHOW_BESTPATH,
&display, RPKI_NOT_BEING_USED, NULL);
if (use_json)
json_object_object_addf(
json_ar, json_net,
Expand Down
9 changes: 4 additions & 5 deletions bgpd/bgp_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -932,11 +932,10 @@ extern void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
safi_t safi, json_object *json,
bool incremental_print,
bool local_table);
extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
struct bgp_dest *bn, const struct prefix *p,
struct bgp_path_info *path, afi_t afi,
safi_t safi, enum rpki_states,
json_object *json_paths);
extern void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
const struct prefix *p, struct bgp_path_info *path, afi_t afi,
safi_t safi, enum rpki_states, json_object *json_paths,
struct attr *attr);
extern int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
struct bgp_table *table, struct prefix_rd *prd,
enum bgp_show_type type, void *output_arg,
Expand Down
Loading
Loading