bgpd: remove some deep nesting

Some of this was so egregiously stupid, I couldn't look at it without
gouging my eyes out...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2017-08-27 22:51:35 +02:00
parent 2b79110731
commit ea47320b1d
3 changed files with 900 additions and 931 deletions

View File

@ -375,7 +375,9 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
continue; continue;
if ((table = rn->info) != NULL) { if ((table = rn->info) == NULL)
continue;
rd_header = 1; rd_header = 1;
for (rm = bgp_table_top(table); rm; for (rm = bgp_table_top(table); rm;
@ -451,14 +453,11 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
type = decode_rd_type(pnt); type = decode_rd_type(pnt);
/* Decode RD value. */ /* Decode RD value. */
if (type == RD_TYPE_AS) if (type == RD_TYPE_AS)
decode_rd_as(pnt + 2, decode_rd_as(pnt + 2, &rd_as);
&rd_as);
else if (type == RD_TYPE_AS4) else if (type == RD_TYPE_AS4)
decode_rd_as4(pnt + 2, decode_rd_as4(pnt + 2, &rd_as);
&rd_as);
else if (type == RD_TYPE_IP) else if (type == RD_TYPE_IP)
decode_rd_ip(pnt + 2, decode_rd_ip(pnt + 2, &rd_ip);
&rd_ip);
if (use_json) { if (use_json) {
char buffer[BUFSIZ]; char buffer[BUFSIZ];
if (type == RD_TYPE_AS if (type == RD_TYPE_AS
@ -504,27 +503,23 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
rd_header = 0; rd_header = 0;
} }
if (use_json) if (use_json)
json_array = json_array = json_object_new_array();
json_object_new_array();
else else
json_array = NULL; json_array = NULL;
if (option == SHOW_DISPLAY_TAGS) if (option == SHOW_DISPLAY_TAGS)
route_vty_out_tag( route_vty_out_tag(vty, &rm->p, ri, 0,
vty, &rm->p, ri, 0, SAFI_EVPN,
SAFI_EVPN, json_array); json_array);
else if (option == SHOW_DISPLAY_OVERLAY) else if (option == SHOW_DISPLAY_OVERLAY)
route_vty_out_overlay( route_vty_out_overlay(vty, &rm->p, ri,
vty, &rm->p, ri, 0, 0, json_array);
json_array);
else else
route_vty_out(vty, &rm->p, ri, route_vty_out(vty, &rm->p, ri, 0,
0, SAFI_EVPN, SAFI_EVPN, json_array);
json_array);
output_count++; output_count++;
} }
/* XXX json */ /* XXX json */
} }
}
if (output_count == 0) if (output_count == 0)
vty_out(vty, "No prefixes displayed, %ld exist\n", total_count); vty_out(vty, "No prefixes displayed, %ld exist\n", total_count);
else else

View File

@ -3391,23 +3391,24 @@ static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
for (ain = rn->adj_in; ain; ain = ain->next) { for (ain = rn->adj_in; ain; ain = ain->next) {
if (ain->peer == peer) { if (ain->peer != peer)
continue;
struct bgp_info *ri = rn->info; struct bgp_info *ri = rn->info;
mpls_label_t label = mpls_label_t label =
(ri && ri->extra) ? ri->extra->label (ri && ri->extra) ? ri->extra->label
: MPLS_INVALID_LABEL; : MPLS_INVALID_LABEL;
ret = bgp_update( ret = bgp_update(peer, &rn->p, ain->addpath_rx_id,
peer, &rn->p, ain->addpath_rx_id,
ain->attr, afi, safi, ZEBRA_ROUTE_BGP, ain->attr, afi, safi, ZEBRA_ROUTE_BGP,
BGP_ROUTE_NORMAL, prd, &label, 1, NULL); BGP_ROUTE_NORMAL, prd, &label, 1,
NULL);
if (ret < 0) { if (ret < 0) {
bgp_unlock_node(rn); bgp_unlock_node(rn);
return; return;
} }
} }
}
} }
void bgp_soft_reconfig_in(struct peer *peer, afi_t afi, safi_t safi) void bgp_soft_reconfig_in(struct peer *peer, afi_t afi, safi_t safi)
@ -3454,8 +3455,10 @@ static wq_item_status bgp_clear_route_node(struct work_queue *wq, void *data)
/* It is possible that we have multiple paths for a prefix from a peer /* It is possible that we have multiple paths for a prefix from a peer
* if that peer is using AddPath. * if that peer is using AddPath.
*/ */
for (ri = rn->info; ri; ri = ri->next) for (ri = rn->info; ri; ri = ri->next) {
if (ri->peer == peer) { if (ri->peer != peer)
continue;
/* graceful restart STALE flag set. */ /* graceful restart STALE flag set. */
if (CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT) if (CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT)
&& peer->nsf[afi][safi] && peer->nsf[afi][safi]
@ -3466,9 +3469,8 @@ static wq_item_status bgp_clear_route_node(struct work_queue *wq, void *data)
/* If this is an EVPN route, process for /* If this is an EVPN route, process for
* un-import. */ * un-import. */
if (safi == SAFI_EVPN) if (safi == SAFI_EVPN)
bgp_evpn_unimport_route(peer->bgp, afi, bgp_evpn_unimport_route(peer->bgp, afi, safi,
safi, &rn->p, &rn->p, ri);
ri);
bgp_rib_remove(rn, ri, peer, afi, safi); bgp_rib_remove(rn, ri, peer, afi, safi);
} }
} }
@ -3705,32 +3707,31 @@ void bgp_clear_stale_route(struct peer *peer, afi_t afi, safi_t safi)
struct bgp_info *ri; struct bgp_info *ri;
/* look for neighbor in tables */ /* look for neighbor in tables */
if ((table = rn->info) != NULL) { if ((table = rn->info) == NULL)
continue;
for (rm = bgp_table_top(table); rm; for (rm = bgp_table_top(table); rm;
rm = bgp_route_next(rm)) rm = bgp_route_next(rm))
for (ri = rm->info; ri; ri = ri->next) for (ri = rm->info; ri; ri = ri->next) {
if (ri->peer == peer) { if (ri->peer != peer)
if (CHECK_FLAG( continue;
ri->flags, if (!CHECK_FLAG(ri->flags,
BGP_INFO_STALE)) BGP_INFO_STALE))
bgp_rib_remove(
rm, ri,
peer,
afi,
safi);
break; break;
}
bgp_rib_remove(rm, ri, peer, afi, safi);
break;
} }
} }
} else { } else {
for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn; for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn)) rn = bgp_route_next(rn))
for (ri = rn->info; ri; ri = ri->next) for (ri = rn->info; ri; ri = ri->next) {
if (ri->peer == peer) { if (ri->peer != peer)
if (CHECK_FLAG(ri->flags, continue;
BGP_INFO_STALE)) if (!CHECK_FLAG(ri->flags, BGP_INFO_STALE))
bgp_rib_remove(rn, ri, peer, break;
afi, safi); bgp_rib_remove(rn, ri, peer, afi, safi);
break; break;
} }
} }
@ -4556,8 +4557,10 @@ void bgp_static_add(struct bgp *bgp)
for (afi = AFI_IP; afi < AFI_MAX; afi++) for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
for (rn = bgp_table_top(bgp->route[afi][safi]); rn; for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
rn = bgp_route_next(rn)) rn = bgp_route_next(rn)) {
if (rn->info != NULL) { if (rn->info == NULL)
continue;
if ((safi == SAFI_MPLS_VPN) if ((safi == SAFI_MPLS_VPN)
|| (safi == SAFI_ENCAP) || (safi == SAFI_ENCAP)
|| (safi == SAFI_EVPN)) { || (safi == SAFI_EVPN)) {
@ -4594,8 +4597,10 @@ void bgp_static_delete(struct bgp *bgp)
for (afi = AFI_IP; afi < AFI_MAX; afi++) for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
for (rn = bgp_table_top(bgp->route[afi][safi]); rn; for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
rn = bgp_route_next(rn)) rn = bgp_route_next(rn)) {
if (rn->info != NULL) { if (rn->info == NULL)
continue;
if ((safi == SAFI_MPLS_VPN) if ((safi == SAFI_MPLS_VPN)
|| (safi == SAFI_ENCAP) || (safi == SAFI_ENCAP)
|| (safi == SAFI_EVPN)) { || (safi == SAFI_EVPN)) {
@ -4611,8 +4616,7 @@ void bgp_static_delete(struct bgp *bgp)
(struct (struct
prefix_rd *)&rn prefix_rd *)&rn
->p); ->p);
bgp_static_free( bgp_static_free(bgp_static);
bgp_static);
rn->info = NULL; rn->info = NULL;
bgp_unlock_node(rn); bgp_unlock_node(rn);
} }
@ -4641,8 +4645,10 @@ void bgp_static_redo_import_check(struct bgp *bgp)
for (afi = AFI_IP; afi < AFI_MAX; afi++) for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
for (rn = bgp_table_top(bgp->route[afi][safi]); rn; for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
rn = bgp_route_next(rn)) rn = bgp_route_next(rn)) {
if (rn->info != NULL) { if (rn->info == NULL)
continue;
if ((safi == SAFI_MPLS_VPN) if ((safi == SAFI_MPLS_VPN)
|| (safi == SAFI_ENCAP) || (safi == SAFI_ENCAP)
|| (safi == SAFI_EVPN)) { || (safi == SAFI_EVPN)) {
@ -5684,8 +5690,10 @@ static void bgp_aggregate_add(struct bgp *bgp, struct prefix *p, afi_t afi,
/* If routes exists below this node, generate aggregate routes. */ /* If routes exists below this node, generate aggregate routes. */
top = bgp_node_get(table, p); top = bgp_node_get(table, p);
for (rn = bgp_node_get(table, p); rn; for (rn = bgp_node_get(table, p); rn;
rn = bgp_route_next_until(rn, top)) rn = bgp_route_next_until(rn, top)) {
if (rn->p.prefixlen > p->prefixlen) { if (rn->p.prefixlen <= p->prefixlen)
continue;
match = 0; match = 0;
for (ri = rn->info; ri; ri = ri->next) { for (ri = rn->info; ri; ri = ri->next) {
@ -5696,48 +5704,40 @@ static void bgp_aggregate_add(struct bgp *bgp, struct prefix *p, afi_t afi,
& ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)) & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
atomic_aggregate = 1; atomic_aggregate = 1;
if (ri->sub_type != BGP_ROUTE_AGGREGATE) { if (ri->sub_type == BGP_ROUTE_AGGREGATE)
continue;
/* summary-only aggregate route suppress /* summary-only aggregate route suppress
aggregated * aggregated route announcement. */
route announcement. */
if (aggregate->summary_only) { if (aggregate->summary_only) {
(bgp_info_extra_get(ri)) (bgp_info_extra_get(ri))->suppress++;
->suppress++; bgp_info_set_flag(rn, ri,
bgp_info_set_flag(
rn, ri,
BGP_INFO_ATTR_CHANGED); BGP_INFO_ATTR_CHANGED);
match++; match++;
} }
/* If at least one route among routes /* If at least one route among routes that are
* that are aggregated has * aggregated has ORIGIN with the value INCOMPLETE,
* ORIGIN with the value INCOMPLETE, * then the aggregated route MUST have the ORIGIN
* then the aggregated route * attribute with the value INCOMPLETE. Otherwise, if
* MUST have the ORIGIN attribute with * at least one route among routes that are aggregated
* the value INCOMPLETE. * has ORIGIN with the value EGP, then the aggregated
* Otherwise, if at least one route * route MUST have the ORIGIN attribute with the value
* among routes that are * EGP.
* aggregated has ORIGIN with the value
* EGP, then the aggregated
* route MUST have the ORIGIN attribute
* with the value EGP.
*/ */
if (origin < ri->attr->origin) if (origin < ri->attr->origin)
origin = ri->attr->origin; origin = ri->attr->origin;
/* as-set aggregate route generate /* as-set aggregate route generate origin, as path,
origin, as path, * community aggregation. */
community aggregation. */
if (aggregate->as_set) { if (aggregate->as_set) {
if (aspath) { if (aspath) {
asmerge = aspath_aggregate( asmerge = aspath_aggregate(aspath,
aspath,
ri->attr->aspath); ri->attr->aspath);
aspath_free(aspath); aspath_free(aspath);
aspath = asmerge; aspath = asmerge;
} else } else
aspath = aspath_dup( aspath = aspath_dup(ri->attr->aspath);
ri->attr->aspath);
if (ri->attr->community) { if (ri->attr->community) {
if (community) { if (community) {
@ -5755,7 +5755,6 @@ static void bgp_aggregate_add(struct bgp *bgp, struct prefix *p, afi_t afi,
} }
aggregate->count++; aggregate->count++;
} }
}
/* If this node is suppressed, process the change. */ /* If this node is suppressed, process the change. */
if (match) if (match)
@ -5806,29 +5805,29 @@ void bgp_aggregate_delete(struct bgp *bgp, struct prefix *p, afi_t afi,
/* If routes exists below this node, generate aggregate routes. */ /* If routes exists below this node, generate aggregate routes. */
top = bgp_node_get(table, p); top = bgp_node_get(table, p);
for (rn = bgp_node_get(table, p); rn; for (rn = bgp_node_get(table, p); rn;
rn = bgp_route_next_until(rn, top)) rn = bgp_route_next_until(rn, top)) {
if (rn->p.prefixlen > p->prefixlen) { if (rn->p.prefixlen <= p->prefixlen)
continue;
match = 0; match = 0;
for (ri = rn->info; ri; ri = ri->next) { for (ri = rn->info; ri; ri = ri->next) {
if (BGP_INFO_HOLDDOWN(ri)) if (BGP_INFO_HOLDDOWN(ri))
continue; continue;
if (ri->sub_type != BGP_ROUTE_AGGREGATE) { if (ri->sub_type == BGP_ROUTE_AGGREGATE)
if (aggregate->summary_only continue;
&& ri->extra) {
if (aggregate->summary_only && ri->extra) {
ri->extra->suppress--; ri->extra->suppress--;
if (ri->extra->suppress == 0) { if (ri->extra->suppress == 0) {
bgp_info_set_flag( bgp_info_set_flag(rn, ri,
rn, ri,
BGP_INFO_ATTR_CHANGED); BGP_INFO_ATTR_CHANGED);
match++; match++;
} }
} }
aggregate->count--; aggregate->count--;
} }
}
/* If this node was suppressed, process the change. */ /* If this node was suppressed, process the change. */
if (match) if (match)
@ -8561,56 +8560,45 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
continue; continue;
if ((table = rn->info) != NULL) { if ((table = rn->info) == NULL)
continue;
header = 1; header = 1;
if ((rm = bgp_node_match(table, &match)) if ((rm = bgp_node_match(table, &match)) == NULL)
!= NULL) { continue;
if (prefix_check if (prefix_check
&& rm->p.prefixlen && rm->p.prefixlen != match.prefixlen) {
!= match.prefixlen) {
bgp_unlock_node(rm); bgp_unlock_node(rm);
continue; continue;
} }
for (ri = rm->info; ri; ri = ri->next) { for (ri = rm->info; ri; ri = ri->next) {
if (header) { if (header) {
route_vty_out_detail_header( route_vty_out_detail_header(vty, bgp,
vty, bgp, rm, rm, (struct prefix_rd *)&rn->p,
(struct AFI_IP, safi, json);
prefix_rd *)&rn
->p,
AFI_IP, safi,
json);
header = 0; header = 0;
} }
display++; display++;
if (pathtype == BGP_PATH_ALL if (pathtype == BGP_PATH_ALL
|| (pathtype || (pathtype == BGP_PATH_BESTPATH
== BGP_PATH_BESTPATH && CHECK_FLAG(ri->flags,
&& CHECK_FLAG(
ri->flags,
BGP_INFO_SELECTED)) BGP_INFO_SELECTED))
|| (pathtype || (pathtype == BGP_PATH_MULTIPATH
== BGP_PATH_MULTIPATH && (CHECK_FLAG(ri->flags,
&& (CHECK_FLAG(
ri->flags,
BGP_INFO_MULTIPATH) BGP_INFO_MULTIPATH)
|| CHECK_FLAG( || CHECK_FLAG(ri->flags,
ri->flags,
BGP_INFO_SELECTED)))) BGP_INFO_SELECTED))))
route_vty_out_detail( route_vty_out_detail(vty, bgp, &rm->p,
vty, bgp, ri, AFI_IP, safi,
&rm->p, ri,
AFI_IP, safi,
json_paths); json_paths);
} }
bgp_unlock_node(rm); bgp_unlock_node(rm);
} }
}
}
} else { } else {
header = 1; header = 1;
@ -9995,7 +9983,8 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) { for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
if (in) { if (in) {
for (ain = rn->adj_in; ain; ain = ain->next) { for (ain = rn->adj_in; ain; ain = ain->next) {
if (ain->peer == peer) { if (ain->peer != peer)
continue;
if (header1) { if (header1) {
if (use_json) { if (use_json) {
json_object_int_add( json_object_int_add(
@ -10029,28 +10018,22 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
} }
if (header2) { if (header2) {
if (!use_json) if (!use_json)
vty_out(vty, vty_out(vty, BGP_SHOW_HEADER);
BGP_SHOW_HEADER);
header2 = 0; header2 = 0;
} }
if (ain->attr) { if (ain->attr) {
bgp_attr_dup(&attr, ain->attr); bgp_attr_dup(&attr, ain->attr);
if (bgp_input_modifier( if (bgp_input_modifier(peer, &rn->p,
peer, &rn->p, &attr, &attr, afi, safi, rmap_name)
afi, safi,
rmap_name)
!= RMAP_DENY) { != RMAP_DENY) {
route_vty_out_tmp( route_vty_out_tmp(vty, &rn->p,
vty, &rn->p, &attr, safi, use_json,
&attr, safi,
use_json,
json_ar); json_ar);
output_count++; output_count++;
} else } else
filtered_count++; filtered_count++;
} }
} }
}
} else { } else {
for (adj = rn->adj_out; adj; adj = adj->next) for (adj = rn->adj_out; adj; adj = adj->next)
SUBGRP_FOREACH_PEER(adj->subgroup, paf) SUBGRP_FOREACH_PEER(adj->subgroup, paf)
@ -10856,24 +10839,20 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
rn = bgp_route_next(rn)) { rn = bgp_route_next(rn)) {
if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
continue; continue;
if ((table = rn->info) == NULL)
continue;
if ((rm = bgp_node_match(table, &match)) == NULL)
continue;
if ((table = rn->info) != NULL)
if ((rm = bgp_node_match(table, &match))
!= NULL) {
if (!prefix_check if (!prefix_check
|| rm->p.prefixlen || rm->p.prefixlen == match.prefixlen) {
== match.prefixlen) {
ri = rm->info; ri = rm->info;
while (ri) { while (ri) {
if (ri->extra if (ri->extra
&& ri->extra && ri->extra->damp_info) {
->damp_info) { ri_temp = ri->next;
ri_temp =
ri->next;
bgp_damp_info_free( bgp_damp_info_free(
ri->extra ri->extra->damp_info, 1);
->damp_info,
1);
ri = ri_temp; ri = ri_temp;
} else } else
ri = ri->next; ri = ri->next;
@ -10882,7 +10861,6 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
bgp_unlock_node(rm); bgp_unlock_node(rm);
} }
}
} else { } else {
if ((rn = bgp_node_match(bgp->rib[afi][safi], &match)) if ((rn = bgp_node_match(bgp->rib[afi][safi], &match))
!= NULL) { != NULL) {
@ -10990,39 +10968,39 @@ static void bgp_config_write_network_vpn(struct vty *vty, struct bgp *bgp,
/* Network configuration. */ /* Network configuration. */
for (prn = bgp_table_top(bgp->route[afi][safi]); prn; for (prn = bgp_table_top(bgp->route[afi][safi]); prn;
prn = bgp_route_next(prn)) prn = bgp_route_next(prn)) {
if ((table = prn->info) != NULL) if ((table = prn->info) == NULL)
continue;
for (rn = bgp_table_top(table); rn; for (rn = bgp_table_top(table); rn;
rn = bgp_route_next(rn)) rn = bgp_route_next(rn)) {
if ((bgp_static = rn->info) != NULL) { if ((bgp_static = rn->info) == NULL)
continue;
p = &rn->p; p = &rn->p;
prd = (struct prefix_rd *)&prn->p; prd = (struct prefix_rd *)&prn->p;
/* "network" configuration display. */ /* "network" configuration display. */
prefix_rd2str(prd, rdbuf, prefix_rd2str(prd, rdbuf, RD_ADDRSTRLEN);
RD_ADDRSTRLEN); label = decode_label(&bgp_static->label);
label = decode_label(
&bgp_static->label);
vty_out(vty, " network %s/%d rd %s", vty_out(vty, " network %s/%d rd %s",
inet_ntop(p->family, inet_ntop(p->family, &p->u.prefix, buf,
&p->u.prefix, buf,
SU_ADDRSTRLEN), SU_ADDRSTRLEN),
p->prefixlen, rdbuf); p->prefixlen, rdbuf);
if (safi == SAFI_MPLS_VPN) if (safi == SAFI_MPLS_VPN)
vty_out(vty, " label %u", vty_out(vty, " label %u", label);
label);
if (bgp_static->rmap.name) if (bgp_static->rmap.name)
vty_out(vty, " route-map %s", vty_out(vty, " route-map %s",
bgp_static->rmap.name); bgp_static->rmap.name);
else { else {
if (bgp_static->backdoor) if (bgp_static->backdoor)
vty_out(vty, vty_out(vty, " backdoor");
" backdoor");
} }
vty_out(vty, "\n"); vty_out(vty, "\n");
} }
}
} }
static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp, static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
@ -11040,48 +11018,45 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
/* Network configuration. */ /* Network configuration. */
for (prn = bgp_table_top(bgp->route[afi][safi]); prn; for (prn = bgp_table_top(bgp->route[afi][safi]); prn;
prn = bgp_route_next(prn)) prn = bgp_route_next(prn)) {
if ((table = prn->info) != NULL) if ((table = prn->info) == NULL)
continue;
for (rn = bgp_table_top(table); rn; for (rn = bgp_table_top(table); rn;
rn = bgp_route_next(rn)) rn = bgp_route_next(rn)) {
if ((bgp_static = rn->info) != NULL) { if ((bgp_static = rn->info) == NULL)
continue;
char *macrouter = NULL; char *macrouter = NULL;
char *esi = NULL; char *esi = NULL;
if (bgp_static->router_mac) if (bgp_static->router_mac)
macrouter = prefix_mac2str( macrouter = prefix_mac2str(
bgp_static->router_mac, bgp_static->router_mac, NULL, 0);
NULL, 0);
if (bgp_static->eth_s_id) if (bgp_static->eth_s_id)
esi = esi2str( esi = esi2str(bgp_static->eth_s_id);
bgp_static->eth_s_id);
p = &rn->p; p = &rn->p;
prd = (struct prefix_rd *)&prn->p; prd = (struct prefix_rd *)&prn->p;
/* "network" configuration display. */ /* "network" configuration display. */
prefix_rd2str(prd, rdbuf, prefix_rd2str(prd, rdbuf, RD_ADDRSTRLEN);
RD_ADDRSTRLEN);
inet_ntop(AF_INET, inet_ntop(AF_INET, &bgp_static->igpnexthop, buf2,
&bgp_static->igpnexthop, buf2,
SU_ADDRSTRLEN); SU_ADDRSTRLEN);
prefix2str(p, buf, sizeof(buf)), prefix2str(p, buf, sizeof(buf));
vty_out(vty, vty_out(vty,
" network %s rd %s ethtag %u tag %u esi %s gwip %s routermac %s", " network %s rd %s ethtag %u tag %u esi %s gwip %s routermac %s\n",
buf, rdbuf, buf, rdbuf, p->u.prefix_evpn .eth_tag,
p->u.prefix_evpn decode_label(&bgp_static ->label), esi, buf2,
.eth_tag, macrouter);
decode_label(
&bgp_static
->label),
esi, buf2, macrouter);
vty_out(vty, "\n");
if (macrouter) if (macrouter)
XFREE(MTYPE_TMP, macrouter); XFREE(MTYPE_TMP, macrouter);
if (esi) if (esi)
XFREE(MTYPE_TMP, esi); XFREE(MTYPE_TMP, esi);
} }
}
} }
/* Configuration of static route announcement and aggregate /* Configuration of static route announcement and aggregate
@ -11107,8 +11082,10 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
/* Network configuration. */ /* Network configuration. */
for (rn = bgp_table_top(bgp->route[afi][safi]); rn; for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
rn = bgp_route_next(rn)) rn = bgp_route_next(rn)) {
if ((bgp_static = rn->info) != NULL) { if ((bgp_static = rn->info) == NULL)
continue;
p = &rn->p; p = &rn->p;
/* "network" configuration display. */ /* "network" configuration display. */
@ -11123,17 +11100,13 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
inet_ntop(p->family, &p->u.prefix, buf, inet_ntop(p->family, &p->u.prefix, buf,
SU_ADDRSTRLEN)); SU_ADDRSTRLEN));
if ((IN_CLASSC(destination) if ((IN_CLASSC(destination) && p->prefixlen == 24)
&& p->prefixlen == 24) || (IN_CLASSB(destination) && p->prefixlen == 16)
|| (IN_CLASSB(destination) || (IN_CLASSA(destination) && p->prefixlen == 8)
&& p->prefixlen == 16)
|| (IN_CLASSA(destination)
&& p->prefixlen == 8)
|| p->u.prefix4.s_addr == 0) { || p->u.prefix4.s_addr == 0) {
/* Natural mask is not display. */ /* Natural mask is not display. */
} else } else
vty_out(vty, " mask %s", vty_out(vty, " mask %s", inet_ntoa(netmask));
inet_ntoa(netmask));
} else { } else {
vty_out(vty, " network %s/%d", vty_out(vty, " network %s/%d",
inet_ntop(p->family, &p->u.prefix, buf, inet_ntop(p->family, &p->u.prefix, buf,
@ -11146,8 +11119,7 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
bgp_static->label_index); bgp_static->label_index);
if (bgp_static->rmap.name) if (bgp_static->rmap.name)
vty_out(vty, " route-map %s", vty_out(vty, " route-map %s", bgp_static->rmap.name);
bgp_static->rmap.name);
else { else {
if (bgp_static->backdoor) if (bgp_static->backdoor)
vty_out(vty, " backdoor"); vty_out(vty, " backdoor");
@ -11158,12 +11130,13 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
/* Aggregate-address configuration. */ /* Aggregate-address configuration. */
for (rn = bgp_table_top(bgp->aggregate[afi][safi]); rn; for (rn = bgp_table_top(bgp->aggregate[afi][safi]); rn;
rn = bgp_route_next(rn)) rn = bgp_route_next(rn)) {
if ((bgp_aggregate = rn->info) != NULL) { if ((bgp_aggregate = rn->info) == NULL)
continue;
p = &rn->p; p = &rn->p;
if (bgp_option_check(BGP_OPT_CONFIG_CISCO) if (bgp_option_check(BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) {
&& afi == AFI_IP) {
struct in_addr netmask; struct in_addr netmask;
masklen2ip(p->prefixlen, &netmask); masklen2ip(p->prefixlen, &netmask);

View File

@ -6610,7 +6610,9 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
continue; continue;
if (peer->afc[afi][safi]) { if (!peer->afc[afi][safi])
continue;
if (!count) { if (!count) {
unsigned long ents; unsigned long ents;
char memstrbuf[MTYPE_MEMSTR_LEN]; char memstrbuf[MTYPE_MEMSTR_LEN];
@ -6972,7 +6974,6 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
vty_out(vty, "\n"); vty_out(vty, "\n");
} }
} }
}
if (use_json) { if (use_json) {
json_object_object_add(json, "peers", json_peers); json_object_object_add(json, "peers", json_peers);