diff options
| author | Quentin Young <qlyoung@users.noreply.github.com> | 2019-04-21 18:11:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-21 18:11:36 -0400 |
| commit | fa8c268f688d747577e34710131d881cfe79619a (patch) | |
| tree | 16e27d0252171189690ce8d45452fbe3916802f3 | |
| parent | cd0c8979e3daf02ef7f3afa4f62c66cc4b6412bf (diff) | |
| parent | a9881f90a87a6be7c5a753ef004f6c4f896b43cc (diff) | |
Merge pull request #3811 from AkhileshSamineni/show_bgp_ipv6_summary_fix
[6.0] bgpd: Incorrect number of peers count in "show bgp ipv6 summary" output
| -rw-r--r-- | bgpd/bgp_vty.c | 4 | ||||
| -rw-r--r-- | bgpd/bgpd.c | 8 | ||||
| -rw-r--r-- | bgpd/bgpd.h | 3 |
3 files changed, 13 insertions, 2 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 67a745047b..6f21a9b3ed 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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)); @@ -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( diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 7ce83ab1d3..94aadda3d6 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -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; @@ -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 */ @@ -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; } @@ -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; @@ -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)) { @@ -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; diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index a516e87388..a6f0e92da3 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -373,6 +373,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]; |
