diff --git a/src/bgp/bgp_show_neighbor.cc b/src/bgp/bgp_show_neighbor.cc index 1dd141a408b..b4c8b4e945a 100644 --- a/src/bgp/bgp_show_neighbor.cc +++ b/src/bgp/bgp_show_neighbor.cc @@ -28,7 +28,7 @@ static bool FillBgpNeighborInfoList(const BgpSandeshContext *bsc, rtinstance->peer_manager()->FillBgpNeighborInfo( bsc, show_list, search_string, summary); - BgpPeer *peer = bsc->bgp_server->FindNextPeer(); + const BgpPeer *peer = bsc->bgp_server->FindNextPeer(); while (peer) { if (search_string.empty() || (peer->peer_basename().find(search_string) != string::npos) || diff --git a/src/bgp/routing-instance/peer_manager.cc b/src/bgp/routing-instance/peer_manager.cc index 2a921f8843e..3ee7866aaaf 100644 --- a/src/bgp/routing-instance/peer_manager.cc +++ b/src/bgp/routing-instance/peer_manager.cc @@ -239,22 +239,10 @@ BgpPeer *PeerManager::PeerLookup(TcpSession::Endpoint remote_endpoint) const { return peer; } -BgpPeer *PeerManager::NextPeer(BgpPeerKey &peer_key) { - // Do a partial match - BgpPeerKeyMap::iterator loc = peers_by_key_.upper_bound(peer_key); - if (loc != peers_by_key_.end()) { - peer_key = loc->second->peer_key(); - return loc->second; - } - - return NULL; -} - -const BgpPeer *PeerManager::NextPeer(BgpPeerKey &peer_key) const { +const BgpPeer *PeerManager::NextPeer(const BgpPeerKey &peer_key) const { // Do a partial match BgpPeerKeyMap::const_iterator loc = peers_by_key_.upper_bound(peer_key); if (loc != peers_by_key_.end()) { - peer_key = loc->second->peer_key(); return loc->second; } @@ -282,5 +270,6 @@ void PeerManager::FillBgpNeighborInfo(const BgpSandeshContext *bsc, peer->FillNeighborInfo(bsc, &bnr, summary); bnr_list->push_back(bnr); } + key = peer->peer_key(); } } diff --git a/src/bgp/routing-instance/peer_manager.h b/src/bgp/routing-instance/peer_manager.h index da51505cade..fc0a9013afd 100644 --- a/src/bgp/routing-instance/peer_manager.h +++ b/src/bgp/routing-instance/peer_manager.h @@ -39,8 +39,7 @@ class PeerManager { virtual void DestroyIPeer(IPeer *ipeer); void ClearAllPeers(); - virtual BgpPeer *NextPeer(BgpPeerKey &key); - virtual const BgpPeer *NextPeer(BgpPeerKey &key) const; + const BgpPeer *NextPeer(const BgpPeerKey &key) const; void FillBgpNeighborInfo(const BgpSandeshContext *bsc, std::vector *sbnr_list,