diff --git a/src/bgp/bgp_condition_listener.cc b/src/bgp/bgp_condition_listener.cc index 474ecb35039..2a26a41952c 100644 --- a/src/bgp/bgp_condition_listener.cc +++ b/src/bgp/bgp_condition_listener.cc @@ -295,8 +295,10 @@ void BgpConditionListener::TableWalk(ConditionMatchTableState *ts, if (!ts->walk_ref().get()) { DBTable::DBTableWalkRef walk_ref = ts->table()->AllocWalker( - boost::bind(&BgpConditionListener::BgpRouteNotify, this, server(), _1, _2), - boost::bind(&BgpConditionListener::WalkDone, this, ts, _2)); + boost::bind(&BgpConditionListener::BgpRouteNotify, + this, server(), _1, _2), + boost::bind(&BgpConditionListener::WalkDone, + this, ts, _2)); ts->set_walk_ref(walk_ref); } ts->StoreDoneCb(obj, cb); diff --git a/src/bgp/bgp_config.cc b/src/bgp/bgp_config.cc index 42c688c54e9..930e45e6aaa 100644 --- a/src/bgp/bgp_config.cc +++ b/src/bgp/bgp_config.cc @@ -381,9 +381,9 @@ string RoutingPolicyMatchConfig::ToString() const { return oss.str(); } -static void PutCommunityList(ostringstream &oss, const CommunityList &list) { - copy(list.begin(), list.end(), ostream_iterator(oss, ",")); - oss.seekp(-1, oss.cur); +static void PutCommunityList(ostringstream *oss, const CommunityList &list) { + copy(list.begin(), list.end(), ostream_iterator(*oss, ",")); + oss->seekp(-1, oss->cur); } string RoutingPolicyActionConfig::ToString() const { @@ -391,17 +391,17 @@ string RoutingPolicyActionConfig::ToString() const { oss << "then {" << endl; if (!update.community_set.empty()) { oss << " community set [ "; - PutCommunityList(oss, update.community_set); + PutCommunityList(&oss, update.community_set); oss << " ]" << endl; } if (!update.community_add.empty()) { oss << " community add [ "; - PutCommunityList(oss, update.community_add); + PutCommunityList(&oss, update.community_add); oss << " ]" << endl; } if (!update.community_remove.empty()) { oss << " community remove [ "; - PutCommunityList(oss, update.community_remove); + PutCommunityList(&oss, update.community_remove); oss << " ]" << endl; } if (update.local_pref) { diff --git a/src/bgp/bgp_config_parser.cc b/src/bgp/bgp_config_parser.cc index 1c2576b9e86..c38e8e25aeb 100644 --- a/src/bgp/bgp_config_parser.cc +++ b/src/bgp/bgp_config_parser.cc @@ -21,6 +21,10 @@ #include "schema/bgp_schema_types.h" #include "schema/vnc_cfg_types.h" +using pugi::xml_attribute; +using pugi::xml_document; +using pugi::xml_node; +using pugi::xml_parse_result; using std::auto_ptr; using std::istringstream; using std::list; @@ -33,8 +37,6 @@ using std::set; using std::string; using std::vector; -using namespace pugi; - typedef multimap< pair, pair > SessionMap; diff --git a/src/bgp/bgp_log.cc b/src/bgp/bgp_log.cc index 2f0f19e042a..3f32067efec 100644 --- a/src/bgp/bgp_log.cc +++ b/src/bgp/bgp_log.cc @@ -2,7 +2,10 @@ * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ -#include "bgp_log.h" +#include "bgp/bgp_log.h" + +#include + #include "bgp/bgp_server.h" #include "bgp/routing-instance/routing_instance.h" @@ -77,4 +80,4 @@ void LogServerName(const IPeer *ipeer, const BgpTable *table) { LogServerName(server); } -} +} // namespace bgp_log_test diff --git a/src/bgp/bgp_peer.cc b/src/bgp/bgp_peer.cc index 65fc7e16914..a549aac5438 100644 --- a/src/bgp/bgp_peer.cc +++ b/src/bgp/bgp_peer.cc @@ -62,7 +62,6 @@ class BgpPeer::PeerClose : public IPeerClose { virtual IPeer *peer() const { return peer_; } virtual void Close(bool non_graceful) { - // Abort GR-Closuree if this request is for non-graceful closure. // Reset GR-Closure if previous closure is still in progress or if // this is a flip (from established state). @@ -116,7 +115,6 @@ class BgpPeer::PeerClose : public IPeerClose { } bool IsGRReady() const { - // Check if GR helper mode is disabled. if (!peer_->server()->gr_helper_enable()) return false; @@ -1039,7 +1037,6 @@ void BgpPeer::Close(bool non_graceful) { if (membership_req_pending_ && peer_close_->close_manager()->membership_state() != PeerCloseManager::MEMBERSHIP_IN_USE) { - BGP_LOG_PEER(Event, this, SandeshLevel::SYS_INFO, BGP_LOG_FLAG_ALL, BGP_PEER_DIR_NA, "Close procedure deferred"); defer_close_ = true; @@ -1221,8 +1218,7 @@ const vector BgpPeer::supported_families_ = list_of (Address::RTARGET) (Address::ERMVPN) (Address::INET6) - (Address::INET6VPN) -; + (Address::INET6VPN); void BgpPeer::AddGRCapabilities(BgpProto::OpenMessage::OptParam *opt_param) { vector gr_families; @@ -1602,7 +1598,6 @@ bool BgpPeer::SkipNotificationSend(int code, int subcode) const { void BgpPeer::SendNotification(BgpSession *session, int code, int subcode, const string &data) { - // Check if we can skip sending this notification message. if (peer_close_->IsCloseGraceful() && SkipNotificationSend(code, subcode)) return; diff --git a/src/bgp/bgp_peer.h b/src/bgp/bgp_peer.h index cfbf7d6893d..1c7f342c686 100644 --- a/src/bgp/bgp_peer.h +++ b/src/bgp/bgp_peer.h @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -72,9 +73,9 @@ struct BgpPeerFamilyAttributesCompare { // A BGP peer along with its session and state machine. class BgpPeer : public IPeer { public: - static const int kMinEndOfRibSendTimeUsecs = 10000000; // 10 Seconds - static const int kMaxEndOfRibSendTimeUsecs = 60000000; // 60 Seconds - static const int kEndOfRibSendRetryTimeMsecs = 2000; // 2 Seconds + static const int kMinEndOfRibSendTimeUsecs = 10000000; // 10 Seconds + static const int kMaxEndOfRibSendTimeUsecs = 60000000; // 60 Seconds + static const int kEndOfRibSendRetryTimeMsecs = 2000; // 2 Seconds typedef std::set AddressFamilyList; typedef AuthenticationData::KeyType KeyType; diff --git a/src/bgp/bgp_peer_close.cc b/src/bgp/bgp_peer_close.cc index 0385dfe2c83..a7977ba2cdd 100644 --- a/src/bgp/bgp_peer_close.cc +++ b/src/bgp/bgp_peer_close.cc @@ -6,6 +6,8 @@ #include +#include + #include "base/task_annotations.h" #include "base/timer.h" #include "bgp/bgp_log.h" @@ -13,7 +15,6 @@ #include "bgp/bgp_peer_types.h" #include "bgp/bgp_route.h" #include "bgp/bgp_server.h" -#include "bgp/bgp_server.h" #include "bgp/routing-instance/routing_instance.h" #include "net/community_type.h" @@ -253,7 +254,6 @@ bool PeerCloseManager::RestartTimerCallback() { return false; if (peer_close_->IsReady() && !families_.empty()) { - // Fake reception of all EORs. for (IPeerClose::Families::iterator i = families_.begin(), next = i; i != families_.end(); i = next) { @@ -273,7 +273,6 @@ bool PeerCloseManager::RestartTimerCallback() { // Route stale timer callback. If the peer has come back up, sweep routes for // those address families that are still active. Delete the rest void PeerCloseManager::ProcessClosure() { - // If the peer is back up and this address family is still supported, // sweep old paths which may not have come back in the new session switch (state_) { diff --git a/src/bgp/bgp_peer_close.h b/src/bgp/bgp_peer_close.h index 6c7c04fba31..e7d1d84a838 100644 --- a/src/bgp/bgp_peer_close.h +++ b/src/bgp/bgp_peer_close.h @@ -5,6 +5,8 @@ #ifndef SRC_BGP_BGP_PEER_CLOSE_H_ #define SRC_BGP_BGP_PEER_CLOSE_H_ +#include + #include "base/timer.h" #include "base/util.h" #include "base/queue_task.h" diff --git a/src/bgp/bgp_sandesh.cc b/src/bgp/bgp_sandesh.cc index 8dd02b17c4a..c7112ea75cf 100644 --- a/src/bgp/bgp_sandesh.cc +++ b/src/bgp/bgp_sandesh.cc @@ -237,11 +237,11 @@ class ShowMulticastManagerDetailHandler { static void CombineMulticastPartitionInfo( const RequestPipeline::StageData *sd, - vector &tree_list) { + vector *tree_list) { for (size_t idx = 0; idx < sd->size(); idx++) { const MulticastManagerDetailData &data = static_cast(sd->at(idx)); - tree_list.insert(tree_list.end(), + tree_list->insert(tree_list->end(), data.tree_list.begin(), data.tree_list.end()); } } @@ -254,7 +254,7 @@ class ShowMulticastManagerDetailHandler { static_cast(ps.snhRequest_.get()); const RequestPipeline::StageData *sd = ps.GetStageData(0); vector tree_list; - CombineMulticastPartitionInfo(sd, tree_list); + CombineMulticastPartitionInfo(sd, &tree_list); ShowMulticastManagerDetailResp *resp = new ShowMulticastManagerDetailResp; diff --git a/src/bgp/bgp_xmpp_channel.cc b/src/bgp/bgp_xmpp_channel.cc index 5a603606b35..7e8708f913f 100644 --- a/src/bgp/bgp_xmpp_channel.cc +++ b/src/bgp/bgp_xmpp_channel.cc @@ -1893,7 +1893,6 @@ bool BgpXmppChannel::ResumeClose() { } void BgpXmppChannel::RegisterTable(int line, BgpTable *table, int instance_id) { - // Defer if Membership manager is in use (by close manager). if (peer_close_->close_manager()->membership_state() == PeerCloseManager::MEMBERSHIP_IN_USE) { @@ -1913,7 +1912,6 @@ void BgpXmppChannel::RegisterTable(int line, BgpTable *table, int instance_id) { } void BgpXmppChannel::UnregisterTable(int line, BgpTable *table) { - // Defer if Membership manager is in use (by close manager). if (peer_close_->close_manager()->membership_state() == PeerCloseManager::MEMBERSHIP_IN_USE) { @@ -2152,14 +2150,14 @@ void BgpXmppChannel::FlushDeferQ(string vrf_name) { } } -void BgpXmppChannel::UpdateRouteTargetRouteFlag(SubscriptionState &sub_state, - bool llgr) { +void BgpXmppChannel::UpdateRouteTargetRouteFlag( + const SubscriptionState *sub_state, bool llgr) { RoutingInstanceMgr *instance_mgr = bgp_server_->routing_instance_mgr(); RoutingInstance *master = instance_mgr->GetRoutingInstance(BgpConfigManager::kMasterInstance); assert(master); BgpTable *rtarget_table = master->GetTable(Address::RTARGET); - BOOST_FOREACH(RouteTarget rtarget, sub_state.targets) { + BOOST_FOREACH(RouteTarget rtarget, sub_state->targets) { RTargetPrefix rt_prefix(bgp_server_->local_autonomous_system(), rtarget); const RTargetTable::RequestKey key(rt_prefix, Peer()); @@ -2187,7 +2185,7 @@ void BgpXmppChannel::StaleCurrentSubscriptions() { BOOST_FOREACH(SubscribedRoutingInstanceList::value_type &entry, routing_instances_) { entry.second.SetStale(); - UpdateRouteTargetRouteFlag(entry.second, false); + UpdateRouteTargetRouteFlag(&entry.second, false); } } @@ -2197,7 +2195,7 @@ void BgpXmppChannel::LlgrStaleCurrentSubscriptions() { BOOST_FOREACH(SubscribedRoutingInstanceList::value_type &entry, routing_instances_) { assert(entry.second.IsStale()); - UpdateRouteTargetRouteFlag(entry.second, true); + UpdateRouteTargetRouteFlag(&entry.second, true); } } @@ -2209,7 +2207,7 @@ void BgpXmppChannel::SweepCurrentSubscriptions() { if (i->second.IsStale()) { string name = i->first->name(); - // Incrementor the iterator first as we expect the entry to be + // Increment the iterator first as we expect the entry to be // soon removed. i++; BGP_LOG_PEER(Membership, Peer(), SandeshLevel::SYS_DEBUG, @@ -2226,18 +2224,18 @@ void BgpXmppChannel::SweepCurrentSubscriptions() { // Clear staled subscription state as new subscription has been received. void BgpXmppChannel::ClearStaledSubscription(BgpTable *rtarget_table, RoutingInstance *rt_instance, BgpAttrPtr attr, - SubscriptionState &sub_state) { - if (!sub_state.IsStale()) + SubscriptionState *sub_state) { + if (!sub_state->IsStale()) return; BGP_LOG_PEER(Membership, Peer(), SandeshLevel::SYS_DEBUG, BGP_LOG_FLAG_ALL, BGP_PEER_DIR_NA, "Instance subscription " << rt_instance->name() << " stale flag is cleared"); - sub_state.ClearStale(); + sub_state->ClearStale(); // Update route targets to clear STALE flag. - BOOST_FOREACH(RouteTarget rtarget, sub_state.targets) { + BOOST_FOREACH(RouteTarget rtarget, sub_state->targets) { PublishedRTargetRoutes::iterator rt_loc = rtarget_routes_.find(rtarget); assert(rt_loc != rtarget_routes_.end()); @@ -2275,11 +2273,11 @@ void BgpXmppChannel::PublishRTargetRoute(RoutingInstance *rt_instance, (rt_instance, state)); it = ret.first; - // During GR, we expect duplicate subscription requests. Clear the stale + // During GR, we expect duplicate subscription requests. Clear stale // state, as agent did re-subscribe after restart. if (!ret.second) { ClearStaledSubscription(rtarget_table, rt_instance, attr, - (*(ret.first)).second); + &it->second); return; } } else { @@ -2598,7 +2596,6 @@ BgpXmppChannelManager::BgpXmppChannelManager(XmppServer *xmpp_server, id_(-1), asn_listener_id_(-1), identifier_listener_id_(-1) { - // Initialize the gen id counter subscription_gen_id_ = 1; deleting_count_ = 0; diff --git a/src/bgp/bgp_xmpp_channel.h b/src/bgp/bgp_xmpp_channel.h index 91bc7d36d2e..1c772126efb 100644 --- a/src/bgp/bgp_xmpp_channel.h +++ b/src/bgp/bgp_xmpp_channel.h @@ -241,8 +241,9 @@ class BgpXmppChannel { int instance_id); void ClearStaledSubscription(BgpTable *rtarget_table, RoutingInstance *rt_instance, BgpAttrPtr attr, - SubscriptionState &sub_state); - void UpdateRouteTargetRouteFlag(SubscriptionState &sub_state, bool llgr); + SubscriptionState *sub_state); + void UpdateRouteTargetRouteFlag(const SubscriptionState *sub_state, + bool llgr); const BgpXmppChannelManager *manager() const { return manager_; } bool ProcessMembershipResponse(std::string table_name, RoutingTableMembershipRequestMap::iterator loc); diff --git a/src/bgp/state_machine.cc b/src/bgp/state_machine.cc index 833db6881d6..0463354d748 100644 --- a/src/bgp/state_machine.cc +++ b/src/bgp/state_machine.cc @@ -1364,15 +1364,8 @@ void StateMachine::SendNotificationAndClose(BgpSession *session, int code, set_idle_hold_time(idle_hold_time() ? idle_hold_time() : kIdleHoldTime); reset_hold_time(); - if (!code || peer_->SkipNotificationReceive(code, subcode)) { - - // Trigger graceful closure. - peer_->Close(false); - } else { - - // Trigger non-graceful closure. - peer_->Close(true); - } + bool non_graceful = code && !peer_->SkipNotificationReceive(code, subcode); + peer_->Close(non_graceful); } // @@ -1708,7 +1701,7 @@ int StateMachine::GetConfiguredHoldTime() const { return kHoldTime; } -void StateMachine::BGPPeerInfoSend(BgpPeerInfoData &peer_info) { +void StateMachine::BGPPeerInfoSend(const BgpPeerInfoData &peer_info) { BGPPeerInfo::Send(peer_info); } diff --git a/src/bgp/state_machine.h b/src/bgp/state_machine.h index d3a82332929..3676bce5000 100644 --- a/src/bgp/state_machine.h +++ b/src/bgp/state_machine.h @@ -205,7 +205,7 @@ class StateMachine : public sc::state_machine { void TimerErrorHanlder(std::string name, std::string error) { } void DeleteAllTimers(); - void BGPPeerInfoSend(BgpPeerInfoData &peer_info); + void BGPPeerInfoSend(const BgpPeerInfoData &peer_info); template bool Enqueue(const Ev &event); bool DequeueEvent(EventContainer ec); diff --git a/src/bgp/xmpp_message_builder.cc b/src/bgp/xmpp_message_builder.cc index d835f2608eb..14501421124 100644 --- a/src/bgp/xmpp_message_builder.cc +++ b/src/bgp/xmpp_message_builder.cc @@ -58,7 +58,7 @@ class BgpXmppMessage : public Message { class XmlWriter : public pugi::xml_writer { public: - XmlWriter(string *repr) : repr_(repr) { } + explicit XmlWriter(string *repr) : repr_(repr) { } virtual void write(const void *data, size_t size) { repr_->append(static_cast(data), size); }