for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
for (ain = rn->adj_in; ain; ain = ain->next) {
- if (ain->peer == peer) {
- struct bgp_info *ri = rn->info;
- mpls_label_t label =
- (ri && ri->extra) ? ri->extra->label
- : MPLS_INVALID_LABEL;
+ if (ain->peer != peer)
+ continue;
- ret = bgp_update(
- peer, &rn->p, ain->addpath_rx_id,
- ain->attr, afi, safi, ZEBRA_ROUTE_BGP,
- BGP_ROUTE_NORMAL, prd, &label, 1, NULL);
+ struct bgp_info *ri = rn->info;
+ mpls_label_t label =
+ (ri && ri->extra) ? ri->extra->label
+ : MPLS_INVALID_LABEL;
- if (ret < 0) {
- bgp_unlock_node(rn);
- return;
- }
+ ret = bgp_update(peer, &rn->p, ain->addpath_rx_id,
+ ain->attr, afi, safi, ZEBRA_ROUTE_BGP,
+ BGP_ROUTE_NORMAL, prd, &label, 1,
+ NULL);
+
+ if (ret < 0) {
+ bgp_unlock_node(rn);
+ return;
}
}
}
/* It is possible that we have multiple paths for a prefix from a peer
* if that peer is using AddPath.
*/
- for (ri = rn->info; ri; ri = ri->next)
- if (ri->peer == peer) {
- /* graceful restart STALE flag set. */
- if (CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT)
- && peer->nsf[afi][safi]
- && !CHECK_FLAG(ri->flags, BGP_INFO_STALE)
- && !CHECK_FLAG(ri->flags, BGP_INFO_UNUSEABLE))
- bgp_info_set_flag(rn, ri, BGP_INFO_STALE);
- else {
- /* If this is an EVPN route, process for
- * un-import. */
- if (safi == SAFI_EVPN)
- bgp_evpn_unimport_route(peer->bgp, afi,
- safi, &rn->p,
- ri);
- bgp_rib_remove(rn, ri, peer, afi, safi);
- }
+ for (ri = rn->info; ri; ri = ri->next) {
+ if (ri->peer != peer)
+ continue;
+
+ /* graceful restart STALE flag set. */
+ if (CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT)
+ && peer->nsf[afi][safi]
+ && !CHECK_FLAG(ri->flags, BGP_INFO_STALE)
+ && !CHECK_FLAG(ri->flags, BGP_INFO_UNUSEABLE))
+ bgp_info_set_flag(rn, ri, BGP_INFO_STALE);
+ else {
+ /* If this is an EVPN route, process for
+ * un-import. */
+ if (safi == SAFI_EVPN)
+ bgp_evpn_unimport_route(peer->bgp, afi, safi,
+ &rn->p, ri);
+ bgp_rib_remove(rn, ri, peer, afi, safi);
}
+ }
return WQ_SUCCESS;
}
struct bgp_info *ri;
/* look for neighbor in tables */
- if ((table = rn->info) != NULL) {
- for (rm = bgp_table_top(table); rm;
- rm = bgp_route_next(rm))
- for (ri = rm->info; ri; ri = ri->next)
- if (ri->peer == peer) {
- if (CHECK_FLAG(
- ri->flags,
- BGP_INFO_STALE))
- bgp_rib_remove(
- rm, ri,
- peer,
- afi,
- safi);
- break;
- }
- }
+ if ((table = rn->info) == NULL)
+ continue;
+
+ for (rm = bgp_table_top(table); rm;
+ rm = bgp_route_next(rm))
+ for (ri = rm->info; ri; ri = ri->next) {
+ if (ri->peer != peer)
+ continue;
+ if (!CHECK_FLAG(ri->flags,
+ BGP_INFO_STALE))
+ break;
+
+ bgp_rib_remove(rm, ri, peer, afi, safi);
+ break;
+ }
}
} else {
for (rn = bgp_table_top(peer->bgp->rib[afi][safi]); rn;
rn = bgp_route_next(rn))
- for (ri = rn->info; ri; ri = ri->next)
- if (ri->peer == peer) {
- if (CHECK_FLAG(ri->flags,
- BGP_INFO_STALE))
- bgp_rib_remove(rn, ri, peer,
- afi, safi);
+ for (ri = rn->info; ri; ri = ri->next) {
+ if (ri->peer != peer)
+ continue;
+ if (!CHECK_FLAG(ri->flags, BGP_INFO_STALE))
break;
- }
+ bgp_rib_remove(rn, ri, peer, afi, safi);
+ break;
+ }
}
}
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
- rn = bgp_route_next(rn))
- if (rn->info != NULL) {
- if ((safi == SAFI_MPLS_VPN)
- || (safi == SAFI_ENCAP)
- || (safi == SAFI_EVPN)) {
- table = rn->info;
-
- for (rm = bgp_table_top(table);
- rm;
- rm = bgp_route_next(rm)) {
- bgp_static = rm->info;
- bgp_static_update_safi(
- bgp, &rm->p,
- bgp_static, afi,
- safi);
- }
- } else {
- bgp_static_update(bgp, &rn->p,
- rn->info, afi,
- safi);
+ rn = bgp_route_next(rn)) {
+ if (rn->info == NULL)
+ continue;
+
+ if ((safi == SAFI_MPLS_VPN)
+ || (safi == SAFI_ENCAP)
+ || (safi == SAFI_EVPN)) {
+ table = rn->info;
+
+ for (rm = bgp_table_top(table);
+ rm;
+ rm = bgp_route_next(rm)) {
+ bgp_static = rm->info;
+ bgp_static_update_safi(
+ bgp, &rm->p,
+ bgp_static, afi,
+ safi);
}
+ } else {
+ bgp_static_update(bgp, &rn->p,
+ rn->info, afi,
+ safi);
}
+ }
}
/* Called from bgp_delete(). Delete all static routes from the BGP
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
- rn = bgp_route_next(rn))
- if (rn->info != NULL) {
- if ((safi == SAFI_MPLS_VPN)
- || (safi == SAFI_ENCAP)
- || (safi == SAFI_EVPN)) {
- table = rn->info;
-
- for (rm = bgp_table_top(table);
- rm;
- rm = bgp_route_next(rm)) {
- bgp_static = rm->info;
- bgp_static_withdraw_safi(
- bgp, &rm->p,
- AFI_IP, safi,
- (struct
- prefix_rd *)&rn
- ->p);
- bgp_static_free(
- bgp_static);
- rn->info = NULL;
- bgp_unlock_node(rn);
- }
- } else {
- bgp_static = rn->info;
- bgp_static_withdraw(bgp, &rn->p,
- afi, safi);
+ rn = bgp_route_next(rn)) {
+ if (rn->info == NULL)
+ continue;
+
+ if ((safi == SAFI_MPLS_VPN)
+ || (safi == SAFI_ENCAP)
+ || (safi == SAFI_EVPN)) {
+ table = rn->info;
+
+ for (rm = bgp_table_top(table);
+ rm;
+ rm = bgp_route_next(rm)) {
+ bgp_static = rm->info;
+ bgp_static_withdraw_safi(
+ bgp, &rm->p,
+ AFI_IP, safi,
+ (struct
+ prefix_rd *)&rn
+ ->p);
bgp_static_free(bgp_static);
rn->info = NULL;
bgp_unlock_node(rn);
}
+ } else {
+ bgp_static = rn->info;
+ bgp_static_withdraw(bgp, &rn->p,
+ afi, safi);
+ bgp_static_free(bgp_static);
+ rn->info = NULL;
+ bgp_unlock_node(rn);
}
+ }
}
void bgp_static_redo_import_check(struct bgp *bgp)
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
- rn = bgp_route_next(rn))
- if (rn->info != NULL) {
- if ((safi == SAFI_MPLS_VPN)
- || (safi == SAFI_ENCAP)
- || (safi == SAFI_EVPN)) {
- table = rn->info;
-
- for (rm = bgp_table_top(table);
- rm;
- rm = bgp_route_next(rm)) {
- bgp_static = rm->info;
- bgp_static_update_safi(
- bgp, &rm->p,
- bgp_static, afi,
- safi);
- }
- } else {
- bgp_static = rn->info;
- bgp_static_update(bgp, &rn->p,
- bgp_static,
- afi, safi);
+ rn = bgp_route_next(rn)) {
+ if (rn->info == NULL)
+ continue;
+
+ if ((safi == SAFI_MPLS_VPN)
+ || (safi == SAFI_ENCAP)
+ || (safi == SAFI_EVPN)) {
+ table = rn->info;
+
+ for (rm = bgp_table_top(table);
+ rm;
+ rm = bgp_route_next(rm)) {
+ bgp_static = rm->info;
+ bgp_static_update_safi(
+ bgp, &rm->p,
+ bgp_static, afi,
+ safi);
}
+ } else {
+ bgp_static = rn->info;
+ bgp_static_update(bgp, &rn->p,
+ bgp_static,
+ afi, safi);
}
+ }
bgp_flag_unset(bgp, BGP_FLAG_FORCE_STATIC_PROCESS);
}
/* If routes exists below this node, generate aggregate routes. */
top = bgp_node_get(table, p);
for (rn = bgp_node_get(table, p); rn;
- rn = bgp_route_next_until(rn, top))
- if (rn->p.prefixlen > p->prefixlen) {
- match = 0;
+ rn = bgp_route_next_until(rn, top)) {
+ if (rn->p.prefixlen <= p->prefixlen)
+ continue;
- for (ri = rn->info; ri; ri = ri->next) {
- if (BGP_INFO_HOLDDOWN(ri))
- continue;
+ match = 0;
- if (ri->attr->flag
- & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
- atomic_aggregate = 1;
+ for (ri = rn->info; ri; ri = ri->next) {
+ if (BGP_INFO_HOLDDOWN(ri))
+ continue;
- if (ri->sub_type != BGP_ROUTE_AGGREGATE) {
- /* summary-only aggregate route suppress
- aggregated
- route announcement. */
- if (aggregate->summary_only) {
- (bgp_info_extra_get(ri))
- ->suppress++;
- bgp_info_set_flag(
- rn, ri,
- BGP_INFO_ATTR_CHANGED);
- match++;
- }
+ if (ri->attr->flag
+ & ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE))
+ atomic_aggregate = 1;
- /* If at least one route among routes
- * that are aggregated has
- * ORIGIN with the value INCOMPLETE,
- * then the aggregated route
- * MUST have the ORIGIN attribute with
- * the value INCOMPLETE.
- * Otherwise, if at least one route
- * among routes that are
- * 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)
- origin = ri->attr->origin;
+ if (ri->sub_type == BGP_ROUTE_AGGREGATE)
+ continue;
- /* as-set aggregate route generate
- origin, as path,
- community aggregation. */
- if (aggregate->as_set) {
- if (aspath) {
- asmerge = aspath_aggregate(
- aspath,
- ri->attr->aspath);
- aspath_free(aspath);
- aspath = asmerge;
- } else
- aspath = aspath_dup(
- ri->attr->aspath);
+ /* summary-only aggregate route suppress
+ * aggregated route announcement. */
+ if (aggregate->summary_only) {
+ (bgp_info_extra_get(ri))->suppress++;
+ bgp_info_set_flag(rn, ri,
+ BGP_INFO_ATTR_CHANGED);
+ match++;
+ }
- if (ri->attr->community) {
- if (community) {
- commerge = community_merge(
- community,
- ri->attr->community);
- community = community_uniq_sort(
- commerge);
- community_free(
- commerge);
- } else
- community = community_dup(
- ri->attr->community);
- }
- }
- aggregate->count++;
+ /* If at least one route among routes that are
+ * aggregated has ORIGIN with the value INCOMPLETE,
+ * then the aggregated route MUST have the ORIGIN
+ * attribute with the value INCOMPLETE. Otherwise, if
+ * at least one route among routes that are 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)
+ origin = ri->attr->origin;
+
+ /* as-set aggregate route generate origin, as path,
+ * community aggregation. */
+ if (aggregate->as_set) {
+ if (aspath) {
+ asmerge = aspath_aggregate(aspath,
+ ri->attr->aspath);
+ aspath_free(aspath);
+ aspath = asmerge;
+ } else
+ aspath = aspath_dup(ri->attr->aspath);
+
+ if (ri->attr->community) {
+ if (community) {
+ commerge = community_merge(
+ community,
+ ri->attr->community);
+ community = community_uniq_sort(
+ commerge);
+ community_free(
+ commerge);
+ } else
+ community = community_dup(
+ ri->attr->community);
}
}
-
- /* If this node is suppressed, process the change. */
- if (match)
- bgp_process(bgp, rn, afi, safi);
+ aggregate->count++;
}
+
+ /* If this node is suppressed, process the change. */
+ if (match)
+ bgp_process(bgp, rn, afi, safi);
+ }
bgp_unlock_node(top);
/* Add aggregate route to BGP table. */
/* If routes exists below this node, generate aggregate routes. */
top = bgp_node_get(table, p);
for (rn = bgp_node_get(table, p); rn;
- rn = bgp_route_next_until(rn, top))
- if (rn->p.prefixlen > p->prefixlen) {
- match = 0;
+ rn = bgp_route_next_until(rn, top)) {
+ if (rn->p.prefixlen <= p->prefixlen)
+ continue;
+ match = 0;
- for (ri = rn->info; ri; ri = ri->next) {
- if (BGP_INFO_HOLDDOWN(ri))
- continue;
+ for (ri = rn->info; ri; ri = ri->next) {
+ if (BGP_INFO_HOLDDOWN(ri))
+ continue;
- if (ri->sub_type != BGP_ROUTE_AGGREGATE) {
- if (aggregate->summary_only
- && ri->extra) {
- ri->extra->suppress--;
-
- if (ri->extra->suppress == 0) {
- bgp_info_set_flag(
- rn, ri,
- BGP_INFO_ATTR_CHANGED);
- match++;
- }
- }
- aggregate->count--;
+ if (ri->sub_type == BGP_ROUTE_AGGREGATE)
+ continue;
+
+ if (aggregate->summary_only && ri->extra) {
+ ri->extra->suppress--;
+
+ if (ri->extra->suppress == 0) {
+ bgp_info_set_flag(rn, ri,
+ BGP_INFO_ATTR_CHANGED);
+ match++;
}
}
-
- /* If this node was suppressed, process the change. */
- if (match)
- bgp_process(bgp, rn, afi, safi);
+ aggregate->count--;
}
+
+ /* If this node was suppressed, process the change. */
+ if (match)
+ bgp_process(bgp, rn, afi, safi);
+ }
bgp_unlock_node(top);
/* Delete aggregate route from BGP table. */
if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
continue;
- if ((table = rn->info) != NULL) {
- header = 1;
-
- if ((rm = bgp_node_match(table, &match))
- != NULL) {
- if (prefix_check
- && rm->p.prefixlen
- != match.prefixlen) {
- bgp_unlock_node(rm);
- continue;
- }
+ if ((table = rn->info) == NULL)
+ continue;
- for (ri = rm->info; ri; ri = ri->next) {
- if (header) {
- route_vty_out_detail_header(
- vty, bgp, rm,
- (struct
- prefix_rd *)&rn
- ->p,
- AFI_IP, safi,
- json);
- header = 0;
- }
- display++;
-
- if (pathtype == BGP_PATH_ALL
- || (pathtype
- == BGP_PATH_BESTPATH
- && CHECK_FLAG(
- ri->flags,
- BGP_INFO_SELECTED))
- || (pathtype
- == BGP_PATH_MULTIPATH
- && (CHECK_FLAG(
- ri->flags,
- BGP_INFO_MULTIPATH)
- || CHECK_FLAG(
- ri->flags,
- BGP_INFO_SELECTED))))
- route_vty_out_detail(
- vty, bgp,
- &rm->p, ri,
- AFI_IP, safi,
- json_paths);
- }
+ header = 1;
+
+ if ((rm = bgp_node_match(table, &match)) == NULL)
+ continue;
- bgp_unlock_node(rm);
+ if (prefix_check
+ && rm->p.prefixlen != match.prefixlen) {
+ bgp_unlock_node(rm);
+ continue;
+ }
+
+ for (ri = rm->info; ri; ri = ri->next) {
+ if (header) {
+ route_vty_out_detail_header(vty, bgp,
+ rm, (struct prefix_rd *)&rn->p,
+ AFI_IP, safi, json);
+ header = 0;
}
+ display++;
+
+ if (pathtype == BGP_PATH_ALL
+ || (pathtype == BGP_PATH_BESTPATH
+ && CHECK_FLAG(ri->flags,
+ BGP_INFO_SELECTED))
+ || (pathtype == BGP_PATH_MULTIPATH
+ && (CHECK_FLAG(ri->flags,
+ BGP_INFO_MULTIPATH)
+ || CHECK_FLAG(ri->flags,
+ BGP_INFO_SELECTED))))
+ route_vty_out_detail(vty, bgp, &rm->p,
+ ri, AFI_IP, safi,
+ json_paths);
}
+
+ bgp_unlock_node(rm);
}
} else {
header = 1;
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
if (in) {
for (ain = rn->adj_in; ain; ain = ain->next) {
- if (ain->peer == peer) {
- if (header1) {
- if (use_json) {
- json_object_int_add(
- json,
- "bgpTableVersion",
- 0);
- json_object_string_add(
- json,
- "bgpLocalRouterId",
- inet_ntoa(
- bgp->router_id));
- json_object_object_add(
- json,
- "bgpStatusCodes",
- json_scode);
- json_object_object_add(
- json,
- "bgpOriginCodes",
- json_ocode);
- } else {
- vty_out(vty,
- "BGP table version is 0, local router ID is %s\n",
- inet_ntoa(
- bgp->router_id));
- vty_out(vty,
- BGP_SHOW_SCODE_HEADER);
- vty_out(vty,
- BGP_SHOW_OCODE_HEADER);
- }
- header1 = 0;
- }
- if (header2) {
- if (!use_json)
- vty_out(vty,
- BGP_SHOW_HEADER);
- header2 = 0;
- }
- if (ain->attr) {
- bgp_attr_dup(&attr, ain->attr);
- if (bgp_input_modifier(
- peer, &rn->p, &attr,
- afi, safi,
- rmap_name)
- != RMAP_DENY) {
- route_vty_out_tmp(
- vty, &rn->p,
- &attr, safi,
- use_json,
- json_ar);
- output_count++;
- } else
- filtered_count++;
+ if (ain->peer != peer)
+ continue;
+ if (header1) {
+ if (use_json) {
+ json_object_int_add(
+ json,
+ "bgpTableVersion",
+ 0);
+ json_object_string_add(
+ json,
+ "bgpLocalRouterId",
+ inet_ntoa(
+ bgp->router_id));
+ json_object_object_add(
+ json,
+ "bgpStatusCodes",
+ json_scode);
+ json_object_object_add(
+ json,
+ "bgpOriginCodes",
+ json_ocode);
+ } else {
+ vty_out(vty,
+ "BGP table version is 0, local router ID is %s\n",
+ inet_ntoa(
+ bgp->router_id));
+ vty_out(vty,
+ BGP_SHOW_SCODE_HEADER);
+ vty_out(vty,
+ BGP_SHOW_OCODE_HEADER);
}
+ header1 = 0;
+ }
+ if (header2) {
+ if (!use_json)
+ vty_out(vty, BGP_SHOW_HEADER);
+ header2 = 0;
+ }
+ if (ain->attr) {
+ bgp_attr_dup(&attr, ain->attr);
+ if (bgp_input_modifier(peer, &rn->p,
+ &attr, afi, safi, rmap_name)
+ != RMAP_DENY) {
+ route_vty_out_tmp(vty, &rn->p,
+ &attr, safi, use_json,
+ json_ar);
+ output_count++;
+ } else
+ filtered_count++;
}
}
} else {
rn = bgp_route_next(rn)) {
if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
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
- || rm->p.prefixlen
- == match.prefixlen) {
- ri = rm->info;
- while (ri) {
- if (ri->extra
- && ri->extra
- ->damp_info) {
- ri_temp =
- ri->next;
- bgp_damp_info_free(
- ri->extra
- ->damp_info,
- 1);
- ri = ri_temp;
- } else
- ri = ri->next;
- }
- }
-
- bgp_unlock_node(rm);
+ if (!prefix_check
+ || rm->p.prefixlen == match.prefixlen) {
+ ri = rm->info;
+ while (ri) {
+ if (ri->extra
+ && ri->extra->damp_info) {
+ ri_temp = ri->next;
+ bgp_damp_info_free(
+ ri->extra->damp_info, 1);
+ ri = ri_temp;
+ } else
+ ri = ri->next;
}
+ }
+
+ bgp_unlock_node(rm);
}
} else {
if ((rn = bgp_node_match(bgp->rib[afi][safi], &match))
/* Network configuration. */
for (prn = bgp_table_top(bgp->route[afi][safi]); prn;
- prn = bgp_route_next(prn))
- if ((table = prn->info) != NULL)
- for (rn = bgp_table_top(table); rn;
- rn = bgp_route_next(rn))
- if ((bgp_static = rn->info) != NULL) {
- p = &rn->p;
- prd = (struct prefix_rd *)&prn->p;
+ prn = bgp_route_next(prn)) {
+ if ((table = prn->info) == NULL)
+ continue;
- /* "network" configuration display. */
- prefix_rd2str(prd, rdbuf,
- RD_ADDRSTRLEN);
- label = decode_label(
- &bgp_static->label);
+ for (rn = bgp_table_top(table); rn;
+ rn = bgp_route_next(rn)) {
+ if ((bgp_static = rn->info) == NULL)
+ continue;
- vty_out(vty, " network %s/%d rd %s",
- inet_ntop(p->family,
- &p->u.prefix, buf,
- SU_ADDRSTRLEN),
- p->prefixlen, rdbuf);
- if (safi == SAFI_MPLS_VPN)
- vty_out(vty, " label %u",
- label);
-
- if (bgp_static->rmap.name)
- vty_out(vty, " route-map %s",
- bgp_static->rmap.name);
- else {
- if (bgp_static->backdoor)
- vty_out(vty,
- " backdoor");
- }
- vty_out(vty, "\n");
- }
+ p = &rn->p;
+ prd = (struct prefix_rd *)&prn->p;
+
+ /* "network" configuration display. */
+ prefix_rd2str(prd, rdbuf, RD_ADDRSTRLEN);
+ label = decode_label(&bgp_static->label);
+
+ vty_out(vty, " network %s/%d rd %s",
+ inet_ntop(p->family, &p->u.prefix, buf,
+ SU_ADDRSTRLEN),
+ p->prefixlen, rdbuf);
+ if (safi == SAFI_MPLS_VPN)
+ vty_out(vty, " label %u", label);
+
+ if (bgp_static->rmap.name)
+ vty_out(vty, " route-map %s",
+ bgp_static->rmap.name);
+ else {
+ if (bgp_static->backdoor)
+ vty_out(vty, " backdoor");
+ }
+ vty_out(vty, "\n");
+ }
+ }
}
static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
/* Network configuration. */
for (prn = bgp_table_top(bgp->route[afi][safi]); prn;
- prn = bgp_route_next(prn))
- if ((table = prn->info) != NULL)
- for (rn = bgp_table_top(table); rn;
- rn = bgp_route_next(rn))
- if ((bgp_static = rn->info) != NULL) {
- char *macrouter = NULL;
- char *esi = NULL;
-
- if (bgp_static->router_mac)
- macrouter = prefix_mac2str(
- bgp_static->router_mac,
- NULL, 0);
- if (bgp_static->eth_s_id)
- esi = esi2str(
- bgp_static->eth_s_id);
- p = &rn->p;
- prd = (struct prefix_rd *)&prn->p;
+ prn = bgp_route_next(prn)) {
+ if ((table = prn->info) == NULL)
+ continue;
- /* "network" configuration display. */
- prefix_rd2str(prd, rdbuf,
- RD_ADDRSTRLEN);
+ for (rn = bgp_table_top(table); rn;
+ rn = bgp_route_next(rn)) {
+ if ((bgp_static = rn->info) == NULL)
+ continue;
- inet_ntop(AF_INET,
- &bgp_static->igpnexthop, buf2,
- SU_ADDRSTRLEN);
+ char *macrouter = NULL;
+ char *esi = NULL;
- prefix2str(p, buf, sizeof(buf)),
- vty_out(vty,
- " network %s rd %s ethtag %u tag %u esi %s gwip %s routermac %s",
- buf, rdbuf,
- p->u.prefix_evpn
- .eth_tag,
- decode_label(
- &bgp_static
- ->label),
- esi, buf2, macrouter);
- vty_out(vty, "\n");
- if (macrouter)
- XFREE(MTYPE_TMP, macrouter);
- if (esi)
- XFREE(MTYPE_TMP, esi);
- }
+ if (bgp_static->router_mac)
+ macrouter = prefix_mac2str(
+ bgp_static->router_mac, NULL, 0);
+ if (bgp_static->eth_s_id)
+ esi = esi2str(bgp_static->eth_s_id);
+ p = &rn->p;
+ prd = (struct prefix_rd *)&prn->p;
+
+ /* "network" configuration display. */
+ prefix_rd2str(prd, rdbuf, RD_ADDRSTRLEN);
+
+ inet_ntop(AF_INET, &bgp_static->igpnexthop, buf2,
+ SU_ADDRSTRLEN);
+
+ prefix2str(p, buf, sizeof(buf));
+ vty_out(vty,
+ " network %s rd %s ethtag %u tag %u esi %s gwip %s routermac %s\n",
+ buf, rdbuf, p->u.prefix_evpn .eth_tag,
+ decode_label(&bgp_static ->label), esi, buf2,
+ macrouter);
+
+ if (macrouter)
+ XFREE(MTYPE_TMP, macrouter);
+ if (esi)
+ XFREE(MTYPE_TMP, esi);
+ }
+ }
}
/* Configuration of static route announcement and aggregate
/* Network configuration. */
for (rn = bgp_table_top(bgp->route[afi][safi]); rn;
- rn = bgp_route_next(rn))
- if ((bgp_static = rn->info) != NULL) {
- p = &rn->p;
-
- /* "network" configuration display. */
- if (bgp_option_check(BGP_OPT_CONFIG_CISCO)
- && afi == AFI_IP) {
- u_int32_t destination;
- struct in_addr netmask;
-
- destination = ntohl(p->u.prefix4.s_addr);
- masklen2ip(p->prefixlen, &netmask);
- vty_out(vty, " network %s",
- inet_ntop(p->family, &p->u.prefix, buf,
- SU_ADDRSTRLEN));
-
- if ((IN_CLASSC(destination)
- && p->prefixlen == 24)
- || (IN_CLASSB(destination)
- && p->prefixlen == 16)
- || (IN_CLASSA(destination)
- && p->prefixlen == 8)
- || p->u.prefix4.s_addr == 0) {
- /* Natural mask is not display. */
- } else
- vty_out(vty, " mask %s",
- inet_ntoa(netmask));
- } else {
- vty_out(vty, " network %s/%d",
- inet_ntop(p->family, &p->u.prefix, buf,
- SU_ADDRSTRLEN),
- p->prefixlen);
- }
+ rn = bgp_route_next(rn)) {
+ if ((bgp_static = rn->info) == NULL)
+ continue;
- if (bgp_static->label_index != BGP_INVALID_LABEL_INDEX)
- vty_out(vty, " label-index %u",
- bgp_static->label_index);
+ p = &rn->p;
+
+ /* "network" configuration display. */
+ if (bgp_option_check(BGP_OPT_CONFIG_CISCO)
+ && afi == AFI_IP) {
+ u_int32_t destination;
+ struct in_addr netmask;
+
+ destination = ntohl(p->u.prefix4.s_addr);
+ masklen2ip(p->prefixlen, &netmask);
+ vty_out(vty, " network %s",
+ inet_ntop(p->family, &p->u.prefix, buf,
+ SU_ADDRSTRLEN));
+
+ if ((IN_CLASSC(destination) && p->prefixlen == 24)
+ || (IN_CLASSB(destination) && p->prefixlen == 16)
+ || (IN_CLASSA(destination) && p->prefixlen == 8)
+ || p->u.prefix4.s_addr == 0) {
+ /* Natural mask is not display. */
+ } else
+ vty_out(vty, " mask %s", inet_ntoa(netmask));
+ } else {
+ vty_out(vty, " network %s/%d",
+ inet_ntop(p->family, &p->u.prefix, buf,
+ SU_ADDRSTRLEN),
+ p->prefixlen);
+ }
- if (bgp_static->rmap.name)
- vty_out(vty, " route-map %s",
- bgp_static->rmap.name);
- else {
- if (bgp_static->backdoor)
- vty_out(vty, " backdoor");
- }
+ if (bgp_static->label_index != BGP_INVALID_LABEL_INDEX)
+ vty_out(vty, " label-index %u",
+ bgp_static->label_index);
- vty_out(vty, "\n");
+ if (bgp_static->rmap.name)
+ vty_out(vty, " route-map %s", bgp_static->rmap.name);
+ else {
+ if (bgp_static->backdoor)
+ vty_out(vty, " backdoor");
}
+ vty_out(vty, "\n");
+ }
+
/* Aggregate-address configuration. */
for (rn = bgp_table_top(bgp->aggregate[afi][safi]); rn;
- rn = bgp_route_next(rn))
- if ((bgp_aggregate = rn->info) != NULL) {
- p = &rn->p;
+ rn = bgp_route_next(rn)) {
+ if ((bgp_aggregate = rn->info) == NULL)
+ continue;
- if (bgp_option_check(BGP_OPT_CONFIG_CISCO)
- && afi == AFI_IP) {
- struct in_addr netmask;
+ p = &rn->p;
- masklen2ip(p->prefixlen, &netmask);
- vty_out(vty, " aggregate-address %s %s",
- inet_ntop(p->family, &p->u.prefix, buf,
- SU_ADDRSTRLEN),
- inet_ntoa(netmask));
- } else {
- vty_out(vty, " aggregate-address %s/%d",
- inet_ntop(p->family, &p->u.prefix, buf,
- SU_ADDRSTRLEN),
- p->prefixlen);
- }
+ if (bgp_option_check(BGP_OPT_CONFIG_CISCO) && afi == AFI_IP) {
+ struct in_addr netmask;
- if (bgp_aggregate->as_set)
- vty_out(vty, " as-set");
+ masklen2ip(p->prefixlen, &netmask);
+ vty_out(vty, " aggregate-address %s %s",
+ inet_ntop(p->family, &p->u.prefix, buf,
+ SU_ADDRSTRLEN),
+ inet_ntoa(netmask));
+ } else {
+ vty_out(vty, " aggregate-address %s/%d",
+ inet_ntop(p->family, &p->u.prefix, buf,
+ SU_ADDRSTRLEN),
+ p->prefixlen);
+ }
- if (bgp_aggregate->summary_only)
- vty_out(vty, " summary-only");
+ if (bgp_aggregate->as_set)
+ vty_out(vty, " as-set");
- vty_out(vty, "\n");
- }
+ if (bgp_aggregate->summary_only)
+ vty_out(vty, " summary-only");
+
+ vty_out(vty, "\n");
+ }
}
void bgp_config_write_distance(struct vty *vty, struct bgp *bgp, afi_t afi,
if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
continue;
- if (peer->afc[afi][safi]) {
- if (!count) {
- unsigned long ents;
- char memstrbuf[MTYPE_MEMSTR_LEN];
- int vrf_id_ui;
+ if (!peer->afc[afi][safi])
+ continue;
- vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN)
- ? -1
- : bgp->vrf_id;
+ if (!count) {
+ unsigned long ents;
+ char memstrbuf[MTYPE_MEMSTR_LEN];
+ int vrf_id_ui;
+
+ vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN)
+ ? -1
+ : bgp->vrf_id;
- /* Usage summary and header */
+ /* Usage summary and header */
+ if (use_json) {
+ json_object_string_add(
+ json, "routerId",
+ inet_ntoa(bgp->router_id));
+ json_object_int_add(json, "as",
+ bgp->as);
+ json_object_int_add(json, "vrfId",
+ vrf_id_ui);
+ json_object_string_add(
+ json, "vrfName",
+ (bgp->inst_type
+ == BGP_INSTANCE_TYPE_DEFAULT)
+ ? "Default"
+ : bgp->name);
+ } else {
+ vty_out(vty,
+ "BGP router identifier %s, local AS number %u vrf-id %d",
+ inet_ntoa(bgp->router_id),
+ bgp->as, vrf_id_ui);
+ vty_out(vty, "\n");
+ }
+
+ if (bgp_update_delay_configured(bgp)) {
if (use_json) {
- json_object_string_add(
- json, "routerId",
- inet_ntoa(bgp->router_id));
- json_object_int_add(json, "as",
- bgp->as);
- json_object_int_add(json, "vrfId",
- vrf_id_ui);
- json_object_string_add(
- json, "vrfName",
- (bgp->inst_type
- == BGP_INSTANCE_TYPE_DEFAULT)
- ? "Default"
- : bgp->name);
- } else {
- vty_out(vty,
- "BGP router identifier %s, local AS number %u vrf-id %d",
- inet_ntoa(bgp->router_id),
- bgp->as, vrf_id_ui);
- vty_out(vty, "\n");
- }
+ json_object_int_add(
+ json,
+ "updateDelayLimit",
+ bgp->v_update_delay);
- if (bgp_update_delay_configured(bgp)) {
- if (use_json) {
+ if (bgp->v_update_delay
+ != bgp->v_establish_wait)
json_object_int_add(
json,
- "updateDelayLimit",
- bgp->v_update_delay);
+ "updateDelayEstablishWait",
+ bgp->v_establish_wait);
- if (bgp->v_update_delay
- != bgp->v_establish_wait)
- json_object_int_add(
- json,
- "updateDelayEstablishWait",
- bgp->v_establish_wait);
-
- if (bgp_update_delay_active(
- bgp)) {
+ if (bgp_update_delay_active(
+ bgp)) {
+ json_object_string_add(
+ json,
+ "updateDelayFirstNeighbor",
+ bgp->update_delay_begin_time);
+ json_object_boolean_true_add(
+ json,
+ "updateDelayInProgress");
+ } else {
+ if (bgp->update_delay_over) {
json_object_string_add(
json,
"updateDelayFirstNeighbor",
bgp->update_delay_begin_time);
- json_object_boolean_true_add(
+ json_object_string_add(
json,
- "updateDelayInProgress");
- } else {
- if (bgp->update_delay_over) {
- json_object_string_add(
- json,
- "updateDelayFirstNeighbor",
- bgp->update_delay_begin_time);
- json_object_string_add(
- json,
- "updateDelayBestpathResumed",
- bgp->update_delay_end_time);
- json_object_string_add(
- json,
- "updateDelayZebraUpdateResume",
- bgp->update_delay_zebra_resume_time);
- json_object_string_add(
- json,
- "updateDelayPeerUpdateResume",
- bgp->update_delay_peers_resume_time);
- }
+ "updateDelayBestpathResumed",
+ bgp->update_delay_end_time);
+ json_object_string_add(
+ json,
+ "updateDelayZebraUpdateResume",
+ bgp->update_delay_zebra_resume_time);
+ json_object_string_add(
+ json,
+ "updateDelayPeerUpdateResume",
+ bgp->update_delay_peers_resume_time);
}
- } else {
+ }
+ } else {
+ vty_out(vty,
+ "Read-only mode update-delay limit: %d seconds\n",
+ bgp->v_update_delay);
+ if (bgp->v_update_delay
+ != bgp->v_establish_wait)
vty_out(vty,
- "Read-only mode update-delay limit: %d seconds\n",
- bgp->v_update_delay);
- if (bgp->v_update_delay
- != bgp->v_establish_wait)
- vty_out(vty,
- " Establish wait: %d seconds\n",
- bgp->v_establish_wait);
+ " Establish wait: %d seconds\n",
+ bgp->v_establish_wait);
- if (bgp_update_delay_active(
- bgp)) {
+ if (bgp_update_delay_active(
+ bgp)) {
+ vty_out(vty,
+ " First neighbor established: %s\n",
+ bgp->update_delay_begin_time);
+ vty_out(vty,
+ " Delay in progress\n");
+ } else {
+ if (bgp->update_delay_over) {
vty_out(vty,
" First neighbor established: %s\n",
bgp->update_delay_begin_time);
vty_out(vty,
- " Delay in progress\n");
- } else {
- if (bgp->update_delay_over) {
- vty_out(vty,
- " First neighbor established: %s\n",
- bgp->update_delay_begin_time);
- vty_out(vty,
- " Best-paths resumed: %s\n",
- bgp->update_delay_end_time);
- vty_out(vty,
- " zebra update resumed: %s\n",
- bgp->update_delay_zebra_resume_time);
- vty_out(vty,
- " peers update resumed: %s\n",
- bgp->update_delay_peers_resume_time);
- }
+ " Best-paths resumed: %s\n",
+ bgp->update_delay_end_time);
+ vty_out(vty,
+ " zebra update resumed: %s\n",
+ bgp->update_delay_zebra_resume_time);
+ vty_out(vty,
+ " peers update resumed: %s\n",
+ bgp->update_delay_peers_resume_time);
}
}
}
+ }
- if (use_json) {
- if (bgp_maxmed_onstartup_configured(bgp)
- && bgp->maxmed_active)
- json_object_boolean_true_add(
- json,
- "maxMedOnStartup");
- if (bgp->v_maxmed_admin)
- json_object_boolean_true_add(
- json,
- "maxMedAdministrative");
-
- json_object_int_add(
- json, "tableVersion",
- bgp_table_version(
- bgp->rib[afi][safi]));
-
- ents = bgp_table_count(
- bgp->rib[afi][safi]);
- json_object_int_add(json, "ribCount",
- ents);
- json_object_int_add(
- json, "ribMemory",
- ents * sizeof(struct bgp_node));
+ if (use_json) {
+ if (bgp_maxmed_onstartup_configured(bgp)
+ && bgp->maxmed_active)
+ json_object_boolean_true_add(
+ json,
+ "maxMedOnStartup");
+ if (bgp->v_maxmed_admin)
+ json_object_boolean_true_add(
+ json,
+ "maxMedAdministrative");
- ents = listcount(bgp->peer);
- json_object_int_add(json, "peerCount",
- ents);
- json_object_int_add(
- json, "peerMemory",
- ents * sizeof(struct peer));
+ json_object_int_add(
+ json, "tableVersion",
+ bgp_table_version(
+ bgp->rib[afi][safi]));
+
+ ents = bgp_table_count(
+ bgp->rib[afi][safi]);
+ json_object_int_add(json, "ribCount",
+ ents);
+ json_object_int_add(
+ json, "ribMemory",
+ ents * sizeof(struct bgp_node));
- if ((ents = listcount(bgp->group))) {
- json_object_int_add(
- json, "peerGroupCount",
- ents);
- json_object_int_add(
- json, "peerGroupMemory",
- ents * sizeof(struct
- peer_group));
- }
+ ents = listcount(bgp->peer);
+ json_object_int_add(json, "peerCount",
+ ents);
+ json_object_int_add(
+ json, "peerMemory",
+ ents * sizeof(struct peer));
- if (CHECK_FLAG(bgp->af_flags[afi][safi],
- BGP_CONFIG_DAMPENING))
- json_object_boolean_true_add(
- json,
- "dampeningEnabled");
- } else {
- if (bgp_maxmed_onstartup_configured(bgp)
- && bgp->maxmed_active)
- vty_out(vty,
- "Max-med on-startup active\n");
- if (bgp->v_maxmed_admin)
- vty_out(vty,
- "Max-med administrative active\n");
+ if ((ents = listcount(bgp->group))) {
+ json_object_int_add(
+ json, "peerGroupCount",
+ ents);
+ json_object_int_add(
+ json, "peerGroupMemory",
+ ents * sizeof(struct
+ peer_group));
+ }
+ if (CHECK_FLAG(bgp->af_flags[afi][safi],
+ BGP_CONFIG_DAMPENING))
+ json_object_boolean_true_add(
+ json,
+ "dampeningEnabled");
+ } else {
+ if (bgp_maxmed_onstartup_configured(bgp)
+ && bgp->maxmed_active)
vty_out(vty,
- "BGP table version %" PRIu64
- "\n",
- bgp_table_version(
- bgp->rib[afi][safi]));
-
- ents = bgp_table_count(
- bgp->rib[afi][safi]);
+ "Max-med on-startup active\n");
+ if (bgp->v_maxmed_admin)
vty_out(vty,
- "RIB entries %ld, using %s of memory\n",
- ents,
- mtype_memstr(
- memstrbuf,
- sizeof(memstrbuf),
- ents * sizeof(struct
- bgp_node)));
+ "Max-med administrative active\n");
- /* Peer related usage */
- ents = listcount(bgp->peer);
+ vty_out(vty,
+ "BGP table version %" PRIu64
+ "\n",
+ bgp_table_version(
+ bgp->rib[afi][safi]));
+
+ ents = bgp_table_count(
+ bgp->rib[afi][safi]);
+ vty_out(vty,
+ "RIB entries %ld, using %s of memory\n",
+ ents,
+ mtype_memstr(
+ memstrbuf,
+ sizeof(memstrbuf),
+ ents * sizeof(struct
+ bgp_node)));
+
+ /* Peer related usage */
+ ents = listcount(bgp->peer);
+ vty_out(vty,
+ "Peers %ld, using %s of memory\n",
+ ents,
+ mtype_memstr(
+ memstrbuf,
+ sizeof(memstrbuf),
+ ents * sizeof(struct
+ peer)));
+
+ if ((ents = listcount(bgp->group)))
vty_out(vty,
- "Peers %ld, using %s of memory\n",
+ "Peer groups %ld, using %s of memory\n",
ents,
mtype_memstr(
memstrbuf,
sizeof(memstrbuf),
ents * sizeof(struct
- peer)));
+ peer_group)));
- if ((ents = listcount(bgp->group)))
- vty_out(vty,
- "Peer groups %ld, using %s of memory\n",
- ents,
- mtype_memstr(
- memstrbuf,
- sizeof(memstrbuf),
- ents * sizeof(struct
- peer_group)));
-
- if (CHECK_FLAG(bgp->af_flags[afi][safi],
- BGP_CONFIG_DAMPENING))
- vty_out(vty,
- "Dampening enabled.\n");
- vty_out(vty, "\n");
-
- /* Subtract 8 here because 'Neighbor' is
- * 8 characters */
- vty_out(vty, "Neighbor");
- vty_out(vty, "%*s",
- max_neighbor_width - 8, " ");
+ if (CHECK_FLAG(bgp->af_flags[afi][safi],
+ BGP_CONFIG_DAMPENING))
vty_out(vty,
- "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
- }
+ "Dampening enabled.\n");
+ vty_out(vty, "\n");
+
+ /* Subtract 8 here because 'Neighbor' is
+ * 8 characters */
+ vty_out(vty, "Neighbor");
+ vty_out(vty, "%*s",
+ max_neighbor_width - 8, " ");
+ vty_out(vty,
+ "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
}
+ }
- count++;
+ count++;
- if (use_json) {
- json_peer = json_object_new_object();
+ if (use_json) {
+ json_peer = json_object_new_object();
- if (peer_dynamic_neighbor(peer))
- json_object_boolean_true_add(
- json_peer, "dynamicPeer");
+ if (peer_dynamic_neighbor(peer))
+ json_object_boolean_true_add(
+ json_peer, "dynamicPeer");
- if (peer->hostname)
- json_object_string_add(json_peer,
- "hostname",
- peer->hostname);
+ if (peer->hostname)
+ json_object_string_add(json_peer,
+ "hostname",
+ peer->hostname);
- if (peer->domainname)
- json_object_string_add(
- json_peer, "domainname",
- peer->domainname);
+ if (peer->domainname)
+ json_object_string_add(
+ json_peer, "domainname",
+ peer->domainname);
- json_object_int_add(json_peer, "remoteAs",
- peer->as);
- json_object_int_add(json_peer, "version", 4);
- json_object_int_add(
- json_peer, "msgRcvd",
- peer->open_in + peer->update_in
- + peer->keepalive_in
- + peer->notify_in
- + peer->refresh_in
- + peer->dynamic_cap_in);
- json_object_int_add(
- json_peer, "msgSent",
- peer->open_out + peer->update_out
- + peer->keepalive_out
- + peer->notify_out
- + peer->refresh_out
- + peer->dynamic_cap_out);
-
- json_object_int_add(json_peer, "tableVersion",
- peer->version[afi][safi]);
- json_object_int_add(json_peer, "outq",
- peer->obuf->count);
- json_object_int_add(json_peer, "inq", 0);
- peer_uptime(peer->uptime, timebuf,
- BGP_UPTIME_LEN, use_json,
- json_peer);
- json_object_int_add(
- json_peer, "prefixReceivedCount",
- peer->pcount[afi][pfx_rcd_safi]);
-
- if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN))
- json_object_string_add(json_peer,
- "state",
- "Idle (Admin)");
- else if (CHECK_FLAG(
- peer->sflags,
- PEER_STATUS_PREFIX_OVERFLOW))
- json_object_string_add(json_peer,
- "state",
- "Idle (PfxCt)");
- else
- json_object_string_add(
- json_peer, "state",
- lookup_msg(bgp_status_msg,
- peer->status, NULL));
-
- if (peer->conf_if)
- json_object_string_add(json_peer,
- "idType",
- "interface");
- else if (peer->su.sa.sa_family == AF_INET)
- json_object_string_add(
- json_peer, "idType", "ipv4");
- else if (peer->su.sa.sa_family == AF_INET6)
- json_object_string_add(
- json_peer, "idType", "ipv6");
+ json_object_int_add(json_peer, "remoteAs",
+ peer->as);
+ json_object_int_add(json_peer, "version", 4);
+ json_object_int_add(
+ json_peer, "msgRcvd",
+ peer->open_in + peer->update_in
+ + peer->keepalive_in
+ + peer->notify_in
+ + peer->refresh_in
+ + peer->dynamic_cap_in);
+ json_object_int_add(
+ json_peer, "msgSent",
+ peer->open_out + peer->update_out
+ + peer->keepalive_out
+ + peer->notify_out
+ + peer->refresh_out
+ + peer->dynamic_cap_out);
+
+ json_object_int_add(json_peer, "tableVersion",
+ peer->version[afi][safi]);
+ json_object_int_add(json_peer, "outq",
+ peer->obuf->count);
+ json_object_int_add(json_peer, "inq", 0);
+ peer_uptime(peer->uptime, timebuf,
+ BGP_UPTIME_LEN, use_json,
+ json_peer);
+ json_object_int_add(
+ json_peer, "prefixReceivedCount",
+ peer->pcount[afi][pfx_rcd_safi]);
- json_object_object_add(json_peers, peer->host,
- json_peer);
- } else {
- memset(dn_flag, '\0', sizeof(dn_flag));
- if (peer_dynamic_neighbor(peer)) {
- dn_count++;
- dn_flag[0] = '*';
- }
+ if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN))
+ json_object_string_add(json_peer,
+ "state",
+ "Idle (Admin)");
+ else if (CHECK_FLAG(
+ peer->sflags,
+ PEER_STATUS_PREFIX_OVERFLOW))
+ json_object_string_add(json_peer,
+ "state",
+ "Idle (PfxCt)");
+ else
+ json_object_string_add(
+ json_peer, "state",
+ lookup_msg(bgp_status_msg,
+ peer->status, NULL));
+
+ if (peer->conf_if)
+ json_object_string_add(json_peer,
+ "idType",
+ "interface");
+ else if (peer->su.sa.sa_family == AF_INET)
+ json_object_string_add(
+ json_peer, "idType", "ipv4");
+ else if (peer->su.sa.sa_family == AF_INET6)
+ json_object_string_add(
+ json_peer, "idType", "ipv6");
- if (peer->hostname
- && bgp_flag_check(bgp,
- BGP_FLAG_SHOW_HOSTNAME))
- len = vty_out(vty, "%s%s(%s)", dn_flag,
- peer->hostname,
- peer->host);
+ json_object_object_add(json_peers, peer->host,
+ json_peer);
+ } else {
+ memset(dn_flag, '\0', sizeof(dn_flag));
+ if (peer_dynamic_neighbor(peer)) {
+ dn_count++;
+ dn_flag[0] = '*';
+ }
+
+ if (peer->hostname
+ && bgp_flag_check(bgp,
+ BGP_FLAG_SHOW_HOSTNAME))
+ len = vty_out(vty, "%s%s(%s)", dn_flag,
+ peer->hostname,
+ peer->host);
+ else
+ len = vty_out(vty, "%s%s", dn_flag,
+ peer->host);
+
+ /* pad the neighbor column with spaces */
+ if (len < max_neighbor_width)
+ vty_out(vty, "%*s",
+ max_neighbor_width - len, " ");
+
+ vty_out(vty, "4 %10u %7d %7d %8" PRIu64
+ " %4d %4zd %8s",
+ peer->as,
+ peer->open_in + peer->update_in
+ + peer->keepalive_in
+ + peer->notify_in
+ + peer->refresh_in
+ + peer->dynamic_cap_in,
+ peer->open_out + peer->update_out
+ + peer->keepalive_out
+ + peer->notify_out
+ + peer->refresh_out
+ + peer->dynamic_cap_out,
+ peer->version[afi][safi], 0,
+ peer->obuf->count,
+ peer_uptime(peer->uptime, timebuf,
+ BGP_UPTIME_LEN, 0, NULL));
+
+ if (peer->status == Established)
+ vty_out(vty, " %12ld",
+ peer->pcount[afi]
+ [pfx_rcd_safi]);
+ else {
+ if (CHECK_FLAG(peer->flags,
+ PEER_FLAG_SHUTDOWN))
+ vty_out(vty, " Idle (Admin)");
+ else if (
+ CHECK_FLAG(
+ peer->sflags,
+ PEER_STATUS_PREFIX_OVERFLOW))
+ vty_out(vty, " Idle (PfxCt)");
else
- len = vty_out(vty, "%s%s", dn_flag,
- peer->host);
-
- /* pad the neighbor column with spaces */
- if (len < max_neighbor_width)
- vty_out(vty, "%*s",
- max_neighbor_width - len, " ");
-
- vty_out(vty, "4 %10u %7d %7d %8" PRIu64
- " %4d %4zd %8s",
- peer->as,
- peer->open_in + peer->update_in
- + peer->keepalive_in
- + peer->notify_in
- + peer->refresh_in
- + peer->dynamic_cap_in,
- peer->open_out + peer->update_out
- + peer->keepalive_out
- + peer->notify_out
- + peer->refresh_out
- + peer->dynamic_cap_out,
- peer->version[afi][safi], 0,
- peer->obuf->count,
- peer_uptime(peer->uptime, timebuf,
- BGP_UPTIME_LEN, 0, NULL));
-
- if (peer->status == Established)
- vty_out(vty, " %12ld",
- peer->pcount[afi]
- [pfx_rcd_safi]);
- else {
- if (CHECK_FLAG(peer->flags,
- PEER_FLAG_SHUTDOWN))
- vty_out(vty, " Idle (Admin)");
- else if (
- CHECK_FLAG(
- peer->sflags,
- PEER_STATUS_PREFIX_OVERFLOW))
- vty_out(vty, " Idle (PfxCt)");
- else
- vty_out(vty, " %12s",
- lookup_msg(
- bgp_status_msg,
- peer->status,
- NULL));
- }
- vty_out(vty, "\n");
+ vty_out(vty, " %12s",
+ lookup_msg(
+ bgp_status_msg,
+ peer->status,
+ NULL));
}
+ vty_out(vty, "\n");
}
}