diff --git a/src/bgp/bgp_config.cc b/src/bgp/bgp_config.cc index 1ab6146c3a0..7ce6270e388 100644 --- a/src/bgp/bgp_config.cc +++ b/src/bgp/bgp_config.cc @@ -160,6 +160,7 @@ void BgpNeighborConfig::CopyValues(const BgpNeighborConfig &rhs) { identifier_ = rhs.identifier_; address_ = rhs.address_; port_ = rhs.port_; + remote_endpoint_ = rhs.remote_endpoint_; hold_time_ = rhs.hold_time_; loop_count_ = rhs.loop_count_; local_as_ = rhs.local_as_; @@ -179,6 +180,7 @@ int BgpNeighborConfig::CompareTo(const BgpNeighborConfig &rhs) const { KEY_COMPARE(identifier_, rhs.identifier_); KEY_COMPARE(address_, rhs.address_); KEY_COMPARE(port_, rhs.port_); + KEY_COMPARE(remote_endpoint_, rhs.remote_endpoint_); KEY_COMPARE(hold_time_, rhs.hold_time_); KEY_COMPARE(loop_count_, rhs.loop_count_); KEY_COMPARE(local_as_, rhs.local_as_); diff --git a/src/bgp/bgp_config.h b/src/bgp/bgp_config.h index 508e240f26e..444a3ec300d 100644 --- a/src/bgp/bgp_config.h +++ b/src/bgp/bgp_config.h @@ -12,6 +12,7 @@ #include #include "base/util.h" +#include "io/tcp_session.h" #include "net/address.h" class BgpServer; @@ -184,6 +185,16 @@ class BgpNeighborConfig { int port() const { return port_; } void set_port(int port) { port_ = port; } + TcpSession::Endpoint remote_endpoint() const { return remote_endpoint_; } + void set_remote_endpoint(TcpSession::Endpoint remote_endpoint) { + remote_endpoint_ = remote_endpoint; + } + + std::string router_type() const { return router_type_; } + void set_router_type(const std::string &router_type) { + router_type_ = router_type; + } + int hold_time() const { return hold_time_; } void set_hold_time(int hold_time) { hold_time_ = hold_time; } @@ -236,12 +247,14 @@ class BgpNeighborConfig { std::string instance_name_; std::string group_name_; Type type_; + std::string router_type_; bool admin_down_; bool passive_; uint32_t peer_as_; uint32_t identifier_; IpAddress address_; int port_; + TcpSession::Endpoint remote_endpoint_; int hold_time_; uint8_t loop_count_; uint32_t local_as_; diff --git a/src/bgp/bgp_config_ifmap.cc b/src/bgp/bgp_config_ifmap.cc index d3ba9144e91..000e2ffbc14 100644 --- a/src/bgp/bgp_config_ifmap.cc +++ b/src/bgp/bgp_config_ifmap.cc @@ -216,8 +216,11 @@ static void NeighborSetSessionAttributes( const autogen::BgpSessionAttributes *attr = iter.operator->(); if (attr->bgp_router.empty()) { common = attr; - } else if (attr->bgp_router == localname || - attr->bgp_router == "BGPaaS") { + } else if (neighbor->router_type() != "bgpaas-client" && + attr->bgp_router == localname) { + local = attr; + } else if (neighbor->router_type() == "bgpaas-client" && + attr->bgp_router == "bgpaas-server") { local = attr; } } @@ -267,6 +270,7 @@ static BgpNeighborConfig *MakeBgpNeighborConfig( // Store a copy of the remote bgp-router's autogen::BgpRouterParams and // derive the autogen::BgpSessionAttributes for the session. const autogen::BgpRouterParams ¶ms = remote_router->parameters(); + neighbor->set_router_type(params.router_type); if (params.admin_down) { neighbor->set_admin_down(true); } @@ -291,7 +295,6 @@ static BgpNeighborConfig *MakeBgpNeighborConfig( } neighbor->set_peer_identifier(IpAddressToBgpIdentifier(identifier)); - neighbor->set_port(params.port); neighbor->set_hold_time(params.hold_time); @@ -299,6 +302,29 @@ static BgpNeighborConfig *MakeBgpNeighborConfig( NeighborSetSessionAttributes(neighbor, local_name, session); } + // Get remote endpoint information for bgpaas-clients if appropriate. + if (params.router_type == "bgpaas-client" && + remote_router->IsPropertySet( + autogen::BgpRouter::BGP_AS_A_SERVICE_PARAMETERS)) { + const autogen::BgpAsAServiceParameters &bgpaas_params = + remote_router->bgp_as_a_service_parameters(); + Ip4Address vrouter_address = + Ip4Address::from_string(bgpaas_params.vrouter_ip_address, err); + if (err) { + BGP_LOG_STR(BgpConfig, SandeshLevel::SYS_WARN, BGP_LOG_FLAG_ALL, + "Invalid bgpaas-client vrouter ip address " << + bgpaas_params.vrouter_ip_address << + " for neighbor " << neighbor->name()); + } + if (bgpaas_params.port < 0 || bgpaas_params.port > 65535) { + BGP_LOG_STR(BgpConfig, SandeshLevel::SYS_WARN, BGP_LOG_FLAG_ALL, + "Invalid bgpaas-client port " << bgpaas_params.port << + " for neighbor " << neighbor->name()); + } + neighbor->set_remote_endpoint(TcpSession::Endpoint(vrouter_address, + static_cast(bgpaas_params.port))); + } + // Get the local identifier and local as from the master protocol config. const BgpIfmapProtocolConfig *master_protocol = master_instance->protocol_config(); @@ -501,11 +527,17 @@ bool BgpIfmapPeeringConfig::GetRouterPair(DBGraph *db_graph, IFMapNode *adj = static_cast(iter.operator->()); if (strcmp(adj->table()->Typename(), "bgp-router") != 0) continue; + autogen::BgpRouter *router = + static_cast(adj->GetObject()); + if (!router) + continue; + const autogen::BgpRouterParams ¶ms = router->parameters(); string instance_name(IdentifierParent(adj->name())); string name = adj->name().substr(instance_name.size() + 1); - if (name == localname || - (instance_name != BgpConfigManager::kMasterInstance && - name == "BGPaaS")) { + if (name == localname && params.router_type != "bgpaas-client") { + local = adj; + } else if (instance_name != BgpConfigManager::kMasterInstance && + params.router_type == "bgpaas-server") { local = adj; } else { remote = adj; diff --git a/src/bgp/bgp_peer.cc b/src/bgp/bgp_peer.cc index 960ace2e8f6..494f38fe8f6 100644 --- a/src/bgp/bgp_peer.cc +++ b/src/bgp/bgp_peer.cc @@ -343,7 +343,9 @@ BgpPeer::BgpPeer(BgpServer *server, RoutingInstance *instance, : server_(server), rtinstance_(instance), peer_key_(config), + remote_endpoint_(config->remote_endpoint()), peer_name_(config->name()), + router_type_(config->router_type()), config_(config), index_(server->RegisterPeer(this)), trigger_(boost::bind(&BgpPeer::ResumeClose, this), @@ -359,6 +361,7 @@ BgpPeer::BgpPeer(BgpServer *server, RoutingInstance *instance, send_ready_(true), admin_down_(config->admin_down()), passive_(config->passive()), + resolve_paths_(config->router_type() == "bgpaas-client"), state_machine_(BgpObjectFactory::Create(this)), membership_req_pending_(0), defer_close_(false), @@ -575,6 +578,13 @@ void BgpPeer::ConfigUpdate(const BgpNeighborConfig *config) { clear_session = true; } + if (router_type_ != config->router_type()) { + router_type_ = config->router_type(); + peer_info.set_router_type(router_type_); + resolve_paths_ = (config->router_type() == "bgpaas-client"), + clear_session = true; + } + // Check if there is any change in the peer address. // If the peer address is changing, remove the key for the older address. // Update with the new peer address and then process the key chain info @@ -594,6 +604,11 @@ void BgpPeer::ConfigUpdate(const BgpNeighborConfig *config) { clear_session = true; } + if (remote_endpoint_ != config->remote_endpoint()) { + remote_endpoint_ = config->remote_endpoint(); + clear_session = true; + } + BgpProto::BgpPeerType old_type = PeerType(); if (local_as_ != config->local_as()) { local_as_ = config->local_as(); @@ -624,8 +639,8 @@ void BgpPeer::ConfigUpdate(const BgpNeighborConfig *config) { peer_type_ = (peer_as_ == local_as_) ? BgpProto::IBGP : BgpProto::EBGP; if (old_type != PeerType()) { - peer_info.set_peer_type(PeerType() == BgpProto::IBGP ? - "internal" : "external"); + peer_info.set_peer_type( + PeerType() == BgpProto::IBGP ? "internal" : "external"); policy_.type = peer_type_; policy_.as_number = peer_as_; clear_session = true; @@ -1118,7 +1133,7 @@ void BgpPeer::ProcessNlri(Address::Family family, DBRequest::DBOperation oper, uint32_t BgpPeer::GetPathFlags(Address::Family family, const BgpAttr *attr) const { - uint32_t flags = 0; + uint32_t flags = resolve_paths_ ? BgpPath::ResolveNexthop : 0; // Check for OriginatorId loop in case we are an RR client. if (peer_type_ == BgpProto::IBGP && diff --git a/src/bgp/bgp_peer.h b/src/bgp/bgp_peer.h index ef989b7f6f0..396db36f1c9 100644 --- a/src/bgp/bgp_peer.h +++ b/src/bgp/bgp_peer.h @@ -137,8 +137,10 @@ class BgpPeer : public IPeer { return peer_key_.endpoint.address().to_string(); } const BgpPeerKey &peer_key() const { return peer_key_; } + TcpSession::Endpoint remote_endpoint() const { return remote_endpoint_; } const std::string &peer_name() const { return peer_name_; } const std::string &peer_basename() const { return peer_basename_; } + std::string router_type() const { return router_type_; } StateMachine::State GetState() const; virtual const std::string GetStateName() const; @@ -335,9 +337,12 @@ class BgpPeer : public IPeer { // Backpointer to routing instance RoutingInstance *rtinstance_; BgpPeerKey peer_key_; + TcpSession::Endpoint remote_endpoint_; std::string peer_name_; std::string peer_basename_; + std::string router_type_; // bgp_schema.xsd:BgpRouterType const BgpNeighborConfig *config_; + // Global peer index int index_; TaskTrigger trigger_; @@ -368,6 +373,7 @@ class BgpPeer : public IPeer { bool send_ready_; bool admin_down_; bool passive_; + bool resolve_paths_; boost::scoped_ptr state_machine_; uint64_t membership_req_pending_; diff --git a/src/bgp/bgp_peer.sandesh b/src/bgp/bgp_peer.sandesh index 1909b829637..761bf7fe58c 100644 --- a/src/bgp/bgp_peer.sandesh +++ b/src/bgp/bgp_peer.sandesh @@ -491,6 +491,7 @@ struct BgpPeerInfoData { 2: optional bool deleted 23: optional bool admin_down; 24: optional bool passive; + 25: optional string router_type; // bgp_schema.xsd:BgpRouterType 3: optional string peer_type; // internal/external 20: optional string peer_address; 4: optional u32 local_asn; diff --git a/src/bgp/bgp_server.cc b/src/bgp/bgp_server.cc index 09d322b43f1..af7c9486a07 100644 --- a/src/bgp/bgp_server.cc +++ b/src/bgp/bgp_server.cc @@ -24,6 +24,7 @@ using boost::system::error_code; using process::ConnectionState; using std::boolalpha; +using std::make_pair; using std::noboolalpha; using std::string; @@ -176,9 +177,14 @@ class BgpServer::ConfigUpdater { if (event == BgpConfigManager::CFG_ADD || event == BgpConfigManager::CFG_CHANGE) { BgpPeer *peer = peer_manager->PeerLocate(server_, neighbor_config); + server_->RemovePeer(peer->remote_endpoint(), peer); peer->ConfigUpdate(neighbor_config); + server_->InsertPeer(peer->remote_endpoint(), peer); } else if (event == BgpConfigManager::CFG_DELETE) { - peer_manager->TriggerPeerDeletion(neighbor_config); + BgpPeer *peer = peer_manager->TriggerPeerDeletion(neighbor_config); + if (peer) { + server_->RemovePeer(peer->remote_endpoint(), peer); + } } } @@ -375,6 +381,37 @@ BgpPeer *BgpServer::FindPeer(const string &name) { return (loc != peer_list_.end() ? loc->second : NULL); } +void BgpServer::InsertPeer(TcpSession::Endpoint remote, BgpPeer *peer) { + if (!remote.port() || remote.address().is_unspecified()) + return; + + EndpointToBgpPeerList::iterator loc = endpoint_peer_list_.find(remote); + if (loc != endpoint_peer_list_.end()) { + loc->second->Clear(BgpProto::Notification::PeerDeconfigured); + endpoint_peer_list_.erase(loc); + } + endpoint_peer_list_.insert(make_pair(remote, peer)); +} + +void BgpServer::RemovePeer(TcpSession::Endpoint remote, BgpPeer *peer) { + EndpointToBgpPeerList::iterator loc = endpoint_peer_list_.find(remote); + if (loc != endpoint_peer_list_.end() && loc->second == peer) { + endpoint_peer_list_.erase(loc); + } +} + +BgpPeer *BgpServer::FindPeer(TcpSession::Endpoint remote) const { + EndpointToBgpPeerList::const_iterator loc = + endpoint_peer_list_.find(remote); + return (loc == endpoint_peer_list_.end() ? NULL : loc->second); +} + +BgpPeer *BgpServer::FindNextPeer(TcpSession::Endpoint remote) const { + EndpointToBgpPeerList::const_iterator loc = + endpoint_peer_list_.upper_bound(remote); + return (loc == endpoint_peer_list_.end() ? NULL : loc->second); +} + const string &BgpServer::localname() const { return config_mgr_->localname(); } diff --git a/src/bgp/bgp_server.h b/src/bgp/bgp_server.h index 0332e92bfe7..4f293fc580a 100644 --- a/src/bgp/bgp_server.h +++ b/src/bgp/bgp_server.h @@ -52,6 +52,7 @@ class BgpServer { typedef boost::function IdentifierUpdateCb; typedef boost::function VisitorFn; typedef std::set StaticRouteMgrList; + explicit BgpServer(EventManager *evm); virtual ~BgpServer(); @@ -62,6 +63,11 @@ class BgpServer { int RegisterPeer(BgpPeer *peer); void UnregisterPeer(BgpPeer *peer); BgpPeer *FindPeer(const std::string &name); + void InsertPeer(TcpSession::Endpoint remote, BgpPeer *peer); + void RemovePeer(TcpSession::Endpoint remote, BgpPeer *peer); + BgpPeer *FindPeer(TcpSession::Endpoint remote) const; + BgpPeer *FindNextPeer( + TcpSession::Endpoint remote = TcpSession::Endpoint()) const; void Shutdown(); @@ -209,6 +215,7 @@ class BgpServer { typedef std::vector AdminDownListenersList; typedef std::vector ASNUpdateListenersList; typedef std::vector IdentifierUpdateListenersList; + typedef std::map EndpointToBgpPeerList; void RoutingInstanceMgrDeletionComplete(RoutingInstanceMgr *mgr); @@ -232,6 +239,7 @@ class BgpServer { tbb::atomic num_up_peer_; tbb::atomic closing_count_; BgpPeerList peer_list_; + EndpointToBgpPeerList endpoint_peer_list_; boost::scoped_ptr lifetime_manager_; boost::scoped_ptr deleter_; diff --git a/src/bgp/bgp_session_manager.cc b/src/bgp/bgp_session_manager.cc index f2d8dfb25f3..9a3fe8ba362 100644 --- a/src/bgp/bgp_session_manager.cc +++ b/src/bgp/bgp_session_manager.cc @@ -94,17 +94,17 @@ bool BgpSessionManager::ProcessWriteReady(TcpSessionPtr tcp_session) { } // -// Search in every routing instance for a matching BgpPeer. +// Search for a matching BgpPeer. +// First look for an exact match in the EndpointToBgpPeerList in BgpServer. +// Then look for a matching address in the master instance. // BgpPeer *BgpSessionManager::FindPeer(Endpoint remote) { - for (RoutingInstanceMgr::RoutingInstanceIterator it = - server_->routing_instance_mgr()->begin(); - it != server_->routing_instance_mgr()->end(); ++it) { - BgpPeer *peer = it->peer_manager()->PeerLookup(remote); - if (peer) - return peer; - } - return NULL; + BgpPeer *peer = server_->FindPeer(remote); + if (peer) + return peer; + const RoutingInstance *instance = + server_->routing_instance_mgr()->GetDefaultRoutingInstance(); + return (instance ? instance->peer_manager()->PeerLookup(remote) : NULL); } // diff --git a/src/bgp/bgp_show_neighbor.cc b/src/bgp/bgp_show_neighbor.cc index 22bb81524d0..ea888503e2c 100644 --- a/src/bgp/bgp_show_neighbor.cc +++ b/src/bgp/bgp_show_neighbor.cc @@ -5,12 +5,40 @@ #include "bgp/bgp_show_handler.h" +#include "bgp/bgp_peer.h" #include "bgp/bgp_peer_internal_types.h" #include "bgp/routing-instance/peer_manager.h" using std::string; using std::vector; +// +// Build the list of BgpPeers in one shot for now. Look at the master instance +// and at all peers in the BgpServer's EndpointToBgpPeerList. The latter is the +// list of all bgpaas peers in non-master instances. +// +static bool FillBgpNeighborInfoList(const BgpSandeshContext *bsc, + bool summary, uint32_t page_limit, uint32_t iter_limit, + const string &start_neighbor, const string &search_string, + vector *show_list, string *next_instance) { + const RoutingInstanceMgr *rim = bsc->bgp_server->routing_instance_mgr(); + const RoutingInstance *rtinstance = rim->GetDefaultRoutingInstance(); + rtinstance->peer_manager()->FillBgpNeighborInfo( + bsc, show_list, search_string, summary); + + BgpPeer *peer = bsc->bgp_server->FindNextPeer(); + while (peer) { + if (search_string.empty() || + (peer->peer_basename().find(search_string) != string::npos) || + (peer->peer_address_string().find(search_string) != string::npos) || + (search_string == "deleted" && peer->IsDeleted())) { + peer->FillNeighborInfo(bsc, show_list, summary); + } + peer = bsc->bgp_server->FindNextPeer(peer->remote_endpoint()); + } + return true; +} + // // Specialization of BgpShowHandler<>::CallbackCommon for regular introspect. // @@ -25,13 +53,10 @@ bool BgpShowHandlerpage_limit() ? bsc->page_limit() : kPageLimit; uint32_t iter_limit = bsc->iter_limit() ? bsc->iter_limit() : kIterLimit; - // Look only at the master instance since we don't have bgp neighbors in - // other instances currently. - RoutingInstanceMgr *rim = bsc->bgp_server->routing_instance_mgr(); - const RoutingInstance *rtinstance = rim->GetDefaultRoutingInstance(); - if (rtinstance && data->next_entry.empty()) { - rtinstance->peer_manager()->FillBgpNeighborInfo( - bsc, &data->show_list, data->search_string, false); + // Build the list of BgpPeers in one shot for now. + if (data->next_entry.empty()) { + FillBgpNeighborInfoList(bsc, false, page_limit, iter_limit, string(), + data->search_string, &data->show_list, NULL); } // Add xmpp neighbors. @@ -68,13 +93,10 @@ bool BgpShowHandlerpage_limit() ? bsc->page_limit() : kPageLimit; uint32_t iter_limit = bsc->iter_limit() ? bsc->iter_limit() : kIterLimit; - // Look only at the master instance since we don't have bgp neighbors in - // other instances currently. - RoutingInstanceMgr *rim = bsc->bgp_server->routing_instance_mgr(); - const RoutingInstance *rtinstance = rim->GetDefaultRoutingInstance(); - if (rtinstance && data->next_entry.empty()) { - rtinstance->peer_manager()->FillBgpNeighborInfo( - bsc, &data->show_list, data->search_string, true); + // Build the list of BgpPeers in one shot for now. + if (data->next_entry.empty()) { + FillBgpNeighborInfoList(bsc, true, page_limit, iter_limit, string(), + data->search_string, &data->show_list, NULL); } // Add xmpp neighbors. diff --git a/src/bgp/routing-instance/peer_manager.cc b/src/bgp/routing-instance/peer_manager.cc index 766c006181a..b36301fd65e 100644 --- a/src/bgp/routing-instance/peer_manager.cc +++ b/src/bgp/routing-instance/peer_manager.cc @@ -66,12 +66,12 @@ void PeerManager::PeerResurrect(string name) { // // Delete the BgpPeer corresponding to the given BgpNeighborConfig. // -void PeerManager::TriggerPeerDeletion(const BgpNeighborConfig *config) { +BgpPeer *PeerManager::TriggerPeerDeletion(const BgpNeighborConfig *config) { CHECK_CONCURRENCY("bgp::Config"); BgpPeerNameMap::iterator loc = peers_by_name_.find(config->name()); if (loc == peers_by_name_.end()) - return; + return NULL; BgpPeer *peer = loc->second; peer->ManagedDelete(); @@ -86,6 +86,7 @@ void PeerManager::TriggerPeerDeletion(const BgpNeighborConfig *config) { // Configuration is deleted by the config manager (parser) // Do not hold reference to it any more peer->ClearConfig(); + return peer; } // @@ -148,7 +149,7 @@ void PeerManager::RemovePeerByName(const string name, BgpPeer *peer) { peers_by_name_.erase(loc); } -BgpPeer *PeerManager::PeerFind(string ip_address) { +BgpPeer *PeerManager::PeerFind(string ip_address) const { if (ip_address.empty()) return NULL; @@ -161,8 +162,8 @@ BgpPeer *PeerManager::PeerFind(string ip_address) { return PeerLookup(endpoint); } -BgpPeer *PeerManager::PeerLookup(string name) { - BgpPeerNameMap::iterator loc = peers_by_name_.find(name); +BgpPeer *PeerManager::PeerLookup(string name) const { + BgpPeerNameMap::const_iterator loc = peers_by_name_.find(name); return (loc != peers_by_name_.end() ? loc->second : NULL); } @@ -185,8 +186,7 @@ size_t PeerManager::GetNeighborCount(string up_or_down) { // // Concurrency: Called from state machine thread // -BgpPeer *PeerManager::PeerLookup( - boost::asio::ip::tcp::endpoint remote_endpoint) { +BgpPeer *PeerManager::PeerLookup(TcpSession::Endpoint remote_endpoint) const { BgpPeer *peer = NULL; BgpPeerKey peer_key; @@ -197,7 +197,7 @@ BgpPeer *PeerManager::PeerLookup( peer_key.endpoint.address(remote_endpoint.address()); // Do a partial match, as we do not know the peer's port yet. - BgpPeerKeyMap::iterator loc = peers_by_key_.lower_bound(peer_key); + BgpPeerKeyMap::const_iterator loc = peers_by_key_.lower_bound(peer_key); while (loc != peers_by_key_.end()) { // Check if the address does indeed match as we are doing a partial // match here diff --git a/src/bgp/routing-instance/peer_manager.h b/src/bgp/routing-instance/peer_manager.h index b080dee2532..d56b48863c8 100644 --- a/src/bgp/routing-instance/peer_manager.h +++ b/src/bgp/routing-instance/peer_manager.h @@ -29,13 +29,13 @@ class PeerManager { explicit PeerManager(RoutingInstance *instance) : instance_(instance) { } virtual ~PeerManager() { } - virtual BgpPeer *PeerFind(std::string address); - virtual BgpPeer *PeerLookup(std::string name); - virtual BgpPeer *PeerLookup(boost::asio::ip::tcp::endpoint remote_endpoint); + virtual BgpPeer *PeerFind(std::string address) const; + virtual BgpPeer *PeerLookup(std::string name) const; + virtual BgpPeer *PeerLookup(TcpSession::Endpoint remote_endpoint) const; virtual BgpPeer *PeerLocate(BgpServer *server, const BgpNeighborConfig *config); void PeerResurrect(std::string name); - void TriggerPeerDeletion(const BgpNeighborConfig *config); + BgpPeer *TriggerPeerDeletion(const BgpNeighborConfig *config); virtual void DestroyIPeer(IPeer *ipeer); virtual BgpPeer *NextPeer(BgpPeerKey &key); diff --git a/src/bgp/test/bgp_config_test.cc b/src/bgp/test/bgp_config_test.cc index f052d467d0b..4be085abc7c 100644 --- a/src/bgp/test/bgp_config_test.cc +++ b/src/bgp/test/bgp_config_test.cc @@ -65,6 +65,8 @@ class BgpConfigTest : public ::testing::Test { return (peer->family_attributes_list_[family]); } + bool GetPeerResolvePaths(BgpPeer *peer) { return peer->resolve_paths_; } + EventManager evm_; BgpServer server_; DB config_db_; @@ -315,7 +317,7 @@ TEST_F(BgpConfigTest, MasterNeighbors) { TASK_UTIL_EXPECT_EQ(2, rti->peer_manager()->size()); } -TEST_F(BgpConfigTest, InstanceBGPaaSNeighbors) { +TEST_F(BgpConfigTest, BGPaaSNeighbors1) { string content; content = FileRead("controller/src/bgp/testdata/config_test_36a.xml"); EXPECT_TRUE(parser_.Parse(content)); @@ -326,19 +328,23 @@ TEST_F(BgpConfigTest, InstanceBGPaaSNeighbors) { TASK_UTIL_ASSERT_TRUE(rti != NULL); TASK_UTIL_EXPECT_EQ(2, rti->peer_manager()->size()); - TASK_UTIL_EXPECT_TRUE(rti->peer_manager()->PeerLookup("test:vm1:0") != NULL); + TASK_UTIL_EXPECT_TRUE( + rti->peer_manager()->PeerLookup("test:vm1:0") != NULL); BgpPeer *peer1 = rti->peer_manager()->PeerLookup("test:vm1:0"); TASK_UTIL_EXPECT_EQ(64512, peer1->local_as()); TASK_UTIL_EXPECT_EQ("192.168.1.1", peer1->local_bgp_identifier_string()); TASK_UTIL_EXPECT_EQ(65001, peer1->peer_as()); TASK_UTIL_EXPECT_EQ("10.0.0.1", peer1->peer_address_string()); + TASK_UTIL_EXPECT_TRUE(GetPeerResolvePaths(peer1)); - TASK_UTIL_EXPECT_TRUE(rti->peer_manager()->PeerLookup("test:vm2:0") != NULL); + TASK_UTIL_EXPECT_TRUE( + rti->peer_manager()->PeerLookup("test:vm2:0") != NULL); BgpPeer *peer2 = rti->peer_manager()->PeerLookup("test:vm2:0"); TASK_UTIL_EXPECT_EQ(64512, peer2->local_as()); TASK_UTIL_EXPECT_EQ("192.168.1.1", peer2->local_bgp_identifier_string()); TASK_UTIL_EXPECT_EQ(65002, peer2->peer_as()); TASK_UTIL_EXPECT_EQ("10.0.0.2", peer2->peer_address_string()); + TASK_UTIL_EXPECT_TRUE(GetPeerResolvePaths(peer2)); // Change asn and identifier for master. content = FileRead("controller/src/bgp/testdata/config_test_36b.xml"); @@ -348,9 +354,187 @@ TEST_F(BgpConfigTest, InstanceBGPaaSNeighbors) { // Verify that instance neighbors use the new values. TASK_UTIL_EXPECT_EQ(64513, peer1->local_as()); TASK_UTIL_EXPECT_EQ("192.168.1.2", peer1->local_bgp_identifier_string()); + TASK_UTIL_EXPECT_TRUE(GetPeerResolvePaths(peer1)); TASK_UTIL_EXPECT_EQ(64513, peer2->local_as()); TASK_UTIL_EXPECT_EQ("192.168.1.2", peer2->local_bgp_identifier_string()); + TASK_UTIL_EXPECT_TRUE(GetPeerResolvePaths(peer2)); + + content = FileRead("controller/src/bgp/testdata/config_test_36a.xml"); + boost::replace_all(content, "", ""); + boost::replace_all(content, "", ""); + EXPECT_TRUE(parser_.Parse(content)); + task_util::WaitForIdle(); + TASK_UTIL_EXPECT_EQ(0, rti->peer_manager()->size()); +} + +TEST_F(BgpConfigTest, BGPaaSNeighbors2) { + string content; + content = FileRead("controller/src/bgp/testdata/config_test_36a.xml"); + EXPECT_TRUE(parser_.Parse(content)); + task_util::WaitForIdle(); + + RoutingInstance *rti = + server_.routing_instance_mgr()->GetRoutingInstance("test"); + TASK_UTIL_ASSERT_TRUE(rti != NULL); + TASK_UTIL_EXPECT_EQ(2, rti->peer_manager()->size()); + + TASK_UTIL_EXPECT_TRUE( + rti->peer_manager()->PeerLookup("test:vm1:0") != NULL); + BgpPeer *peer1 = rti->peer_manager()->PeerLookup("test:vm1:0"); + TASK_UTIL_EXPECT_EQ("0.0.0.0", + peer1->remote_endpoint().address().to_string()); + TASK_UTIL_EXPECT_EQ(0, peer1->remote_endpoint().port()); + TASK_UTIL_EXPECT_TRUE(GetPeerResolvePaths(peer1)); + + TASK_UTIL_EXPECT_TRUE( + rti->peer_manager()->PeerLookup("test:vm2:0") != NULL); + BgpPeer *peer2 = rti->peer_manager()->PeerLookup("test:vm2:0"); + TASK_UTIL_EXPECT_EQ("0.0.0.0", + peer2->remote_endpoint().address().to_string()); + TASK_UTIL_EXPECT_EQ(0, peer2->remote_endpoint().port()); + TASK_UTIL_EXPECT_TRUE(GetPeerResolvePaths(peer2)); + + // Set BgpAsAServiceParameters for router test:vm1. + autogen::BgpAsAServiceParameters *bgpaas_params1 = + new autogen::BgpAsAServiceParameters; + bgpaas_params1->vrouter_ip_address = "172.16.1.99"; + bgpaas_params1->port = 1024; + ifmap_test_util::IFMapMsgPropertyAdd(&config_db_, "bgp-router", "test:vm1", + "bgp-as-a-service-parameters", bgpaas_params1); + task_util::WaitForIdle(); + + // Verify that the vrouter ip address and port are updated for test:vm1. + TASK_UTIL_EXPECT_EQ("172.16.1.99", + peer1->remote_endpoint().address().to_string()); + TASK_UTIL_EXPECT_EQ(1024, peer1->remote_endpoint().port()); + TASK_UTIL_EXPECT_EQ(peer1, server_.FindPeer(peer1->remote_endpoint())); + TASK_UTIL_EXPECT_TRUE(GetPeerResolvePaths(peer1)); + + // Set BgpAsAServiceParameters for router test:vm2. + autogen::BgpAsAServiceParameters *bgpaas_params2 = + new autogen::BgpAsAServiceParameters; + bgpaas_params2->vrouter_ip_address = "172.16.1.99"; + bgpaas_params2->port = 1025; + ifmap_test_util::IFMapMsgPropertyAdd(&config_db_, "bgp-router", "test:vm2", + "bgp-as-a-service-parameters", bgpaas_params2); + task_util::WaitForIdle(); + + // Verify that the vrouter ip address and port are updated for test:vm2. + TASK_UTIL_EXPECT_EQ("172.16.1.99", + peer2->remote_endpoint().address().to_string()); + TASK_UTIL_EXPECT_EQ(1025, peer2->remote_endpoint().port()); + TASK_UTIL_EXPECT_EQ(peer2, server_.FindPeer(peer2->remote_endpoint())); + TASK_UTIL_EXPECT_TRUE(GetPeerResolvePaths(peer2)); + + ifmap_test_util::IFMapMsgPropertyDelete(&config_db_, + "bgp-router", "test:vm1", "bgp-as-a-service-parameters"); + ifmap_test_util::IFMapMsgPropertyDelete(&config_db_, + "bgp-router", "test:vm2", "bgp-as-a-service-parameters"); + content = FileRead("controller/src/bgp/testdata/config_test_36a.xml"); + boost::replace_all(content, "", ""); + boost::replace_all(content, "", ""); + EXPECT_TRUE(parser_.Parse(content)); + task_util::WaitForIdle(); + TASK_UTIL_EXPECT_EQ(0, rti->peer_manager()->size()); +} + +TEST_F(BgpConfigTest, BGPaaSNeighbors3) { + string content; + content = FileRead("controller/src/bgp/testdata/config_test_36a.xml"); + EXPECT_TRUE(parser_.Parse(content)); + + // Set BgpAsAServiceParameters for router test:vm1. + autogen::BgpAsAServiceParameters *bgpaas_params1 = + new autogen::BgpAsAServiceParameters; + bgpaas_params1->vrouter_ip_address = "172.16.1.99"; + bgpaas_params1->port = 1024; + ifmap_test_util::IFMapMsgPropertyAdd(&config_db_, "bgp-router", "test:vm1", + "bgp-as-a-service-parameters", bgpaas_params1); + // Set BgpAsAServiceParameters for router test:vm2. + autogen::BgpAsAServiceParameters *bgpaas_params2 = + new autogen::BgpAsAServiceParameters; + bgpaas_params2->vrouter_ip_address = "172.16.1.99"; + bgpaas_params2->port = 1025; + ifmap_test_util::IFMapMsgPropertyAdd(&config_db_, "bgp-router", "test:vm2", + "bgp-as-a-service-parameters", bgpaas_params2); + + // Wait for configs to be updated. + task_util::WaitForIdle(); + + RoutingInstance *rti = + server_.routing_instance_mgr()->GetRoutingInstance("test"); + TASK_UTIL_ASSERT_TRUE(rti != NULL); + TASK_UTIL_EXPECT_EQ(2, rti->peer_manager()->size()); + + // Verify that the vrouter ip address and port are set for test:vm1. + TASK_UTIL_EXPECT_TRUE( + rti->peer_manager()->PeerLookup("test:vm1:0") != NULL); + BgpPeer *peer1 = rti->peer_manager()->PeerLookup("test:vm1:0"); + TASK_UTIL_EXPECT_EQ("172.16.1.99", + peer1->remote_endpoint().address().to_string()); + TASK_UTIL_EXPECT_EQ(1024, peer1->remote_endpoint().port()); + TASK_UTIL_EXPECT_EQ(peer1, server_.FindPeer(peer1->remote_endpoint())); + + // Verify that the vrouter ip address and port are set for test:vm2. + TASK_UTIL_EXPECT_TRUE( + rti->peer_manager()->PeerLookup("test:vm2:0") != NULL); + BgpPeer *peer2 = rti->peer_manager()->PeerLookup("test:vm2:0"); + TASK_UTIL_EXPECT_EQ("172.16.1.99", + peer2->remote_endpoint().address().to_string()); + TASK_UTIL_EXPECT_EQ(1025, peer2->remote_endpoint().port()); + TASK_UTIL_EXPECT_EQ(peer2, server_.FindPeer(peer2->remote_endpoint())); + + // Save the old remote endpoint for peer1. + TcpSession::Endpoint old_peer1_remote_endpoint = peer1->remote_endpoint(); + + // Set test::vm1 port to be same as port for test:vm2. + bgpaas_params1 = new autogen::BgpAsAServiceParameters; + bgpaas_params1->vrouter_ip_address = "172.16.1.99"; + bgpaas_params1->port = 1025; + ifmap_test_util::IFMapMsgPropertyAdd(&config_db_, "bgp-router", "test:vm1", + "bgp-as-a-service-parameters", bgpaas_params1); + task_util::WaitForIdle(); + + // Verify that the vrouter ip address and port are updated for test:vm1. + TASK_UTIL_EXPECT_EQ("172.16.1.99", + peer1->remote_endpoint().address().to_string()); + TASK_UTIL_EXPECT_EQ(1025, peer1->remote_endpoint().port()); + + // Verify that the vrouter ip address and port are identical for test:vm2. + TASK_UTIL_EXPECT_EQ("172.16.1.99", + peer2->remote_endpoint().address().to_string()); + TASK_UTIL_EXPECT_EQ(1025, peer2->remote_endpoint().port()); + + // Verify that test:vm1 is inserted into BgpServer::EndpointToBgpPeerList. + // Verify that there's no entry for the old remote endpoint for test:vm1. + // Note that test:vm2 is removed from BgpServer::EndpointToBgpPeerList when + // test:vm1 is inserted with the same remote endpoint. + TASK_UTIL_EXPECT_EQ(peer1, server_.FindPeer(peer1->remote_endpoint())); + TASK_UTIL_EXPECT_TRUE(server_.FindPeer(old_peer1_remote_endpoint) == NULL); + + // Set test::vm2 port to be same as old port for test:vm2. + bgpaas_params2 = new autogen::BgpAsAServiceParameters; + bgpaas_params2->vrouter_ip_address = "172.16.1.99"; + bgpaas_params2->port = 1024; + ifmap_test_util::IFMapMsgPropertyAdd(&config_db_, "bgp-router", "test:vm2", + "bgp-as-a-service-parameters", bgpaas_params2); + task_util::WaitForIdle(); + + // Verify that the vrouter ip address and port are updated for test:vm2. + TASK_UTIL_EXPECT_EQ("172.16.1.99", + peer2->remote_endpoint().address().to_string()); + TASK_UTIL_EXPECT_EQ(1024, peer2->remote_endpoint().port()); + + // Verify that test:vm1 is inserted into BgpServer::EndpointToBgpPeerList. + // Verify that test:vm2 is inserted into BgpServer::EndpointToBgpPeerList. + TASK_UTIL_EXPECT_EQ(peer1, server_.FindPeer(peer1->remote_endpoint())); + TASK_UTIL_EXPECT_EQ(peer2, server_.FindPeer(peer2->remote_endpoint())); + + ifmap_test_util::IFMapMsgPropertyDelete(&config_db_, + "bgp-router", "test:vm1", "bgp-as-a-service-parameters"); + ifmap_test_util::IFMapMsgPropertyDelete(&config_db_, + "bgp-router", "test:vm2", "bgp-as-a-service-parameters"); content = FileRead("controller/src/bgp/testdata/config_test_36a.xml"); boost::replace_all(content, "", ""); boost::replace_all(content, "", ""); diff --git a/src/bgp/test/bgp_ifmap_config_manager_test.cc b/src/bgp/test/bgp_ifmap_config_manager_test.cc index c08aad88b9b..436576d1ff9 100644 --- a/src/bgp/test/bgp_ifmap_config_manager_test.cc +++ b/src/bgp/test/bgp_ifmap_config_manager_test.cc @@ -1309,7 +1309,7 @@ TEST_F(BgpIfmapConfigManagerTest, InstanceNeighbors) { TASK_UTIL_EXPECT_EQ(0, db_graph_.vertex_count()); } -TEST_F(BgpIfmapConfigManagerTest, InstanceBGPaaSNeighbors) { +TEST_F(BgpIfmapConfigManagerTest, BGPaaSNeighbors1) { string content; content = FileRead("controller/src/bgp/testdata/config_test_36a.xml"); EXPECT_TRUE(parser_.Parse(content)); @@ -1322,18 +1322,24 @@ TEST_F(BgpIfmapConfigManagerTest, InstanceBGPaaSNeighbors) { const BgpNeighborConfig *nbr_config1; nbr_config1 = config_manager_->FindNeighbor("test", "test:vm1:0"); EXPECT_TRUE(nbr_config1 != NULL); + EXPECT_EQ("bgpaas-client", nbr_config1->router_type()); EXPECT_EQ(64512, nbr_config1->local_as()); EXPECT_EQ("192.168.1.1", nbr_config1->local_identifier_string()); EXPECT_EQ(65001, nbr_config1->peer_as()); EXPECT_EQ("10.0.0.1", nbr_config1->peer_address_string()); + EXPECT_EQ("0.0.0.0", nbr_config1->remote_endpoint().address().to_string()); + EXPECT_EQ(0, nbr_config1->remote_endpoint().port()); const BgpNeighborConfig *nbr_config2; nbr_config2 = config_manager_->FindNeighbor("test", "test:vm2:0"); EXPECT_TRUE(nbr_config2 != NULL); + EXPECT_EQ("bgpaas-client", nbr_config2->router_type()); EXPECT_EQ(64512, nbr_config2->local_as()); EXPECT_EQ("192.168.1.1", nbr_config2->local_identifier_string()); EXPECT_EQ(65002, nbr_config2->peer_as()); EXPECT_EQ("10.0.0.2", nbr_config2->peer_address_string()); + EXPECT_EQ("0.0.0.0", nbr_config2->remote_endpoint().address().to_string()); + EXPECT_EQ(0, nbr_config2->remote_endpoint().port()); // Change asn and identifier for master. content = FileRead("controller/src/bgp/testdata/config_test_36b.xml"); @@ -1360,6 +1366,161 @@ TEST_F(BgpIfmapConfigManagerTest, InstanceBGPaaSNeighbors) { TASK_UTIL_EXPECT_EQ(0, db_graph_.vertex_count()); } +TEST_F(BgpIfmapConfigManagerTest, BGPaaSNeighbors2) { + string content; + content = FileRead("controller/src/bgp/testdata/config_test_36a.xml"); + EXPECT_TRUE(parser_.Parse(content)); + task_util::WaitForIdle(); + + const BgpInstanceConfig *rti = FindInstanceConfig("test"); + EXPECT_TRUE(rti != NULL); + EXPECT_EQ(2, config_manager_->NeighborCount("test")); + + // Verify that the vrouter ip address and port are not set for test:vm1. + const BgpNeighborConfig *nbr_config1; + nbr_config1 = config_manager_->FindNeighbor("test", "test:vm1:0"); + EXPECT_TRUE(nbr_config1 != NULL); + EXPECT_EQ("bgpaas-client", nbr_config1->router_type()); + EXPECT_EQ("0.0.0.0", nbr_config1->remote_endpoint().address().to_string()); + EXPECT_EQ(0, nbr_config1->remote_endpoint().port()); + + // Verify that the vrouter ip address and port are not set for test:vm2. + const BgpNeighborConfig *nbr_config2; + nbr_config2 = config_manager_->FindNeighbor("test", "test:vm2:0"); + EXPECT_TRUE(nbr_config2 != NULL); + EXPECT_EQ("bgpaas-client", nbr_config2->router_type()); + EXPECT_EQ("0.0.0.0", nbr_config2->remote_endpoint().address().to_string()); + EXPECT_EQ(0, nbr_config2->remote_endpoint().port()); + + // Set BgpAsAServiceParameters for router test:vm1. + autogen::BgpAsAServiceParameters *bgpaas_params1 = + new autogen::BgpAsAServiceParameters; + bgpaas_params1->vrouter_ip_address = "172.16.1.99"; + bgpaas_params1->port = 1024; + ifmap_test_util::IFMapMsgPropertyAdd(&db_, "bgp-router", "test:vm1", + "bgp-as-a-service-parameters", bgpaas_params1); + task_util::WaitForIdle(); + + // Verify that the vrouter ip address and port are updated for test:vm1. + nbr_config1 = config_manager_->FindNeighbor("test", "test:vm1:0"); + EXPECT_EQ("172.16.1.99", + nbr_config1->remote_endpoint().address().to_string()); + EXPECT_EQ(1024, nbr_config1->remote_endpoint().port()); + + // Set BgpAsAServiceParameters for router test:vm2. + autogen::BgpAsAServiceParameters *bgpaas_params2 = + new autogen::BgpAsAServiceParameters; + bgpaas_params2->vrouter_ip_address = "172.16.1.99"; + bgpaas_params2->port = 1025; + ifmap_test_util::IFMapMsgPropertyAdd(&db_, "bgp-router", "test:vm2", + "bgp-as-a-service-parameters", bgpaas_params2); + task_util::WaitForIdle(); + + // Verify that the vrouter ip address and port are updated for test:vm2. + nbr_config2 = config_manager_->FindNeighbor("test", "test:vm2:0"); + EXPECT_EQ("172.16.1.99", + nbr_config2->remote_endpoint().address().to_string()); + EXPECT_EQ(1025, nbr_config2->remote_endpoint().port()); + + // Cleanup. + ifmap_test_util::IFMapMsgPropertyDelete(&db_, "bgp-router", "test:vm1", + "bgp-as-a-service-parameters"); + ifmap_test_util::IFMapMsgPropertyDelete(&db_, "bgp-router", "test:vm2", + "bgp-as-a-service-parameters"); + content = FileRead("controller/src/bgp/testdata/config_test_36a.xml"); + boost::replace_all(content, "", ""); + boost::replace_all(content, "", ""); + EXPECT_TRUE(parser_.Parse(content)); + task_util::WaitForIdle(); + TASK_UTIL_EXPECT_EQ(1, config_manager_->config()->instances().size()); + TASK_UTIL_EXPECT_EQ(0, config_manager_->NeighborCount("test")); + TASK_UTIL_EXPECT_EQ(0, db_graph_.vertex_count()); +} + +TEST_F(BgpIfmapConfigManagerTest, BGPaaSNeighbors3) { + string content; + content = FileRead("controller/src/bgp/testdata/config_test_36a.xml"); + EXPECT_TRUE(parser_.Parse(content)); + + // Set BgpAsAServiceParameters for router test:vm1. + autogen::BgpAsAServiceParameters *bgpaas_params1 = + new autogen::BgpAsAServiceParameters; + bgpaas_params1->vrouter_ip_address = "172.16.1.99"; + bgpaas_params1->port = 1024; + ifmap_test_util::IFMapMsgPropertyAdd(&db_, "bgp-router", "test:vm1", + "bgp-as-a-service-parameters", bgpaas_params1); + + // Set BgpAsAServiceParameters for router test:vm2. + autogen::BgpAsAServiceParameters *bgpaas_params2 = + new autogen::BgpAsAServiceParameters; + bgpaas_params2->vrouter_ip_address = "172.16.1.99"; + bgpaas_params2->port = 1025; + ifmap_test_util::IFMapMsgPropertyAdd(&db_, "bgp-router", "test:vm2", + "bgp-as-a-service-parameters", bgpaas_params2); + + task_util::WaitForIdle(); + const BgpInstanceConfig *rti = FindInstanceConfig("test"); + EXPECT_TRUE(rti != NULL); + EXPECT_EQ(2, config_manager_->NeighborCount("test")); + + // Verify that the vrouter ip address and port are set for test:vm1. + const BgpNeighborConfig *nbr_config1; + nbr_config1 = config_manager_->FindNeighbor("test", "test:vm1:0"); + EXPECT_EQ("172.16.1.99", + nbr_config1->remote_endpoint().address().to_string()); + EXPECT_EQ(1024, nbr_config1->remote_endpoint().port()); + + // Verify that the vrouter ip address and port are set for test:vm2. + const BgpNeighborConfig *nbr_config2; + nbr_config2 = config_manager_->FindNeighbor("test", "test:vm2:0"); + EXPECT_EQ("172.16.1.99", + nbr_config2->remote_endpoint().address().to_string()); + EXPECT_EQ(1025, nbr_config2->remote_endpoint().port()); + + // Update BgpAsAServiceParameters for router test:vm1. + bgpaas_params1 = new autogen::BgpAsAServiceParameters; + bgpaas_params1->vrouter_ip_address = "172.16.1.99"; + bgpaas_params1->port = 1025; + ifmap_test_util::IFMapMsgPropertyAdd(&db_, "bgp-router", "test:vm1", + "bgp-as-a-service-parameters", bgpaas_params1); + + // Update BgpAsAServiceParameters for router test:vm2. + bgpaas_params2 = new autogen::BgpAsAServiceParameters; + bgpaas_params2->vrouter_ip_address = "172.16.1.99"; + bgpaas_params2->port = 1024; + ifmap_test_util::IFMapMsgPropertyAdd(&db_, "bgp-router", "test:vm2", + "bgp-as-a-service-parameters", bgpaas_params2); + + // Wait for the configs to get updated. + task_util::WaitForIdle(); + + // Verify that the vrouter ip address and port are updated for test:vm1. + nbr_config1 = config_manager_->FindNeighbor("test", "test:vm1:0"); + EXPECT_EQ("172.16.1.99", + nbr_config1->remote_endpoint().address().to_string()); + EXPECT_EQ(1025, nbr_config1->remote_endpoint().port()); + + // Verify that the vrouter ip address and port are updated for test:vm2. + nbr_config2 = config_manager_->FindNeighbor("test", "test:vm2:0"); + EXPECT_EQ("172.16.1.99", + nbr_config2->remote_endpoint().address().to_string()); + EXPECT_EQ(1024, nbr_config2->remote_endpoint().port()); + + // Cleanup. + ifmap_test_util::IFMapMsgPropertyDelete(&db_, "bgp-router", "test:vm1", + "bgp-as-a-service-parameters"); + ifmap_test_util::IFMapMsgPropertyDelete(&db_, "bgp-router", "test:vm2", + "bgp-as-a-service-parameters"); + content = FileRead("controller/src/bgp/testdata/config_test_36a.xml"); + boost::replace_all(content, "", ""); + boost::replace_all(content, "", ""); + EXPECT_TRUE(parser_.Parse(content)); + task_util::WaitForIdle(); + TASK_UTIL_EXPECT_EQ(1, config_manager_->config()->instances().size()); + TASK_UTIL_EXPECT_EQ(0, config_manager_->NeighborCount("test")); + TASK_UTIL_EXPECT_EQ(0, db_graph_.vertex_count()); +} + TEST_F(BgpIfmapConfigManagerShowTest, ShowInstances1) { string content = FileRead( "controller/src/bgp/testdata/config_test_26a.xml"); @@ -1687,7 +1848,7 @@ TEST_F(BgpIfmapConfigManagerShowTest, ShowBGPaaSPeerings) { for (int idx = 1; idx <= 2; ++idx) { char full_name[1024]; snprintf(full_name, sizeof(full_name), "attr(%s:%s,%s:%s%d)", - "test", "BGPaaS", "test", "vm", idx); + "test", "bgpaas-server", "test", "vm", idx); TASK_UTIL_EXPECT_TRUE(FindPeeringConfig(full_name) != NULL); const BgpIfmapPeeringConfig *config = FindPeeringConfig(full_name); TASK_UTIL_EXPECT_EQ(1, config->size()); diff --git a/src/bgp/test/bgp_server_test_util.cc b/src/bgp/test/bgp_server_test_util.cc index 8fe129e06e2..7e5c2bdbaea 100644 --- a/src/bgp/test/bgp_server_test_util.cc +++ b/src/bgp/test/bgp_server_test_util.cc @@ -297,7 +297,8 @@ void PeerManagerTest::DestroyIPeer(IPeer *ipeer) { // // Server side peer lookup logic. Look into the global map to identify the peer // -BgpPeer *PeerManagerTest::PeerLookup(ip::tcp::endpoint remote_endpoint) { +BgpPeer *PeerManagerTest::PeerLookup( + TcpSession::Endpoint remote_endpoint) const { BgpPeerKey peer_key; bool present; @@ -322,7 +323,7 @@ BgpPeer *PeerManagerTest::PeerLookup(ip::tcp::endpoint remote_endpoint) { "remote_endpoint: " << remote_endpoint); } - PeerByUuidMap::iterator loc = peers_by_uuid_.find(peer_key.uuid); + PeerByUuidMap::const_iterator loc = peers_by_uuid_.find(peer_key.uuid); if (loc == peers_by_uuid_.end()) { return NULL; } diff --git a/src/bgp/test/bgp_server_test_util.h b/src/bgp/test/bgp_server_test_util.h index e3bab6a4d85..f4e4c888311 100644 --- a/src/bgp/test/bgp_server_test_util.h +++ b/src/bgp/test/bgp_server_test_util.h @@ -279,7 +279,7 @@ class PeerManagerTest : public PeerManager { PeerManagerTest(RoutingInstance *instance); virtual BgpPeer *PeerLocate(BgpServer *server, const BgpNeighborConfig *config); - virtual BgpPeer *PeerLookup(boost::asio::ip::tcp::endpoint remote_endpoint); + virtual BgpPeer *PeerLookup(TcpSession::Endpoint remote_endpoint) const; virtual void DestroyIPeer(IPeer *ipeer); private: diff --git a/src/bgp/testdata/config_test_36a.xml b/src/bgp/testdata/config_test_36a.xml index a14ef8fe062..2f03f57e251 100644 --- a/src/bgp/testdata/config_test_36a.xml +++ b/src/bgp/testdata/config_test_36a.xml @@ -7,8 +7,9 @@ target:64512:1 - - 64512 + + bgpaas-server + 64512 inet @@ -33,9 +34,10 @@ + bgpaas-client 65001
10.0.0.1
- + inet @@ -48,9 +50,10 @@
+ bgpaas-client 65002
10.0.0.2
- + inet diff --git a/src/schema/bgp_schema.xsd b/src/schema/bgp_schema.xsd index a56f0361750..7215c7f3488 100644 --- a/src/schema/bgp_schema.xsd +++ b/src/schema/bgp_schema.xsd @@ -69,6 +69,14 @@ + + + + + + + diff --git a/src/schema/vnc_cfg.xsd b/src/schema/vnc_cfg.xsd index e9561dfe34d..8b85fd2752c 100644 --- a/src/schema/vnc_cfg.xsd +++ b/src/schema/vnc_cfg.xsd @@ -1307,14 +1307,6 @@ targetNamespace="http://www.contrailsystems.com/2012/VNC-CONFIG/0"> - - - - - - -