Skip to content

Commit

Permalink
bgpd: Incorrect number of peers count in "show bgp ipv6 summary" output
Browse files Browse the repository at this point in the history
Fix : Now the peers count displays the number of neighbors activated per afi/safi.

Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
  • Loading branch information
AkhileshSamineni committed Feb 15, 2019
1 parent eea14ea commit b82cbdd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -7838,7 +7838,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
json, "ribMemory",
ents * sizeof(struct bgp_node));

ents = listcount(bgp->peer);
ents = bgp->af_peer_count[afi][safi];
json_object_int_add(json, "peerCount", ents);
json_object_int_add(json, "peerMemory",
ents * sizeof(struct peer));
Expand Down Expand Up @@ -7878,7 +7878,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
bgp_node)));

/* Peer related usage */
ents = listcount(bgp->peer);
ents = bgp->af_peer_count[afi][safi];
vty_out(vty, "Peers %ld, using %s of memory\n",
ents,
mtype_memstr(
Expand Down
8 changes: 8 additions & 0 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ struct peer_af *peer_af_create(struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_af *af;
int afid;
struct bgp *bgp;

if (!peer)
return NULL;
Expand All @@ -679,6 +680,7 @@ struct peer_af *peer_af_create(struct peer *peer, afi_t afi, safi_t safi)
if (afid >= BGP_AF_MAX)
return NULL;

bgp = peer->bgp;
assert(peer->peer_af_array[afid] == NULL);

/* Allocate new peer af */
Expand All @@ -689,6 +691,7 @@ struct peer_af *peer_af_create(struct peer *peer, afi_t afi, safi_t safi)
af->safi = safi;
af->afid = afid;
af->peer = peer;
bgp->af_peer_count[afi][safi]++;

return af;
}
Expand All @@ -711,6 +714,7 @@ int peer_af_delete(struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_af *af;
int afid;
struct bgp *bgp;

if (!peer)
return -1;
Expand All @@ -723,6 +727,7 @@ int peer_af_delete(struct peer *peer, afi_t afi, safi_t safi)
if (!af)
return -1;

bgp = peer->bgp;
bgp_stop_announce_route_timer(af);

if (PAF_SUBGRP(af)) {
Expand All @@ -734,6 +739,9 @@ int peer_af_delete(struct peer *peer, afi_t afi, safi_t safi)

update_subgroup_remove_peer(af->subgroup, af);

if (bgp->af_peer_count[afi][safi])
bgp->af_peer_count[afi][safi]--;

peer->peer_af_array[afid] = NULL;
XFREE(MTYPE_BGP_PEER_AF, af);
return 0;
Expand Down
3 changes: 3 additions & 0 deletions bgpd/bgpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ struct bgp {
#define BGP_CONFIG_VRF_TO_VRF_EXPORT (1 << 8)
#define BGP_DEFAULT_NAME "default"

/* BGP per AF peer count */
uint32_t af_peer_count[AFI_MAX][SAFI_MAX];

/* Route table for next-hop lookup cache. */
struct bgp_table *nexthop_cache_table[AFI_MAX];

Expand Down

0 comments on commit b82cbdd

Please sign in to comment.