]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Incorrect number of peers count in "show bgp ipv6 summary" output
authorAkhilesh Samineni <akhilesh.samineni@broadcom.com>
Fri, 15 Feb 2019 16:50:51 +0000 (22:20 +0530)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Sat, 27 Apr 2019 15:25:53 +0000 (18:25 +0300)
Fix : Now the peers count displays the number of neighbors activated per afi/safi.

Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h

index a6adeea66df6daa0c25c968e1523f7a09c11afaa..25f4b842e71ba00d0cbe688453ac35b9c2207863 100644 (file)
@@ -7811,7 +7811,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));
@@ -7851,7 +7851,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(
index da2c97f6f4e96683c04544e47140f2b331647d05..3d7a0f32c05f5b409b7552c8c375cd9de418ab28 100644 (file)
@@ -669,6 +669,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;
@@ -677,6 +678,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 */
@@ -693,6 +695,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;
 }
@@ -715,6 +718,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;
@@ -727,6 +731,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)) {
@@ -738,6 +743,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;
index d20f841a2f1bd7adf4184333b817d8ab972947b2..7cddd7e11844d0db4cd59117a6e19cdda3883af8 100644 (file)
@@ -369,6 +369,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];