]> git.proxmox.com Git - mirror_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)
committerAkhilesh Samineni <akhilesh.samineni@broadcom.com>
Fri, 15 Feb 2019 17:06:15 +0000 (22:36 +0530)
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 f7ec2780ef5f820d398d4913aa894391b180f9e3..232d19d33c5f88139d1bfbe2204bb1c981ad7a25 100644 (file)
@@ -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(
index a82dd51cc8b4053967853a58bf940e203b7615ea..c21edb8cc9cb812d53270e2ea7f2528fe9aa155b 100644 (file)
@@ -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;
index fd2157ab9cb9c02aa4847a5d1b685faca8c841f3..d24871c4f594dddf2e69c27392871f6976131694 100644 (file)
@@ -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];