Fix : Now the peers count displays the number of neighbors activated per afi/safi.
Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
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));
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(
{
struct peer_af *af;
int afid;
+ struct bgp *bgp;
if (!peer)
return NULL;
if (afid >= BGP_AF_MAX)
return NULL;
+ bgp = peer->bgp;
assert(peer->peer_af_array[afid] == NULL);
/* Allocate new peer af */
af->safi = safi;
af->afid = afid;
af->peer = peer;
+ bgp->af_peer_count[afi][safi]++;
return af;
}
{
struct peer_af *af;
int afid;
+ struct bgp *bgp;
if (!peer)
return -1;
if (!af)
return -1;
+ bgp = peer->bgp;
bgp_stop_announce_route_timer(af);
if (PAF_SUBGRP(af)) {
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;
#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];