]> 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>
Thu, 7 Mar 2019 07:47:25 +0000 (13:17 +0530)
committerAkhilesh Samineni <akhilesh.samineni@broadcom.com>
Thu, 7 Mar 2019 07:47:25 +0000 (13:17 +0530)
The "show bgp ipv6 summary" output displays incorrect number of peers count.

sonic# show bgp ipv6 summary

IPv6 Unicast Summary:
BGP router identifier 10.1.0.1, local AS number 65100 vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 5, using 103 KiB of memory
Peer groups 1, using 64 bytes of memory

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2003::1 4 65099 0 0 0 0 0 never Active
2088::1 4 65100 0 0 0 0 0 never Active
3021::2 4 65100 0 0 0 0 0 never Active

Total number of neighbors 3
sonic#
In the above output, the peers count displays as 5 but the actual peer count is 3, i.e.. 3 neighbors are activated in ipv6 unicast address family.
Displayed peer count (5) is the number of the neighbors activated in a BGP instance.

Fix : Now the peers count displays the number of neighbors activated per afi/safi.
After Fix:
sonic# show bgp ipv6 summary

IPv6 Unicast Summary:
BGP router identifier 10.1.0.1, local AS number 65100 vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 3, using 62 KiB of memory
Peer groups 1, using 64 bytes of memory

Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2003::1 4 65099 0 0 0 0 0 never Active
2088::1 4 65100 0 0 0 0 0 never Active
3021::2 4 65100 0 0 0 0 0 never Active

Total number of neighbors 3
sonic#

Signed-off-by: Akhilesh Samineni <akhilesh.samineni@broadcom.com>
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h
tests/topotests/all-protocol-startup/r1/show_bgp_ipv6_summary.ref

index 93d22087bbc7009f4d22e14f93c53fb78ce11b8a..f111ad3c7ff510a69d73fc4736e19d663351d48a 100644 (file)
@@ -8031,7 +8031,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));
@@ -8071,7 +8071,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 a920cfeeec14524ad55789fb4028a18cd21a424c..e7361ca0c683bc80593ea3b0ca3c3787a9f3b391 100644 (file)
@@ -707,6 +707,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;
@@ -715,6 +716,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 */
@@ -725,6 +727,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;
 }
@@ -747,6 +750,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;
@@ -759,6 +763,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)) {
@@ -768,8 +773,12 @@ int peer_af_delete(struct peer *peer, afi_t afi, safi_t safi)
                                   af->subgroup->id, peer->host);
        }
 
+
        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 c7d137c76c169bc8acddfd781a3293b29ab2f99c..8f8696438bd71e3e9eed9890a60e3ec86a3dd98d 100644 (file)
@@ -374,6 +374,9 @@ struct bgp {
 #define BGP_CONFIG_VRF_TO_VRF_IMPORT                   (1 << 7)
 #define BGP_CONFIG_VRF_TO_VRF_EXPORT                   (1 << 8)
 
+       /* 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];
 
index 6777cd9fc3031ea4bfda92082df65db83beda5b6..85388c738d549f908f3849a9386267fdd7ef196d 100644 (file)
@@ -1,7 +1,7 @@
 BGP router identifier 192.168.0.1, local AS number 100 vrf-id 0
 BGP table version 1
 RIB entries 1, using XXXX bytes of memory
-Peers 4, using XXXX KiB of memory
+Peers 2, using XXXX KiB of memory
 
 Neighbor         V         AS MsgRcvd MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd
 fc00:0:0:8::1000 4        100       0       0        0    0    0    never       Active