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,155 +375,150 @@ 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)
rd_header = 1; continue;
for (rm = bgp_table_top(table); rm; rd_header = 1;
rm = bgp_route_next(rm))
for (ri = rm->info; ri; ri = ri->next) {
total_count++;
if (type == bgp_show_type_neighbor) {
union sockunion *su =
output_arg;
if (ri->peer->su_remote == NULL for (rm = bgp_table_top(table); rm;
|| !sockunion_same( rm = bgp_route_next(rm))
ri->peer->su_remote, for (ri = rm->info; ri; ri = ri->next) {
su)) total_count++;
continue; if (type == bgp_show_type_neighbor) {
} union sockunion *su =
if (header == 0) { output_arg;
if (use_json) {
if (option
== SHOW_DISPLAY_TAGS) {
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 {
if (option
== SHOW_DISPLAY_TAGS)
vty_out(vty,
V4_HEADER_TAG);
else if (
option
== SHOW_DISPLAY_OVERLAY)
vty_out(vty,
V4_HEADER_OVERLAY);
else {
vty_out(vty,
"BGP table version is 0, local router ID is %s\n",
inet_ntoa(
bgp->router_id));
vty_out(vty,
"Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n");
vty_out(vty,
"Origin codes: i - IGP, e - EGP, ? - incomplete\n\n");
vty_out(vty,
V4_HEADER);
}
}
header = 0;
}
if (rd_header) {
u_int16_t type;
struct rd_as rd_as;
struct rd_ip rd_ip;
u_char *pnt;
pnt = rn->p.u.val; if (ri->peer->su_remote == NULL
|| !sockunion_same(
/* Decode RD type. */ ri->peer->su_remote,
type = decode_rd_type(pnt); su))
/* Decode RD value. */ continue;
if (type == RD_TYPE_AS)
decode_rd_as(pnt + 2,
&rd_as);
else if (type == RD_TYPE_AS4)
decode_rd_as4(pnt + 2,
&rd_as);
else if (type == RD_TYPE_IP)
decode_rd_ip(pnt + 2,
&rd_ip);
if (use_json) {
char buffer[BUFSIZ];
if (type == RD_TYPE_AS
|| type == RD_TYPE_AS4)
sprintf(buffer,
"%u:%d",
rd_as.as,
rd_as.val);
else if (type
== RD_TYPE_IP)
sprintf(buffer,
"%s:%d",
inet_ntoa(
rd_ip.ip),
rd_ip.val);
json_object_string_add(
json_nroute,
"routeDistinguisher",
buffer);
} else {
vty_out(vty,
"Route Distinguisher: ");
if (type == RD_TYPE_AS)
vty_out(vty,
"as2 %u:%d",
rd_as.as,
rd_as.val);
else if (type
== RD_TYPE_AS4)
vty_out(vty,
"as4 %u:%d",
rd_as.as,
rd_as.val);
else if (type
== RD_TYPE_IP)
vty_out(vty,
"ip %s:%d",
inet_ntoa(
rd_ip.ip),
rd_ip.val);
vty_out(vty, "\n\n");
}
rd_header = 0;
}
if (use_json)
json_array =
json_object_new_array();
else
json_array = NULL;
if (option == SHOW_DISPLAY_TAGS)
route_vty_out_tag(
vty, &rm->p, ri, 0,
SAFI_EVPN, json_array);
else if (option == SHOW_DISPLAY_OVERLAY)
route_vty_out_overlay(
vty, &rm->p, ri, 0,
json_array);
else
route_vty_out(vty, &rm->p, ri,
0, SAFI_EVPN,
json_array);
output_count++;
} }
/* XXX json */ if (header == 0) {
} if (use_json) {
if (option
== SHOW_DISPLAY_TAGS) {
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 {
if (option
== SHOW_DISPLAY_TAGS)
vty_out(vty,
V4_HEADER_TAG);
else if (
option
== SHOW_DISPLAY_OVERLAY)
vty_out(vty,
V4_HEADER_OVERLAY);
else {
vty_out(vty,
"BGP table version is 0, local router ID is %s\n",
inet_ntoa(
bgp->router_id));
vty_out(vty,
"Status codes: s suppressed, d damped, h history, * valid, > best, i - internal\n");
vty_out(vty,
"Origin codes: i - IGP, e - EGP, ? - incomplete\n\n");
vty_out(vty,
V4_HEADER);
}
}
header = 0;
}
if (rd_header) {
u_int16_t type;
struct rd_as rd_as;
struct rd_ip rd_ip;
u_char *pnt;
pnt = rn->p.u.val;
/* Decode RD type. */
type = decode_rd_type(pnt);
/* Decode RD value. */
if (type == RD_TYPE_AS)
decode_rd_as(pnt + 2, &rd_as);
else if (type == RD_TYPE_AS4)
decode_rd_as4(pnt + 2, &rd_as);
else if (type == RD_TYPE_IP)
decode_rd_ip(pnt + 2, &rd_ip);
if (use_json) {
char buffer[BUFSIZ];
if (type == RD_TYPE_AS
|| type == RD_TYPE_AS4)
sprintf(buffer,
"%u:%d",
rd_as.as,
rd_as.val);
else if (type
== RD_TYPE_IP)
sprintf(buffer,
"%s:%d",
inet_ntoa(
rd_ip.ip),
rd_ip.val);
json_object_string_add(
json_nroute,
"routeDistinguisher",
buffer);
} else {
vty_out(vty,
"Route Distinguisher: ");
if (type == RD_TYPE_AS)
vty_out(vty,
"as2 %u:%d",
rd_as.as,
rd_as.val);
else if (type
== RD_TYPE_AS4)
vty_out(vty,
"as4 %u:%d",
rd_as.as,
rd_as.val);
else if (type
== RD_TYPE_IP)
vty_out(vty,
"ip %s:%d",
inet_ntoa(
rd_ip.ip),
rd_ip.val);
vty_out(vty, "\n\n");
}
rd_header = 0;
}
if (use_json)
json_array = json_object_new_array();
else
json_array = NULL;
if (option == SHOW_DISPLAY_TAGS)
route_vty_out_tag(vty, &rm->p, ri, 0,
SAFI_EVPN,
json_array);
else if (option == SHOW_DISPLAY_OVERLAY)
route_vty_out_overlay(vty, &rm->p, ri,
0, json_array);
else
route_vty_out(vty, &rm->p, ri, 0,
SAFI_EVPN, json_array);
output_count++;
}
/* 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);

File diff suppressed because it is too large Load Diff

View File

@ -6610,368 +6610,369 @@ 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])
if (!count) { continue;
unsigned long ents;
char memstrbuf[MTYPE_MEMSTR_LEN];
int vrf_id_ui;
vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) if (!count) {
? -1 unsigned long ents;
: bgp->vrf_id; char memstrbuf[MTYPE_MEMSTR_LEN];
int vrf_id_ui;
/* Usage summary and header */ vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN)
? -1
: bgp->vrf_id;
/* 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) { if (use_json) {
json_object_string_add( json_object_int_add(
json, "routerId", json,
inet_ntoa(bgp->router_id)); "updateDelayLimit",
json_object_int_add(json, "as", bgp->v_update_delay);
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 (bgp->v_update_delay
if (use_json) { != bgp->v_establish_wait)
json_object_int_add( json_object_int_add(
json, json,
"updateDelayLimit", "updateDelayEstablishWait",
bgp->v_update_delay); bgp->v_establish_wait);
if (bgp->v_update_delay if (bgp_update_delay_active(
!= bgp->v_establish_wait) bgp)) {
json_object_int_add( json_object_string_add(
json, json,
"updateDelayEstablishWait", "updateDelayFirstNeighbor",
bgp->v_establish_wait); bgp->update_delay_begin_time);
json_object_boolean_true_add(
if (bgp_update_delay_active( json,
bgp)) { "updateDelayInProgress");
} else {
if (bgp->update_delay_over) {
json_object_string_add( json_object_string_add(
json, json,
"updateDelayFirstNeighbor", "updateDelayFirstNeighbor",
bgp->update_delay_begin_time); bgp->update_delay_begin_time);
json_object_boolean_true_add( json_object_string_add(
json, json,
"updateDelayInProgress"); "updateDelayBestpathResumed",
} else { bgp->update_delay_end_time);
if (bgp->update_delay_over) { json_object_string_add(
json_object_string_add( json,
json, "updateDelayZebraUpdateResume",
"updateDelayFirstNeighbor", bgp->update_delay_zebra_resume_time);
bgp->update_delay_begin_time); json_object_string_add(
json_object_string_add( json,
json, "updateDelayPeerUpdateResume",
"updateDelayBestpathResumed", bgp->update_delay_peers_resume_time);
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, vty_out(vty,
"Read-only mode update-delay limit: %d seconds\n", " Establish wait: %d seconds\n",
bgp->v_update_delay); bgp->v_establish_wait);
if (bgp->v_update_delay
!= bgp->v_establish_wait)
vty_out(vty,
" Establish wait: %d seconds\n",
bgp->v_establish_wait);
if (bgp_update_delay_active( if (bgp_update_delay_active(
bgp)) { 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, vty_out(vty,
" First neighbor established: %s\n", " First neighbor established: %s\n",
bgp->update_delay_begin_time); bgp->update_delay_begin_time);
vty_out(vty, vty_out(vty,
" Delay in progress\n"); " Best-paths resumed: %s\n",
} else { bgp->update_delay_end_time);
if (bgp->update_delay_over) { vty_out(vty,
vty_out(vty, " zebra update resumed: %s\n",
" First neighbor established: %s\n", bgp->update_delay_zebra_resume_time);
bgp->update_delay_begin_time); vty_out(vty,
vty_out(vty, " peers update resumed: %s\n",
" Best-paths resumed: %s\n", bgp->update_delay_peers_resume_time);
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));
ents = listcount(bgp->peer);
json_object_int_add(json, "peerCount",
ents);
json_object_int_add(
json, "peerMemory",
ents * sizeof(struct peer));
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,
"Max-med on-startup active\n");
if (bgp->v_maxmed_admin)
vty_out(vty,
"Max-med administrative active\n");
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,
"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, " ");
vty_out(vty,
"V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
}
} }
count++;
if (use_json) { if (use_json) {
json_peer = json_object_new_object(); if (bgp_maxmed_onstartup_configured(bgp)
&& bgp->maxmed_active)
if (peer_dynamic_neighbor(peer))
json_object_boolean_true_add( json_object_boolean_true_add(
json_peer, "dynamicPeer"); json,
"maxMedOnStartup");
if (bgp->v_maxmed_admin)
json_object_boolean_true_add(
json,
"maxMedAdministrative");
if (peer->hostname)
json_object_string_add(json_peer,
"hostname",
peer->hostname);
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_object_int_add(
json_peer, "msgRcvd", json, "tableVersion",
peer->open_in + peer->update_in bgp_table_version(
+ peer->keepalive_in bgp->rib[afi][safi]));
+ peer->notify_in
+ peer->refresh_in ents = bgp_table_count(
+ peer->dynamic_cap_in); bgp->rib[afi][safi]);
json_object_int_add(json, "ribCount",
ents);
json_object_int_add( json_object_int_add(
json_peer, "msgSent", json, "ribMemory",
peer->open_out + peer->update_out ents * sizeof(struct bgp_node));
+ peer->keepalive_out
+ peer->notify_out
+ peer->refresh_out
+ peer->dynamic_cap_out);
json_object_int_add(json_peer, "tableVersion", ents = listcount(bgp->peer);
peer->version[afi][safi]); json_object_int_add(json, "peerCount",
json_object_int_add(json_peer, "outq", ents);
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_object_int_add(
json_peer, "prefixReceivedCount", json, "peerMemory",
peer->pcount[afi][pfx_rcd_safi]); ents * sizeof(struct peer));
if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) if ((ents = listcount(bgp->group))) {
json_object_string_add(json_peer, json_object_int_add(
"state", json, "peerGroupCount",
"Idle (Admin)"); ents);
else if (CHECK_FLAG( json_object_int_add(
peer->sflags, json, "peerGroupMemory",
PEER_STATUS_PREFIX_OVERFLOW)) ents * sizeof(struct
json_object_string_add(json_peer, peer_group));
"state", }
"Idle (PfxCt)");
else
json_object_string_add(
json_peer, "state",
lookup_msg(bgp_status_msg,
peer->status, NULL));
if (peer->conf_if) if (CHECK_FLAG(bgp->af_flags[afi][safi],
json_object_string_add(json_peer, BGP_CONFIG_DAMPENING))
"idType", json_object_boolean_true_add(
"interface"); json,
else if (peer->su.sa.sa_family == AF_INET) "dampeningEnabled");
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_object_add(json_peers, peer->host,
json_peer);
} else { } else {
memset(dn_flag, '\0', sizeof(dn_flag)); if (bgp_maxmed_onstartup_configured(bgp)
if (peer_dynamic_neighbor(peer)) { && bgp->maxmed_active)
dn_count++; vty_out(vty,
dn_flag[0] = '*'; "Max-med on-startup active\n");
} if (bgp->v_maxmed_admin)
vty_out(vty,
"Max-med administrative active\n");
if (peer->hostname vty_out(vty,
&& bgp_flag_check(bgp, "BGP table version %" PRIu64
BGP_FLAG_SHOW_HOSTNAME)) "\n",
len = vty_out(vty, "%s%s(%s)", dn_flag, bgp_table_version(
peer->hostname, bgp->rib[afi][safi]));
peer->host);
else
len = vty_out(vty, "%s%s", dn_flag,
peer->host);
/* pad the neighbor column with spaces */ ents = bgp_table_count(
if (len < max_neighbor_width) bgp->rib[afi][safi]);
vty_out(vty, "%*s", vty_out(vty,
max_neighbor_width - len, " "); "RIB entries %ld, using %s of memory\n",
ents,
mtype_memstr(
memstrbuf,
sizeof(memstrbuf),
ents * sizeof(struct
bgp_node)));
vty_out(vty, "4 %10u %7d %7d %8" PRIu64 /* Peer related usage */
" %4d %4zd %8s", ents = listcount(bgp->peer);
peer->as, vty_out(vty,
peer->open_in + peer->update_in "Peers %ld, using %s of memory\n",
+ peer->keepalive_in ents,
+ peer->notify_in mtype_memstr(
+ peer->refresh_in memstrbuf,
+ peer->dynamic_cap_in, sizeof(memstrbuf),
peer->open_out + peer->update_out ents * sizeof(struct
+ peer->keepalive_out peer)));
+ 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) if ((ents = listcount(bgp->group)))
vty_out(vty, " %12ld", vty_out(vty,
peer->pcount[afi] "Peer groups %ld, using %s of memory\n",
[pfx_rcd_safi]); ents,
else { mtype_memstr(
if (CHECK_FLAG(peer->flags, memstrbuf,
PEER_FLAG_SHUTDOWN)) sizeof(memstrbuf),
vty_out(vty, " Idle (Admin)"); ents * sizeof(struct
else if ( peer_group)));
CHECK_FLAG(
peer->sflags, if (CHECK_FLAG(bgp->af_flags[afi][safi],
PEER_STATUS_PREFIX_OVERFLOW)) BGP_CONFIG_DAMPENING))
vty_out(vty, " Idle (PfxCt)"); vty_out(vty,
else "Dampening enabled.\n");
vty_out(vty, " %12s",
lookup_msg(
bgp_status_msg,
peer->status,
NULL));
}
vty_out(vty, "\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++;
if (use_json) {
json_peer = json_object_new_object();
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->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_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
vty_out(vty, " %12s",
lookup_msg(
bgp_status_msg,
peer->status,
NULL));
}
vty_out(vty, "\n");
}
} }
if (use_json) { if (use_json) {