diff --git a/src/bgp/bgp_attr.cc b/src/bgp/bgp_attr.cc index 821ba83312e..35d16cb7b84 100644 --- a/src/bgp/bgp_attr.cc +++ b/src/bgp/bgp_attr.cc @@ -154,8 +154,8 @@ void ClusterListSpec::ToCanonical(BgpAttr *attr) { std::string ClusterListSpec::ToString() const { std::stringstream repr; - repr << "CLUSTER_LIST :"; + repr << "CLUSTER_LIST :"; for (std::vector::const_iterator iter = cluster_list.begin(); iter != cluster_list.end(); ++iter) { repr << " " << Ip4Address(*iter).to_string(); diff --git a/src/bgp/bgp_common.h b/src/bgp/bgp_common.h index b029edf3b92..f30ffb3bd03 100644 --- a/src/bgp/bgp_common.h +++ b/src/bgp/bgp_common.h @@ -2,11 +2,16 @@ * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ -#ifndef ctrlplane_bgp_common_h -#define ctrlplane_bgp_common_h +#ifndef SRC_BGP_BGP_COMMON_H_ +#define SRC_BGP_BGP_COMMON_H_ + +#include + #include +#include +#include #include -#include + typedef uint16_t as_t; typedef uint32_t as4_t; @@ -14,8 +19,8 @@ class RoutingPolicy; typedef boost::intrusive_ptr RoutingPolicyPtr; // -// Generic datastructure for configured list of routing policies with -// ordering info +// Generic data structure for configured list of routing policies with +// ordering info. // struct RoutingPolicyAttachInfo { std::string sequence_; @@ -25,10 +30,10 @@ struct RoutingPolicyAttachInfo { typedef std::vector RoutingPolicyConfigList; // -// Generic datastructure for policy attachment -// It is a list of Routing Policy pointer + Generation of routing policy +// Generic data structure for policy attachment. +// It is a list of Routing Policy pointer + Generation of routing policy. // typedef std::pair RoutingPolicyInfo; typedef std::list RoutingPolicyAttachList; -#endif +#endif // SRC_BGP_BGP_COMMON_H_ diff --git a/src/bgp/bgp_condition_listener.h b/src/bgp/bgp_condition_listener.h index ad6a6709a65..a841c02d5dd 100644 --- a/src/bgp/bgp_condition_listener.h +++ b/src/bgp/bgp_condition_listener.h @@ -11,6 +11,7 @@ #include #include +#include #include "base/util.h" diff --git a/src/bgp/bgp_config.cc b/src/bgp/bgp_config.cc index b9a1ed6ff1a..91756ebd885 100644 --- a/src/bgp/bgp_config.cc +++ b/src/bgp/bgp_config.cc @@ -12,9 +12,12 @@ #include "base/util.h" using std::copy; -using std::string; +using std::endl; using std::ostringstream; using std::ostream_iterator; +using std::string; +using std::swap; +using std::vector; const char *BgpConfigManager::kMasterInstance = "default-domain:default-project:ip-fabric:__default__"; @@ -104,7 +107,7 @@ void AuthenticationData::Clear() { key_chain_.clear(); } -std::string AuthenticationData::KeyTypeToString() const { +string AuthenticationData::KeyTypeToString() const { switch (key_type_) { case MD5: return "MD5"; @@ -113,7 +116,7 @@ std::string AuthenticationData::KeyTypeToString() const { } } -std::string AuthenticationData::KeyTypeToString(KeyType key_type) { +string AuthenticationData::KeyTypeToString(KeyType key_type) { switch (key_type) { case MD5: return "MD5"; @@ -122,9 +125,9 @@ std::string AuthenticationData::KeyTypeToString(KeyType key_type) { } } -std::vector AuthenticationData::KeysToString() const { +vector AuthenticationData::KeysToString() const { AuthenticationKeyChain::const_iterator iter; - std::vector auth_keys; + vector auth_keys; for (iter = key_chain_.begin(); iter != key_chain_.end(); ++iter) { AuthenticationKey key = *iter; auth_keys.push_back(integerToString(key.id)); @@ -133,9 +136,9 @@ std::vector AuthenticationData::KeysToString() const { } // NOTE: This prints the actual key too. Use with care. -std::vector AuthenticationData::KeysToStringDetail() const { +vector AuthenticationData::KeysToStringDetail() const { AuthenticationKeyChain::const_iterator iter; - std::vector auth_keys; + vector auth_keys; for (iter = key_chain_.begin(); iter != key_chain_.end(); ++iter) { AuthenticationKey key = *iter; auth_keys.push_back(integerToString(key.id) + ":" + key.value); @@ -200,8 +203,8 @@ int BgpNeighborConfig::CompareTo(const BgpNeighborConfig &rhs) const { BgpFamilyAttributesConfigCompare()); } -BgpNeighborConfig::AddressFamilyList BgpNeighborConfig::GetAddressFamilies( - ) const { +BgpNeighborConfig::AddressFamilyList +BgpNeighborConfig::GetAddressFamilies() const { BgpNeighborConfig::AddressFamilyList family_list; BOOST_FOREACH(const BgpFamilyAttributesConfig family_config, family_attributes_list_) { @@ -210,24 +213,24 @@ BgpNeighborConfig::AddressFamilyList BgpNeighborConfig::GetAddressFamilies( return family_list; } -std::string BgpNeighborConfig::AuthKeyTypeToString() const { +string BgpNeighborConfig::AuthKeyTypeToString() const { return auth_data_.KeyTypeToString(); } // Return the key's id concatenated with its type. -std::vector BgpNeighborConfig::AuthKeysToString() const { +vector BgpNeighborConfig::AuthKeysToString() const { return auth_data_.KeysToString(); } -BgpProtocolConfig::BgpProtocolConfig(const std::string &instance_name) - : instance_name_(instance_name), - admin_down_(false), - autonomous_system_(0), - local_autonomous_system_(0), - identifier_(0), - port_(0), - hold_time_(0), - last_change_at_(UTCTimestampUsec()) { +BgpProtocolConfig::BgpProtocolConfig(const string &instance_name) + : instance_name_(instance_name), + admin_down_(false), + autonomous_system_(0), + local_autonomous_system_(0), + identifier_(0), + port_(0), + hold_time_(0), + last_change_at_(UTCTimestampUsec()) { } int BgpProtocolConfig::CompareTo(const BgpProtocolConfig &rhs) const { @@ -240,13 +243,13 @@ int BgpProtocolConfig::CompareTo(const BgpProtocolConfig &rhs) const { return 0; } -BgpInstanceConfig::BgpInstanceConfig(const std::string &name) - : name_(name), - has_pnf_(false), - virtual_network_index_(0), - virtual_network_allow_transit_(false), - vxlan_id_(0), - last_change_at_(UTCTimestampUsec()) { +BgpInstanceConfig::BgpInstanceConfig(const string &name) + : name_(name), + has_pnf_(false), + virtual_network_index_(0), + virtual_network_allow_transit_(false), + vxlan_id_(0), + last_change_at_(UTCTimestampUsec()) { } BgpInstanceConfig::~BgpInstanceConfig() { @@ -279,9 +282,9 @@ void BgpInstanceConfig::swap_static_routes(Address::Family family, StaticRouteList *list) { assert(family == Address::INET || family == Address::INET6); if (family == Address::INET) { - std::swap(inet_static_routes_, *list); + swap(inet_static_routes_, *list); } else { - std::swap(inet6_static_routes_, *list); + swap(inet6_static_routes_, *list); } } @@ -295,8 +298,8 @@ const ServiceChainConfig *BgpInstanceConfig::service_chain_info( return NULL; } -const BgpInstanceConfig::AggregateRouteList &BgpInstanceConfig::aggregate_routes( - Address::Family family) const { +const BgpInstanceConfig::AggregateRouteList & +BgpInstanceConfig::aggregate_routes(Address::Family family) const { assert(family == Address::INET || family == Address::INET6); if (family == Address::INET) { return inet_aggregate_routes_; @@ -309,13 +312,13 @@ void BgpInstanceConfig::swap_aggregate_routes(Address::Family family, AggregateRouteList *list) { assert(family == Address::INET || family == Address::INET6); if (family == Address::INET) { - std::swap(inet_aggregate_routes_, *list); + swap(inet_aggregate_routes_, *list); } else { - std::swap(inet6_aggregate_routes_, *list); + swap(inet6_aggregate_routes_, *list); } } -BgpRoutingPolicyConfig::BgpRoutingPolicyConfig(const std::string &name) +BgpRoutingPolicyConfig::BgpRoutingPolicyConfig(const string &name) : name_(name), last_change_at_(UTCTimestampUsec()) { } @@ -327,9 +330,9 @@ void BgpRoutingPolicyConfig::Clear() { terms_.clear(); } -std::string RoutingPolicyMatchConfig::ToString() const { +string RoutingPolicyMatchConfig::ToString() const { ostringstream oss; - oss << "from {" << std::endl; + oss << "from {" << endl; if (!protocols_match.empty()) { oss << " protocol [ "; BOOST_FOREACH(const string &protocol, protocols_match) { @@ -339,56 +342,56 @@ std::string RoutingPolicyMatchConfig::ToString() const { oss << " ]"; } if (!community_match.empty()) { - oss << " community " << community_match << std::endl; + oss << " community " << community_match << endl; } if (!prefixes_to_match.empty()) { BOOST_FOREACH(const PrefixMatchConfig &match, prefixes_to_match) { oss << " prefix " << match.prefix_to_match << " " - << match.prefix_match_type << std::endl; + << match.prefix_match_type << endl; } } - oss << "}" << std::endl; + oss << "}" << endl; return oss.str(); } static void PutCommunityList(ostringstream &oss, const CommunityList &list) { - copy(list.begin(), list.end(), ostream_iterator(oss,",")); + copy(list.begin(), list.end(), ostream_iterator(oss, ",")); oss.seekp(-1, oss.cur); } string RoutingPolicyActionConfig::ToString() const { ostringstream oss; - oss << "then {" << std::endl; + oss << "then {" << endl; if (!update.community_set.empty()) { oss << " community set [ "; PutCommunityList(oss, update.community_set); - oss << " ]" << std::endl; + oss << " ]" << endl; } if (!update.community_add.empty()) { oss << " community add [ "; PutCommunityList(oss, update.community_add); - oss << " ]" << std::endl; + oss << " ]" << endl; } if (!update.community_remove.empty()) { oss << " community remove [ "; PutCommunityList(oss, update.community_remove); - oss << " ]" << std::endl; + oss << " ]" << endl; } if (update.local_pref) { - oss << " local-preference " << update.local_pref << std::endl; + oss << " local-preference " << update.local_pref << endl; } if (update.med) { - oss << " med " << update.med << std::endl; + oss << " med " << update.med << endl; } if (action == ACCEPT) { - oss << " accept" << std::endl; + oss << " accept" << endl; } else if (action == REJECT) { - oss << " reject" << std::endl; + oss << " reject" << endl; } else if (action == NEXT_TERM) { - oss << " next-term" << std::endl; + oss << " next-term" << endl; } - oss << "}" << std::endl; + oss << "}" << endl; return oss.str(); } diff --git a/src/bgp/bgp_config.h b/src/bgp/bgp_config.h index f67cb09cfd8..952b8ca4a82 100644 --- a/src/bgp/bgp_config.h +++ b/src/bgp/bgp_config.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. */ -#ifndef BGP_BGP_CONFIG_H__ -#define BGP_BGP_CONFIG_H__ +#ifndef SRC_BGP_BGP_CONFIG_H__ +#define SRC_BGP_BGP_CONFIG_H__ #include #include @@ -85,7 +85,7 @@ class AuthenticationData { // Per address family configuration for a BGP neighbor. // struct BgpFamilyAttributesConfig { - BgpFamilyAttributesConfig(const std::string &family) + explicit BgpFamilyAttributesConfig(const std::string &family) : family(family), loop_count(0), prefix_limit(0) { } @@ -547,7 +547,7 @@ class BgpConfigManager { static const int kDefaultPort; static const uint32_t kDefaultAutonomousSystem; - BgpConfigManager(BgpServer *server); + explicit BgpConfigManager(BgpServer *server); virtual ~BgpConfigManager(); void RegisterObservers(const Observers &obs) { obs_ = obs; } @@ -586,4 +586,4 @@ class BgpConfigManager { DISALLOW_COPY_AND_ASSIGN(BgpConfigManager); }; -#endif // BGP_BGP_CONFIG_H__ +#endif // SRC_BGP_BGP_CONFIG_H__ diff --git a/src/bgp/bgp_config_ifmap.cc b/src/bgp/bgp_config_ifmap.cc index 1ba839e17e9..5a3920d9889 100644 --- a/src/bgp/bgp_config_ifmap.cc +++ b/src/bgp/bgp_config_ifmap.cc @@ -6,6 +6,8 @@ #include +#include + #include "base/string_util.h" #include "base/task_annotations.h" #include "bgp/bgp_common.h" @@ -17,11 +19,16 @@ #include "schema/bgp_schema_types.h" #include "schema/vnc_cfg_types.h" -using namespace std; +using std::auto_ptr; +using std::make_pair; +using std::pair; +using std::set; +using std::sort; +using std::string; +using std::vector; using boost::iequals; const int BgpIfmapConfigManager::kConfigTaskInstanceId = 0; -int BgpIfmapConfigManager::config_task_id_ = -1; static BgpNeighborConfig::AddressFamilyList default_addr_family_list; @@ -47,13 +54,13 @@ static uint32_t IpAddressToBgpIdentifier(const IpAddress &address) { return htonl(address.to_v4().to_ulong()); } -static std::string BgpIdentifierToString(uint32_t identifier) { +static string BgpIdentifierToString(uint32_t identifier) { Ip4Address addr(ntohl(identifier)); return addr.to_string(); } BgpIfmapPeeringConfig::BgpIfmapPeeringConfig(BgpIfmapInstanceConfig *instance) - : instance_(instance) { + : instance_(instance) { } BgpIfmapPeeringConfig::~BgpIfmapPeeringConfig() { @@ -68,7 +75,7 @@ void BgpIfmapPeeringConfig::SetNodeProxy(IFMapNodeProxy *proxy) { } BgpIfmapRoutingPolicyLinkConfig::BgpIfmapRoutingPolicyLinkConfig( - BgpIfmapInstanceConfig *rti, BgpIfmapRoutingPolicyConfig *rtp) : + BgpIfmapInstanceConfig *rti, BgpIfmapRoutingPolicyConfig *rtp) : instance_(rti), policy_(rtp) { } @@ -82,8 +89,8 @@ void BgpIfmapRoutingPolicyLinkConfig::SetNodeProxy(IFMapNodeProxy *proxy) { } } -bool BgpIfmapRoutingPolicyLinkConfig::GetRoutingInstanceRoutingPolicyPair( - DBGraph *graph, IFMapNode *node, pair *pair) { +bool BgpIfmapRoutingPolicyLinkConfig::GetInstancePolicyPair( + DBGraph *graph, IFMapNode *node, pair *pair) { IFMapNode *routing_instance = NULL; IFMapNode *routing_policy = NULL; @@ -105,7 +112,7 @@ bool BgpIfmapRoutingPolicyLinkConfig::GetRoutingInstanceRoutingPolicyPair( } void BgpIfmapRoutingPolicyLinkConfig::Update(BgpIfmapConfigManager *manager, - const autogen::RoutingPolicyRoutingInstance *ri_rp) { + const autogen::RoutingPolicyRoutingInstance *ri_rp) { ri_rp_link_.reset(ri_rp); } @@ -113,7 +120,7 @@ void BgpIfmapRoutingPolicyLinkConfig::Delete(BgpIfmapConfigManager *manager) { ri_rp_link_.reset(); } -static AuthenticationData::KeyType KeyChainType(const std::string &value) { +static AuthenticationData::KeyType KeyChainType(const string &value) { // Case-insensitive comparison if (boost::iequals(value, "md5")) { return AuthenticationData::MD5; @@ -122,12 +129,12 @@ static AuthenticationData::KeyType KeyChainType(const std::string &value) { } static void BuildKeyChain(BgpNeighborConfig *neighbor, - const autogen::AuthenticationData &values) { + const autogen::AuthenticationData &values) { AuthenticationData keydata; keydata.set_key_type(KeyChainType(values.key_type)); AuthenticationKey key; - for (std::vector::const_iterator iter = + for (vector::const_iterator iter = values.key_items.begin(); iter != values.key_items.end(); ++iter) { key.id = iter->key_id; key.value = iter->key; @@ -227,7 +234,7 @@ static void NeighborSetSessionAttributes( } } - // TODO: local should override rather than replace common. + // TODO(nsheth): local should override rather than replace common. const autogen::BgpSessionAttributes *attributes = NULL; if (common != NULL) { attributes = common; @@ -353,10 +360,9 @@ static BgpNeighborConfig *MakeBgpNeighborConfig( // Build map of BgpNeighborConfigs based on the data in autogen::BgpPeering. // void BgpIfmapPeeringConfig::BuildNeighbors(BgpIfmapConfigManager *manager, - const autogen::BgpRouter *local_rt_config, - const string &peername, const autogen::BgpRouter *remote_rt_config, - const autogen::BgpPeering *peering, NeighborMap *map) { - + const autogen::BgpRouter *local_rt_config, + const string &peername, const autogen::BgpRouter *remote_rt_config, + const autogen::BgpPeering *peering, NeighborMap *map) { const BgpIfmapInstanceConfig *master_instance = manager->config()->FindInstance(BgpConfigManager::kMasterInstance); @@ -390,7 +396,7 @@ void BgpIfmapPeeringConfig::BuildNeighbors(BgpIfmapConfigManager *manager, // part of the process. // void BgpIfmapPeeringConfig::Update(BgpIfmapConfigManager *manager, - const autogen::BgpPeering *peering) { + const autogen::BgpPeering *peering) { IFMapNode *node = node_proxy_.node(); assert(node != NULL); bgp_peering_.reset(peering); @@ -497,8 +503,8 @@ void BgpIfmapPeeringConfig::Delete(BgpIfmapConfigManager *manager) { // we return true. // bool BgpIfmapPeeringConfig::GetRouterPair(DBGraph *db_graph, - const string &localname, IFMapNode *node, - pair *pair) { + const string &localname, IFMapNode *node, + pair *pair) { IFMapNode *local = NULL; IFMapNode *remote = NULL; string local_router_type; @@ -557,8 +563,8 @@ bool BgpIfmapPeeringConfig::GetRouterPair(DBGraph *db_graph, // Constructor for BgpIfmapProtocolConfig. // BgpIfmapProtocolConfig::BgpIfmapProtocolConfig(BgpIfmapInstanceConfig *instance) - : instance_(instance), - data_(instance->name()) { + : instance_(instance), + data_(instance->name()) { } // @@ -584,7 +590,7 @@ void BgpIfmapProtocolConfig::SetNodeProxy(IFMapNodeProxy *proxy) { // Update autogen::BgpRouter object for this BgpIfmapProtocolConfig. // void BgpIfmapProtocolConfig::Update(BgpIfmapConfigManager *manager, - const autogen::BgpRouter *router) { + const autogen::BgpRouter *router) { bgp_router_.reset(router); const autogen::BgpRouterParams ¶ms = router->parameters(); data_.set_admin_down(params.admin_down); @@ -660,7 +666,7 @@ void BgpIfmapInstanceConfig::ResetProtocol() { // Return true and fill in the target string if we find the route-target. // static bool GetInstanceTargetRouteTarget(DBGraph *graph, IFMapNode *node, - string *target) { + string *target) { for (DBGraphVertex::adjacency_iterator iter = node->begin(graph); iter != node->end(graph); ++iter) { IFMapNode *adj = static_cast(iter.operator->()); @@ -683,7 +689,7 @@ static bool GetInstanceTargetRouteTarget(DBGraph *graph, IFMapNode *node, // and hence should not be imported based on policy. // static void GetRoutingInstanceExportTargets(DBGraph *graph, IFMapNode *node, - vector *target_list) { + vector *target_list) { for (DBGraphVertex::adjacency_iterator iter = node->begin(graph); iter != node->end(graph); ++iter) { IFMapNode *adj = static_cast(iter.operator->()); @@ -713,8 +719,8 @@ static void GetRoutingInstanceExportTargets(DBGraph *graph, IFMapNode *node, // connection means. // static void GetConnectionExportTargets(DBGraph *graph, IFMapNode *src_node, - const string &src_instance, IFMapNode *node, - vector *target_list) { + const string &src_instance, IFMapNode *node, + vector *target_list) { const autogen::Connection *conn = dynamic_cast(node->GetObject()); if (!conn) @@ -740,8 +746,8 @@ static void GetConnectionExportTargets(DBGraph *graph, IFMapNode *src_node, // graph edges and look for routing-policy adjacency // static bool GetRoutingInstanceRoutingPolicy(DBGraph *graph, IFMapNode *node, - RoutingPolicyAttachInfo *ri_rp_link) { - std::string sequence; + RoutingPolicyAttachInfo *ri_rp_link) { + string sequence; const autogen::RoutingPolicyRoutingInstance *policy = static_cast(node->GetObject()); const autogen::RoutingPolicyType &attach_info = policy->data(); @@ -763,8 +769,8 @@ static bool GetRoutingInstanceRoutingPolicy(DBGraph *graph, IFMapNode *node, // Fill in all the route-aggregation for a routing-instance. // static bool GetRouteAggregateConfig(DBGraph *graph, IFMapNode *node, - BgpInstanceConfig::AggregateRouteList *inet_list, - BgpInstanceConfig::AggregateRouteList *inet6_list) { + BgpInstanceConfig::AggregateRouteList *inet_list, + BgpInstanceConfig::AggregateRouteList *inet6_list) { const autogen::RouteAggregate *ra = static_cast(node->GetObject()); if (ra == NULL) return false; @@ -774,7 +780,7 @@ static bool GetRouteAggregateConfig(DBGraph *graph, IFMapNode *node, IpAddress::from_string(ra->aggregate_route_nexthop(), ec); if (ec != 0) return false; - BOOST_FOREACH(const std::string &route, ra->aggregate_route_entries()) { + BOOST_FOREACH(const string &route, ra->aggregate_route_entries()) { AggregateRouteConfig aggregate; aggregate.nexthop = nexthop; @@ -844,7 +850,7 @@ static int GetVirtualNetworkVxlanId(DBGraph *graph, IFMapNode *node) { } static void SetStaticRouteConfig(BgpInstanceConfig *rti, - const autogen::RoutingInstance *config) { + const autogen::RoutingInstance *config) { BgpInstanceConfig::StaticRouteList inet_list; BgpInstanceConfig::StaticRouteList inet6_list; BOOST_FOREACH(const autogen::StaticRouteType &route, @@ -877,10 +883,8 @@ static void SetStaticRouteConfig(BgpInstanceConfig *rti, } static void SetServiceChainConfig(BgpInstanceConfig *rti, - const autogen::RoutingInstance *config) { - + const autogen::RoutingInstance *config) { BgpInstanceConfig::ServiceChainList list; - const autogen::ServiceChainInfo &inet_chain = config->service_chain_information(); if (config->IsPropertySet( @@ -914,7 +918,8 @@ static void SetServiceChainConfig(BgpInstanceConfig *rti, rti->swap_service_chain_list(&list); } -void BgpIfmapConfigManager::ProcessRoutingPolicyLink(const BgpConfigDelta &delta) { +void BgpIfmapConfigManager::ProcessRoutingPolicyLink( + const BgpConfigDelta &delta) { CHECK_CONCURRENCY("bgp::Config"); BgpIfmapRoutingPolicyLinkConfig *ri_rp_link @@ -930,13 +935,13 @@ void BgpIfmapConfigManager::ProcessRoutingPolicyLink(const BgpConfigDelta &delta } pair ri_rp_pair; - if (!BgpIfmapRoutingPolicyLinkConfig::GetRoutingInstanceRoutingPolicyPair( - db_graph_, node, &ri_rp_pair)) { + if (!BgpIfmapRoutingPolicyLinkConfig::GetInstancePolicyPair(db_graph_, + node, &ri_rp_pair)) { return; } - std::string instance_name = ri_rp_pair.first->name(); - std::string policy_name = ri_rp_pair.second->name(); + string instance_name = ri_rp_pair.first->name(); + string policy_name = ri_rp_pair.second->name(); BgpIfmapInstanceConfig *rti = config_->FindInstance(instance_name); @@ -967,7 +972,7 @@ void BgpIfmapConfigManager::ProcessRoutingPolicyLink(const BgpConfigDelta &delta } autogen::RoutingPolicyRoutingInstance *ri_rp_link_cfg = - static_cast(delta.obj.get()); + static_cast(delta.obj.get()); ri_rp_link->Update(this, ri_rp_link_cfg); } @@ -976,6 +981,7 @@ static bool CompareRoutingPolicyOrder(const RoutingPolicyAttachInfo &lhs, const RoutingPolicyAttachInfo &rhs) { return (lhs.sequence_ < rhs.sequence_); } + // // Update BgpIfmapInstanceConfig based on a new autogen::RoutingInstance object. // @@ -990,7 +996,7 @@ static bool CompareRoutingPolicyOrder(const RoutingPolicyAttachInfo &lhs, // are added to our import list. // void BgpIfmapInstanceConfig::Update(BgpIfmapConfigManager *manager, - const autogen::RoutingInstance *config) { + const autogen::RoutingInstance *config) { BgpInstanceConfig::RouteTargetList import_list, export_list; BgpInstanceConfig::AggregateRouteList inet6_aggregate_list; BgpInstanceConfig::AggregateRouteList inet_aggregate_list; @@ -1046,7 +1052,7 @@ void BgpIfmapInstanceConfig::Update(BgpIfmapConfigManager *manager, data_.set_import_list(import_list); data_.set_export_list(export_list); - std::sort(policy_list.begin(), policy_list.end(), CompareRoutingPolicyOrder); + sort(policy_list.begin(), policy_list.end(), CompareRoutingPolicyOrder); data_.swap_routing_policy_list(&policy_list); data_.swap_aggregate_routes(Address::INET, &inet_aggregate_list); data_.swap_aggregate_routes(Address::INET6, &inet6_aggregate_list); @@ -1066,8 +1072,8 @@ void BgpIfmapInstanceConfig::ResetConfig() { } // -// Return true if the BgpIfmapInstanceConfig is ready to be deleted. The caller is -// responsible for actually deleting it. +// Return true if the BgpIfmapInstanceConfig is ready to be deleted. The +// caller is responsible for actually deleting it. // bool BgpIfmapInstanceConfig::DeleteIfEmpty(BgpConfigManager *manager) { if (name_ == BgpConfigManager::kMasterInstance) { @@ -1092,7 +1098,7 @@ bool BgpIfmapInstanceConfig::DeleteIfEmpty(BgpConfigManager *manager) { // is notified. // void BgpIfmapInstanceConfig::AddNeighbor(BgpConfigManager *manager, - BgpNeighborConfig *neighbor) { + BgpNeighborConfig *neighbor) { BGP_CONFIG_LOG_NEIGHBOR( Create, manager->server(), neighbor, SandeshLevel::SYS_DEBUG, BGP_LOG_FLAG_ALL, @@ -1111,7 +1117,7 @@ void BgpIfmapInstanceConfig::AddNeighbor(BgpConfigManager *manager, // Change a BgpNeighborConfig that's already in this BgpIfmapInstanceConfig. // void BgpIfmapInstanceConfig::ChangeNeighbor(BgpConfigManager *manager, - BgpNeighborConfig *neighbor) { + BgpNeighborConfig *neighbor) { NeighborMap::iterator loc = neighbors_.find(neighbor->name()); assert(loc != neighbors_.end()); loc->second = neighbor; @@ -1137,7 +1143,7 @@ void BgpIfmapInstanceConfig::ChangeNeighbor(BgpConfigManager *manager, // BgpNeighborConfig object. // void BgpIfmapInstanceConfig::DeleteNeighbor(BgpConfigManager *manager, - BgpNeighborConfig *neighbor) { + BgpNeighborConfig *neighbor) { BGP_CONFIG_LOG_NEIGHBOR(Delete, manager->server(), neighbor, SandeshLevel::SYS_DEBUG, BGP_LOG_FLAG_ALL); manager->Notify(neighbor, BgpConfigManager::CFG_DELETE); @@ -1180,14 +1186,16 @@ void BgpIfmapInstanceConfig::DeletePeering(BgpIfmapPeeringConfig *peering) { // // Add a BgpIfmapRoutingPolicyConfig to this BgpIfmapInstanceConfig. // -void BgpIfmapInstanceConfig::AddRoutingPolicy(BgpIfmapRoutingPolicyConfig *rtp) { +void BgpIfmapInstanceConfig::AddRoutingPolicy( + BgpIfmapRoutingPolicyConfig *rtp) { routing_policies_.insert(make_pair(rtp->name(), rtp)); } // // Delete a BgpIfmapRoutingPolicyConfig from this BgpIfmapInstanceConfig. // -void BgpIfmapInstanceConfig::DeleteRoutingPolicy(BgpIfmapRoutingPolicyConfig *rtp) { +void BgpIfmapInstanceConfig::DeleteRoutingPolicy( + BgpIfmapRoutingPolicyConfig *rtp) { routing_policies_.erase(rtp->name()); } @@ -1276,19 +1284,18 @@ BgpIfmapInstanceConfig::NeighborMapItems() const { // // Create a new BgpIfmapRoutingPolicyLinkConfig. // -// The IFMapNodeProxy is a proxy for the IFMapNode which is the -// midnode that represents the routing-policy-routing-instance. The newly created +// The IFMapNodeProxy is a proxy for the IFMapNode which is the midnode that +// represents the routing-policy-routing-instance. The newly created // BgpIfmapRoutingPolicyLinkConfig gets added to the IfmapRoutingPolicyLinkMap. // -BgpIfmapRoutingPolicyLinkConfig * -BgpIfmapConfigData::CreateRoutingPolicyLink(BgpIfmapInstanceConfig *rti, - BgpIfmapRoutingPolicyConfig *rtp, - IFMapNodeProxy *proxy) { +BgpIfmapRoutingPolicyLinkConfig *BgpIfmapConfigData::CreateRoutingPolicyLink( + BgpIfmapInstanceConfig *rti, BgpIfmapRoutingPolicyConfig *rtp, + IFMapNodeProxy *proxy) { BgpIfmapRoutingPolicyLinkConfig *ri_rp_link = new BgpIfmapRoutingPolicyLinkConfig(rti, rtp); ri_rp_link->SetNodeProxy(proxy); pair result = - ri_rp_links_.insert(make_pair(ri_rp_link->node()->name(), ri_rp_link)); + ri_rp_links_.insert(make_pair(ri_rp_link->node()->name(), ri_rp_link)); assert(result.second); ri_rp_link->instance()->AddRoutingPolicy(rtp); ri_rp_link->policy()->AddInstance(rti); @@ -1298,13 +1305,13 @@ BgpIfmapConfigData::CreateRoutingPolicyLink(BgpIfmapInstanceConfig *rti, // // Delete a BgpIfmapRoutingPolicyLinkConfig. // -// The BgpIfmapRoutingPolicyLinkConfig is removed from the -// IfmapRoutingPolicyLinkMap and then deleted. -// Note that the reference to the IFMapNode for the routing-policy-routing-instance +// The BgpIfmapRoutingPolicyLinkConfig is erased from IfmapRoutingPolicyLinkMap +// and then deleted. +// Note that the reference to the IFMapNode for routing-policy-routing-instance // gets released via the destructor when the IFMapNodeProxy is destroyed. // -void BgpIfmapConfigData::DeleteRoutingPolicyLink(BgpIfmapRoutingPolicyLinkConfig - *ri_rp_link) { +void BgpIfmapConfigData::DeleteRoutingPolicyLink( + BgpIfmapRoutingPolicyLinkConfig *ri_rp_link) { ri_rp_links_.erase(ri_rp_link->node()->name()); ri_rp_link->instance()->DeleteRoutingPolicy(ri_rp_link->policy()); ri_rp_link->policy()->RemoveInstance(ri_rp_link->instance()); @@ -1314,8 +1321,8 @@ void BgpIfmapConfigData::DeleteRoutingPolicyLink(BgpIfmapRoutingPolicyLinkConfig // // Find the BgpIfmapRoutingPolicyLinkConfig by name. // -BgpIfmapRoutingPolicyLinkConfig * -BgpIfmapConfigData::FindRoutingPolicyLink(const string &name) { +BgpIfmapRoutingPolicyLinkConfig *BgpIfmapConfigData::FindRoutingPolicyLink( + const string &name) { IfmapRoutingPolicyLinkMap::iterator loc = ri_rp_links_.find(name); if (loc != ri_rp_links_.end()) { return loc->second; @@ -1408,7 +1415,8 @@ BgpIfmapConfigData::RoutingPolicyMapItems(const string &start_name) const { // The newly created BgpIfmapRoutingPolicyConfig gets added to the // IfmapRoutingPolicyMap. // -BgpIfmapRoutingPolicyConfig *BgpIfmapConfigData::LocateRoutingPolicy(const string &name) { +BgpIfmapRoutingPolicyConfig *BgpIfmapConfigData::LocateRoutingPolicy( + const string &name) { BgpIfmapRoutingPolicyConfig *rtp = FindRoutingPolicy(name); if (rtp != NULL) { return rtp; @@ -1440,7 +1448,7 @@ void BgpIfmapConfigData::DeleteRoutingPolicy(BgpIfmapRoutingPolicyConfig *rtp) { } BgpIfmapRoutingPolicyConfig *BgpIfmapConfigData::FindRoutingPolicy( - const std::string &name) { + const string &name) { IfmapRoutingPolicyMap::iterator loc = routing_policies_.find(name); if (loc != routing_policies_.end()) { return loc->second; @@ -1449,7 +1457,7 @@ BgpIfmapRoutingPolicyConfig *BgpIfmapConfigData::FindRoutingPolicy( } const BgpIfmapRoutingPolicyConfig *BgpIfmapConfigData::FindRoutingPolicy( - const std::string &name) const { + const string &name) const { IfmapRoutingPolicyMap::const_iterator loc = routing_policies_.find(name); if (loc != routing_policies_.end()) { return loc->second; @@ -1461,19 +1469,15 @@ const BgpIfmapRoutingPolicyConfig *BgpIfmapConfigData::FindRoutingPolicy( // Constructor for BgpIfmapConfigManager. // BgpIfmapConfigManager::BgpIfmapConfigManager(BgpServer *server) - : BgpConfigManager(server), - db_(NULL), db_graph_(NULL), - trigger_(boost::bind(&BgpIfmapConfigManager::ConfigHandler, this), - TaskScheduler::GetInstance()->GetTaskId("bgp::Config"), - kConfigTaskInstanceId), - listener_(new BgpConfigListener(this)), - config_(new BgpIfmapConfigData()) { + : BgpConfigManager(server), + db_(NULL), + db_graph_(NULL), + trigger_(boost::bind(&BgpIfmapConfigManager::ConfigHandler, this), + TaskScheduler::GetInstance()->GetTaskId("bgp::Config"), + kConfigTaskInstanceId), + listener_(new BgpConfigListener(this)), + config_(new BgpIfmapConfigData()) { IdentifierMapInit(); - - if (config_task_id_ == -1) { - TaskScheduler *scheduler = TaskScheduler::GetInstance(); - config_task_id_ = scheduler->GetTaskId("bgp::Config"); - } } // @@ -1514,7 +1518,7 @@ BgpIfmapConfigManager::RoutingPolicyMapItems(const string &start_name) const { BgpConfigManager::NeighborMapRange BgpIfmapConfigManager::NeighborMapItems( - const std::string &instance_name) const { + const string &instance_name) const { static BgpConfigManager::NeighborMap nilMap; BgpIfmapInstanceConfig *rti = config_->FindInstance(instance_name); if (rti == NULL) { @@ -1524,7 +1528,7 @@ BgpIfmapConfigManager::NeighborMapItems( } int BgpIfmapConfigManager::NeighborCount( - const std::string &instance_name) const { + const string &instance_name) const { BgpIfmapInstanceConfig *rti = config_->FindInstance(instance_name); if (rti == NULL) { return 0; @@ -1535,7 +1539,8 @@ int BgpIfmapConfigManager::NeighborCount( // // Constructor for BgpIfmapRoutingPolicyConfig. // -BgpIfmapRoutingPolicyConfig::BgpIfmapRoutingPolicyConfig(const std::string &name) +BgpIfmapRoutingPolicyConfig::BgpIfmapRoutingPolicyConfig( + const string &name) : name_(name), data_(name) { } @@ -1592,7 +1597,7 @@ void BgpIfmapRoutingPolicyConfig::RemoveInstance(BgpIfmapInstanceConfig *rti) { static void BuildPolicyTerm(autogen::PolicyTermType cfg_term, - RoutingPolicyTerm *term) { + RoutingPolicyTerm *term) { term->match.protocols_match = cfg_term.term_match_condition.protocol; term->match.community_match = cfg_term.term_match_condition.community; BOOST_FOREACH(const autogen::PrefixMatchType &prefix_match, @@ -1604,15 +1609,15 @@ static void BuildPolicyTerm(autogen::PolicyTermType cfg_term, term->match.prefixes_to_match.push_back(match); } - BOOST_FOREACH(const std::string community, + BOOST_FOREACH(const string community, cfg_term.term_action_list.update.community.add.community) { term->action.update.community_add.push_back(community); } - BOOST_FOREACH(const std::string community, + BOOST_FOREACH(const string community, cfg_term.term_action_list.update.community.remove.community) { term->action.update.community_remove.push_back(community); } - BOOST_FOREACH(const std::string community, + BOOST_FOREACH(const string community, cfg_term.term_action_list.update.community.set.community) { term->action.update.community_set.push_back(community); } @@ -1627,8 +1632,8 @@ static void BuildPolicyTerm(autogen::PolicyTermType cfg_term, } static void BuildPolicyTerms(BgpRoutingPolicyConfig *policy_cfg, - const autogen::RoutingPolicy *policy) { - std::vector terms = policy->entries(); + const autogen::RoutingPolicy *policy) { + vector terms = policy->entries(); BOOST_FOREACH(autogen::PolicyTermType cfg_term, terms) { RoutingPolicyTerm policy_term; BuildPolicyTerm(cfg_term, &policy_term); @@ -1637,7 +1642,7 @@ static void BuildPolicyTerms(BgpRoutingPolicyConfig *policy_cfg, } void BgpIfmapRoutingPolicyConfig::Update(BgpIfmapConfigManager *manager, - const autogen::RoutingPolicy *policy) { + const autogen::RoutingPolicy *policy) { routing_policy_.reset(policy); data_.Clear(); if (policy) { @@ -1653,7 +1658,7 @@ void BgpIfmapRoutingPolicyConfig::ResetConfig() { } const BgpRoutingPolicyConfig *BgpIfmapConfigManager::FindRoutingPolicy( - const std::string &name) const { + const string &name) const { BgpIfmapRoutingPolicyConfig *rtp = config_->FindRoutingPolicy(name); if (rtp == NULL) { return NULL; @@ -1662,7 +1667,7 @@ const BgpRoutingPolicyConfig *BgpIfmapConfigManager::FindRoutingPolicy( } const BgpInstanceConfig *BgpIfmapConfigManager::FindInstance( - const std::string &name) const { + const string &name) const { BgpIfmapInstanceConfig *rti = config_->FindInstance(name); if (rti == NULL) { return NULL; @@ -1671,7 +1676,7 @@ const BgpInstanceConfig *BgpIfmapConfigManager::FindInstance( } const BgpProtocolConfig *BgpIfmapConfigManager::GetProtocolConfig( - const std::string &instance_name) const { + const string &instance_name) const { BgpIfmapInstanceConfig *rti = config_->FindInstance(instance_name); if (rti == NULL) { return NULL; @@ -1684,7 +1689,7 @@ const BgpProtocolConfig *BgpIfmapConfigManager::GetProtocolConfig( } const BgpNeighborConfig *BgpIfmapConfigManager::FindNeighbor( - const std::string &instance_name, const std::string &name) const { + const string &instance_name, const string &name) const { BgpIfmapInstanceConfig *rti = config_->FindInstance(instance_name); if (rti == NULL) { return NULL; @@ -1696,10 +1701,10 @@ const BgpNeighborConfig *BgpIfmapConfigManager::FindNeighbor( // Initialize autogen::BgpRouterParams with default values. // void BgpIfmapConfigManager::DefaultBgpRouterParams( - autogen::BgpRouterParams ¶m) { - param.Clear(); - param.autonomous_system = BgpConfigManager::kDefaultAutonomousSystem; - param.port = BgpConfigManager::kDefaultPort; + autogen::BgpRouterParams *param) { + param->Clear(); + param->autonomous_system = BgpConfigManager::kDefaultAutonomousSystem; + param->port = BgpConfigManager::kDefaultPort; } // @@ -1711,7 +1716,7 @@ void BgpIfmapConfigManager::DefaultConfig() { BgpIfmapInstanceConfig *rti = config_->LocateInstance(kMasterInstance); auto_ptr router(new autogen::BgpRouter()); autogen::BgpRouterParams param; - DefaultBgpRouterParams(param); + DefaultBgpRouterParams(¶m); router->SetProperty("bgp-router-parameters", ¶m); BgpIfmapProtocolConfig *protocol = rti->LocateProtocol(); protocol->Update(this, router.release()); @@ -1746,13 +1751,14 @@ void BgpIfmapConfigManager::IdentifierMapInit() { boost::bind(&BgpIfmapConfigManager::ProcessRoutingInstance, this, _1))); id_map_.insert(make_pair("routing-policy", - boost::bind(&BgpIfmapConfigManager::ProcessRoutingPolicy, this, _1))); + boost::bind(&BgpIfmapConfigManager::ProcessRoutingPolicy, this, _1))); id_map_.insert(make_pair("routing-policy-routing-instance", - boost::bind(&BgpIfmapConfigManager::ProcessRoutingPolicyLink, this, _1))); + boost::bind(&BgpIfmapConfigManager::ProcessRoutingPolicyLink, this, + _1))); id_map_.insert(make_pair("bgp-router", - boost::bind(&BgpIfmapConfigManager::ProcessBgpRouter, this, _1))); + boost::bind(&BgpIfmapConfigManager::ProcessBgpRouter, this, _1))); id_map_.insert(make_pair("bgp-peering", - boost::bind(&BgpIfmapConfigManager::ProcessBgpPeering, this, _1))); + boost::bind(&BgpIfmapConfigManager::ProcessBgpPeering, this, _1))); } // diff --git a/src/bgp/bgp_config_ifmap.h b/src/bgp/bgp_config_ifmap.h index 825228e6df4..312a597c05d 100644 --- a/src/bgp/bgp_config_ifmap.h +++ b/src/bgp/bgp_config_ifmap.h @@ -2,16 +2,18 @@ * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ -#ifndef BGP_BGP_CONFIG_IFMAP_H__ -#define BGP_BGP_CONFIG_IFMAP_H__ +#ifndef SRC_BGP_BGP_CONFIG_IFMAP_H__ +#define SRC_BGP_BGP_CONFIG_IFMAP_H__ + +#include +#include #include #include +#include +#include #include -#include -#include - #include "base/task_trigger.h" #include "base/util.h" #include "bgp/bgp_config.h" @@ -180,10 +182,13 @@ class BgpIfmapProtocolConfig { // class BgpIfmapInstanceConfig { public: - typedef std::map NeighborMap; - typedef std::map PeeringMap; - typedef std::map RouitngPolicyMap; typedef BgpInstanceConfig::RouteTargetList RouteTargetList; + typedef std::map NeighborMap; + typedef std::map PeeringMap; + typedef std::map RouitngPolicyMap; explicit BgpIfmapInstanceConfig(const std::string &name); ~BgpIfmapInstanceConfig(); @@ -255,7 +260,7 @@ class BgpIfmapInstanceConfig { class BgpIfmapRoutingPolicyLinkConfig { public: explicit BgpIfmapRoutingPolicyLinkConfig(BgpIfmapInstanceConfig *rti, - BgpIfmapRoutingPolicyConfig *rtp); + BgpIfmapRoutingPolicyConfig *rtp); ~BgpIfmapRoutingPolicyLinkConfig(); void SetNodeProxy(IFMapNodeProxy *proxy); @@ -265,8 +270,8 @@ class BgpIfmapRoutingPolicyLinkConfig { const autogen::RoutingPolicyRoutingInstance *routing_policy_link() const { return ri_rp_link_.get(); } - static bool GetRoutingInstanceRoutingPolicyPair(DBGraph *graph, - IFMapNode *node, std::pair *pair); + static bool GetInstancePolicyPair(DBGraph *graph, IFMapNode *node, + std::pair *pair); BgpIfmapInstanceConfig *instance() { return instance_; } BgpIfmapRoutingPolicyConfig *policy() { return policy_; } @@ -279,7 +284,8 @@ class BgpIfmapRoutingPolicyLinkConfig { BgpIfmapRoutingPolicyConfig *policy_; std::string name_; IFMapNodeProxy node_proxy_; - boost::intrusive_ptr ri_rp_link_; + boost::intrusive_ptr< + const autogen::RoutingPolicyRoutingInstance> ri_rp_link_; DISALLOW_COPY_AND_ASSIGN(BgpIfmapRoutingPolicyLinkConfig); }; @@ -304,7 +310,9 @@ class BgpIfmapRoutingPolicyConfig { const std::string &name() const { return name_; } BgpRoutingPolicyConfig *routing_policy_config() { return &data_; } - const BgpRoutingPolicyConfig *routing_policy_config() const { return &data_; } + const BgpRoutingPolicyConfig *routing_policy_config() const { + return &data_; + } void AddInstance(BgpIfmapInstanceConfig *rti); void RemoveInstance(BgpIfmapInstanceConfig *rti); @@ -337,10 +345,14 @@ class BgpIfmapConfigData { public: typedef BgpConfigManager::InstanceMap BgpInstanceMap; typedef BgpConfigManager::RoutingPolicyMap BgpRoutingPolicyMap; - typedef std::map IfmapInstanceMap; - typedef std::map IfmapRoutingPolicyMap; - typedef std::map IfmapPeeringMap; - typedef std::map IfmapRoutingPolicyLinkMap; + typedef std::map IfmapInstanceMap; + typedef std::map IfmapRoutingPolicyMap; + typedef std::map IfmapPeeringMap; + typedef std::map IfmapRoutingPolicyLinkMap; BgpIfmapConfigData(); ~BgpIfmapConfigData(); @@ -354,22 +366,24 @@ class BgpIfmapConfigData { BgpIfmapRoutingPolicyConfig *LocateRoutingPolicy(const std::string &name); void DeleteRoutingPolicy(BgpIfmapRoutingPolicyConfig *rtp); BgpIfmapRoutingPolicyConfig *FindRoutingPolicy(const std::string &name); - const BgpIfmapRoutingPolicyConfig *FindRoutingPolicy(const std::string &name) const; + const BgpIfmapRoutingPolicyConfig *FindRoutingPolicy( + const std::string &name) const; BgpIfmapPeeringConfig *CreatePeering(BgpIfmapInstanceConfig *rti, - IFMapNodeProxy *proxy); + IFMapNodeProxy *proxy); void DeletePeering(BgpIfmapPeeringConfig *peer); BgpIfmapPeeringConfig *FindPeering(const std::string &name); const BgpIfmapPeeringConfig *FindPeering(const std::string &name) const; int PeeringCount() const { return peerings_.size(); } - BgpIfmapRoutingPolicyLinkConfig * - CreateRoutingPolicyLink(BgpIfmapInstanceConfig *rti, - BgpIfmapRoutingPolicyConfig *rtp, - IFMapNodeProxy *proxy); + BgpIfmapRoutingPolicyLinkConfig *CreateRoutingPolicyLink( + BgpIfmapInstanceConfig *rti, BgpIfmapRoutingPolicyConfig *rtp, + IFMapNodeProxy *proxy); void DeleteRoutingPolicyLink(BgpIfmapRoutingPolicyLinkConfig *ri_rp_link); - BgpIfmapRoutingPolicyLinkConfig *FindRoutingPolicyLink(const std::string &name); - const BgpIfmapRoutingPolicyLinkConfig *FindRoutingPolicyLink(const std::string &name) const; + BgpIfmapRoutingPolicyLinkConfig *FindRoutingPolicyLink( + const std::string &name); + const BgpIfmapRoutingPolicyLinkConfig *FindRoutingPolicyLink( + const std::string &name) const; BgpConfigManager::InstanceMapRange InstanceMapItems( const std::string &start_name = std::string()) const; @@ -410,7 +424,7 @@ class BgpIfmapConfigData { class BgpIfmapConfigManager : public BgpConfigManager, public IFMapConfigListener::ConfigManager { public: - BgpIfmapConfigManager(BgpServer *server); + explicit BgpIfmapConfigManager(BgpServer *server); virtual ~BgpIfmapConfigManager(); void Initialize(DB *db, DBGraph *db_graph, const std::string &localname); @@ -440,7 +454,7 @@ class BgpIfmapConfigManager : public BgpConfigManager, const std::string &instance_name, const std::string &name) const; // end: BgpConfigManager - void DefaultBgpRouterParams(autogen::BgpRouterParams ¶m); + void DefaultBgpRouterParams(autogen::BgpRouterParams *param); void OnChange(); DB *database() { return db_; } @@ -467,7 +481,6 @@ class BgpIfmapConfigManager : public BgpConfigManager, bool ConfigHandler(); - static int config_task_id_; static const int kConfigTaskInstanceId; DB *db_; @@ -482,4 +495,4 @@ class BgpIfmapConfigManager : public BgpConfigManager, DISALLOW_COPY_AND_ASSIGN(BgpIfmapConfigManager); }; -#endif +#endif // SRC_BGP_BGP_CONFIG_IFMAP_H_ diff --git a/src/bgp/bgp_config_listener.cc b/src/bgp/bgp_config_listener.cc index c9ca663a5d2..7fa23a3b62e 100644 --- a/src/bgp/bgp_config_listener.cc +++ b/src/bgp/bgp_config_listener.cc @@ -4,14 +4,13 @@ #include "bgp/bgp_config_listener.h" -#include #include -#include "bgp/bgp_config_ifmap.h" +#include +#include "bgp/bgp_config_ifmap.h" #include "ifmap/ifmap_dependency_tracker.h" - using boost::assign::list_of; using boost::assign::map_list_of; using std::make_pair; diff --git a/src/bgp/bgp_config_listener.h b/src/bgp/bgp_config_listener.h index 6f64f157e59..0ebab98ce4d 100644 --- a/src/bgp/bgp_config_listener.h +++ b/src/bgp/bgp_config_listener.h @@ -2,8 +2,8 @@ * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ -#ifndef BGP__BGP_CONFIG_LISTENER__ -#define BGP__BGP_CONFIG_LISTENER__ +#ifndef SRC_BGP_BGP_CONFIG_LISTENER_H_ +#define SRC_BGP_BGP_CONFIG_LISTENER_H_ #include "ifmap/ifmap_config_listener.h" @@ -24,4 +24,4 @@ class BgpConfigListener : public IFMapConfigListener { DISALLOW_COPY_AND_ASSIGN(BgpConfigListener); }; -#endif // BGP__BGP_CONFIG_LISTENER__ +#endif // SRC_BGP_BGP_CONFIG_LISTENER_H_ diff --git a/src/bgp/bgp_config_parser.h b/src/bgp/bgp_config_parser.h index e4f91f7eab7..1498c672573 100644 --- a/src/bgp/bgp_config_parser.h +++ b/src/bgp/bgp_config_parser.h @@ -28,6 +28,7 @@ class BgpConfigParser { static std::string session_uuid(const std::string &left, const std::string &right, int index); + private: bool ParseConfig(const pugi::xml_node &root, bool add_change, RequestList *requests) const; diff --git a/src/bgp/bgp_config_yaml.cc b/src/bgp/bgp_config_yaml.cc index 61b310803ed..b52cb6f261a 100644 --- a/src/bgp/bgp_config_yaml.cc +++ b/src/bgp/bgp_config_yaml.cc @@ -14,7 +14,7 @@ using boost::assign::map_list_of; // Container of per-instance data. class YamlInstanceData { - public: +public: typedef BgpConfigManager::NeighborMap NeighborMap; explicit YamlInstanceData(const std::string &name) : protocol_(name) { @@ -44,14 +44,14 @@ class YamlInstanceData { BgpProtocolConfig *GetProtocol() { return &protocol_; } - private: +private: BgpProtocolConfig protocol_; NeighborMap neighbors_; }; // Configuration data class BgpYamlConfigManager::Configuration { - public: +public: typedef map InstanceDataMap; Configuration() { @@ -103,7 +103,8 @@ class BgpYamlConfigManager::Configuration { RoutingPolicyMap *RoutingPolicyMapMutable() { return &routing_policies_; } - private: + +private: BgpInstanceConfig *LocateInstance(const std::string &name) { InstanceMap::iterator loc = instances_.find(name); if (loc != instances_.end()) { @@ -113,7 +114,6 @@ class BgpYamlConfigManager::Configuration { instances_.insert( make_pair(name, new BgpInstanceConfig(name))); return result.first->second; - } BgpRoutingPolicyConfig *LocateRoutingPolicy(const std::string &name) { diff --git a/src/bgp/bgp_ifmap_sandesh.h b/src/bgp/bgp_ifmap_sandesh.h index 4c1218b8b4e..b41a619a266 100644 --- a/src/bgp/bgp_ifmap_sandesh.h +++ b/src/bgp/bgp_ifmap_sandesh.h @@ -1,8 +1,12 @@ -#ifndef BGP__BGP_IFMAP_SANDESH_H__ -#define BGP__BGP_IFMAP_SANDESH_H__ +/* + * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. + */ + +#ifndef SRC_BGP_BGP_IFMAP_SANDESH_H__ +#define SRC_BGP_BGP_IFMAP_SANDESH_H__ struct BgpSandeshContext; -extern void RegisterSandeshShowIfmapHandlers(BgpSandeshContext *); +extern void RegisterSandeshShowIfmapHandlers(BgpSandeshContext *bsc); -#endif // BGP__BGP_IFMAP_SANDESH_H__ +#endif // SRC_BGP_BGP_IFMAP_SANDESH_H__ diff --git a/src/bgp/bgp_message_builder.h b/src/bgp/bgp_message_builder.h index 43c8e8b786a..4385994a862 100644 --- a/src/bgp/bgp_message_builder.h +++ b/src/bgp/bgp_message_builder.h @@ -10,7 +10,7 @@ class BgpMessage : public Message { public: - BgpMessage(const BgpTable *table = NULL); + explicit BgpMessage(const BgpTable *table = NULL); virtual ~BgpMessage(); bool Start(const RibOutAttr *roattr, const BgpRoute *route); virtual bool AddRoute(const BgpRoute *route, const RibOutAttr *roattr); diff --git a/src/bgp/bgp_path.h b/src/bgp/bgp_path.h index 1294c4869fc..ccc30af4b42 100644 --- a/src/bgp/bgp_path.h +++ b/src/bgp/bgp_path.h @@ -6,6 +6,7 @@ #define SRC_BGP_BGP_PATH_H_ #include +#include #include "base/util.h" #include "route/path.h" diff --git a/src/bgp/bgp_peer.h b/src/bgp/bgp_peer.h index 755837d31fc..66fc9c98d94 100644 --- a/src/bgp/bgp_peer.h +++ b/src/bgp/bgp_peer.h @@ -131,7 +131,7 @@ class BgpPeer : public IPeer { virtual BgpServer *server() { return server_; } const BgpServer *server() const { return server_; } - unsigned long PeerAddress() const { return peer_key_.Address(); } + unsigned long PeerAddress() const { return peer_key_.address(); } const std::string peer_address_string() const { return peer_key_.endpoint.address().to_string(); } diff --git a/src/bgp/bgp_peer_key.h b/src/bgp/bgp_peer_key.h index 381a22b4a4d..1ba8a1cb505 100644 --- a/src/bgp/bgp_peer_key.h +++ b/src/bgp/bgp_peer_key.h @@ -19,9 +19,7 @@ struct BgpPeerKey { bool operator==(const BgpPeerKey &rhs) const; bool operator!=(const BgpPeerKey &rhs) const; - unsigned long Address() const { - return endpoint.address().to_v4().to_ulong(); - } + uint32_t address() const { return endpoint.address().to_v4().to_ulong(); } boost::asio::ip::tcp::endpoint endpoint; boost::uuids::uuid uuid; diff --git a/src/bgp/bgp_ribout.cc b/src/bgp/bgp_ribout.cc index ee1eb2019dd..84441a69abb 100644 --- a/src/bgp/bgp_ribout.cc +++ b/src/bgp/bgp_ribout.cc @@ -2,10 +2,10 @@ * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ -#include - #include +#include + #include "base/string_util.h" #include "bgp/bgp_ribout.h" #include "bgp/bgp_ribout_updates.h" diff --git a/src/bgp/bgp_route.cc b/src/bgp/bgp_route.cc index 7763d11c87f..ebd91073b5b 100644 --- a/src/bgp/bgp_route.cc +++ b/src/bgp/bgp_route.cc @@ -461,7 +461,8 @@ void BgpRoute::FillRouteInfo(const BgpTable *table, if (attr->ext_community()) { FillRoutePathExtCommunityInfo(table, attr->ext_community(), &srp); } - if (srp.get_origin_vn().empty() && !table->IsVpnTable() && path->IsVrfOriginated()) { + if (srp.get_origin_vn().empty() && + !table->IsVpnTable() && path->IsVrfOriginated()) { srp.set_origin_vn(ri->GetVirtualNetworkName()); } if (attr->origin_vn_path()) { diff --git a/src/bgp/bgp_sandesh.cc b/src/bgp/bgp_sandesh.cc index 60b7aba67d3..59b8bc1f570 100644 --- a/src/bgp/bgp_sandesh.cc +++ b/src/bgp/bgp_sandesh.cc @@ -18,34 +18,37 @@ #include "bgp/routing-instance/peer_manager.h" #include "bgp/routing-instance/routing_instance.h" -using namespace boost::assign; -using namespace std; +using boost::assign::list_of; +using std::string; +using std::vector; class ShowNeighborStatisticsHandler { public: static bool CallbackS1(const Sandesh *sr, - const RequestPipeline::PipeSpec ps, int stage, - int instNum, RequestPipeline::InstData * data); - static size_t FillBgpNeighborStatistics(const ShowNeighborStatisticsReq *req, - BgpServer *bgp_server); + const RequestPipeline::PipeSpec ps, int stage, int instNum, + RequestPipeline::InstData * data); + static size_t FillBgpNeighborStatistics( + const ShowNeighborStatisticsReq *req, BgpServer *bgp_server); }; size_t ShowNeighborStatisticsHandler::FillBgpNeighborStatistics( - const ShowNeighborStatisticsReq *req, BgpServer *bgp_server) { + const ShowNeighborStatisticsReq *req, BgpServer *bgp_server) { size_t count = 0; if (req->get_bgp_or_xmpp().empty() || - boost::iequals(req->get_bgp_or_xmpp(), "bgp")) { + boost::iequals(req->get_bgp_or_xmpp(), "bgp")) { RoutingInstanceMgr *rim = bgp_server->routing_instance_mgr(); if (!req->get_domain().empty()) { RoutingInstance *ri = rim->GetRoutingInstance(req->get_domain()); if (ri) { - count += ri->peer_manager()->GetNeighborCount(req->get_up_or_down()); + count += + ri->peer_manager()->GetNeighborCount(req->get_up_or_down()); } } else { RoutingInstanceMgr::RoutingInstanceIterator it = rim->begin(); - for (;it != rim->end(); it++) { - count += it->peer_manager()->GetNeighborCount(req->get_up_or_down()); + for (; it != rim->end(); it++) { + count += + it->peer_manager()->GetNeighborCount(req->get_up_or_down()); } } } @@ -56,12 +59,10 @@ size_t ShowNeighborStatisticsHandler::FillBgpNeighborStatistics( bool ShowNeighborStatisticsHandler::CallbackS1( const Sandesh *sr, const RequestPipeline::PipeSpec ps, int stage, int instNum, RequestPipeline::InstData *data) { - const ShowNeighborStatisticsReq *req; BgpSandeshContext *bsc; - req = static_cast( - ps.snhRequest_.get()); + req = static_cast(ps.snhRequest_.get()); bsc = static_cast(req->client_context()); // Retrieve number of BGP peers. @@ -85,7 +86,6 @@ bool ShowNeighborStatisticsHandler::CallbackS1( } void ShowNeighborStatisticsReq::HandleRequest() const { - // Use config task as we need to examine both bgp and xmpp data bases // to compute the number of neighbors. Both BGP and XMPP peers are // inserted/deleted under config task. @@ -133,7 +133,6 @@ bool ClearBgpNeighborHandler::CallbackS1( // handler for 'clear bgp neighbor' void ClearBgpNeighborReq::HandleRequest() const { - // Use config task since neighbors are added/deleted under that task. // to compute the number of neighbors. RequestPipeline::StageSpec s1; @@ -221,10 +220,12 @@ class ShowMulticastManagerDetailHandler { MulticastManagerDetailData *mydata = static_cast(data); const ShowMulticastManagerDetailReq *req = - static_cast(ps.snhRequest_.get()); + static_cast( + ps.snhRequest_.get()); BgpSandeshContext *bsc = static_cast(req->client_context()); - DBTableBase *table = bsc->bgp_server->database()->FindTable(req->get_name()); + DBTableBase *table = + bsc->bgp_server->database()->FindTable(req->get_name()); ErmVpnTable *mcast_table = dynamic_cast(table); if (mcast_table && !mcast_table->IsVpnTable()) FillMulticastPartitionInfo(mydata, mcast_table, inst_id); @@ -253,7 +254,8 @@ class ShowMulticastManagerDetailHandler { vector tree_list; CombineMulticastPartitionInfo(sd, tree_list); - ShowMulticastManagerDetailResp *resp = new ShowMulticastManagerDetailResp; + ShowMulticastManagerDetailResp *resp = + new ShowMulticastManagerDetailResp; resp->set_trees(tree_list); resp->set_context(req->context()); resp->Response(); @@ -321,8 +323,8 @@ class ShowRouteVrfHandler { show_route.set_last_modified(duration_usecs_to_string( UTCTimestampUsec() - route->last_change_at())); vector show_route_paths; - for(Route::PathList::const_iterator it = route->GetPathList().begin(); - it != route->GetPathList().end(); it++) { + for (Route::PathList::const_iterator it = route->GetPathList().begin(); + it != route->GetPathList().end(); it++) { const BgpPath *path = static_cast(it.operator->()); ShowRoutePath srp; srp.set_protocol("BGP"); @@ -349,7 +351,8 @@ class ShowRouteVrfHandler { const RequestPipeline::StageData *sd = ps.GetStageData(0); ShowRoute route; for (size_t i = 0; i < sd->size(); i++) { - const SearchRouteInVrfData &data = static_cast(sd->at(i)); + const SearchRouteInVrfData &data = + static_cast(sd->at(i)); if (data.routes.size()) { route = data.routes.front(); break; diff --git a/src/bgp/bgp_sandesh.h b/src/bgp/bgp_sandesh.h index 35c72794099..8a379fa5624 100644 --- a/src/bgp/bgp_sandesh.h +++ b/src/bgp/bgp_sandesh.h @@ -2,12 +2,15 @@ * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ -#ifndef BGP_SANDESH_H_ -#define BGP_SANDESH_H_ +#ifndef SRC_BGP_BGP_SANDESH_H_ +#define SRC_BGP_BGP_SANDESH_H_ #include #include +#include +#include + class BgpServer; class BgpXmppChannelManager; class BgpNeighborResp; @@ -72,4 +75,4 @@ struct BgpSandeshContext : public SandeshContext { PeeringReqIterateHandler show_peering_req_iterate_handler_; }; -#endif /* BGP_SANDESH_H_ */ +#endif // SRC_BGP_BGP_SANDESH_H_ diff --git a/src/bgp/bgp_server.cc b/src/bgp/bgp_server.cc index 8aef0187014..7109f7a36bf 100644 --- a/src/bgp/bgp_server.cc +++ b/src/bgp/bgp_server.cc @@ -38,15 +38,14 @@ class BgpServer::ConfigUpdater { public: explicit ConfigUpdater(BgpServer *server) : server_(server) { BgpConfigManager::Observers obs; - obs.instance = - boost::bind(&ConfigUpdater::ProcessInstanceConfig, this, _1, _2); - obs.protocol = - boost::bind(&ConfigUpdater::ProcessProtocolConfig, this, _1, _2); - obs.neighbor = - boost::bind(&ConfigUpdater::ProcessNeighborConfig, this, _1, _2); - obs.policy = - boost::bind(&ConfigUpdater::ProcessRoutingPolicyConfig, this, _1, _2); - + obs.instance = boost::bind(&ConfigUpdater::ProcessInstanceConfig, + this, _1, _2); + obs.protocol = boost::bind(&ConfigUpdater::ProcessProtocolConfig, + this, _1, _2); + obs.neighbor = boost::bind(&ConfigUpdater::ProcessNeighborConfig, + this, _1, _2); + obs.policy = boost::bind(&ConfigUpdater::ProcessRoutingPolicyConfig, + this, _1, _2); server->config_manager()->RegisterObservers(obs); } diff --git a/src/bgp/bgp_session_manager.cc b/src/bgp/bgp_session_manager.cc index 4c8aef3ba07..f9f672f37af 100644 --- a/src/bgp/bgp_session_manager.cc +++ b/src/bgp/bgp_session_manager.cc @@ -29,7 +29,7 @@ BgpSessionManager::~BgpSessionManager() { // // Start listening at the given port. // -bool BgpSessionManager::Initialize(short port) { +bool BgpSessionManager::Initialize(unsigned short port) { return TcpServer::Initialize(port); } diff --git a/src/bgp/bgp_session_manager.h b/src/bgp/bgp_session_manager.h index f15c2affc2e..4fe7d8c2c55 100644 --- a/src/bgp/bgp_session_manager.h +++ b/src/bgp/bgp_session_manager.h @@ -23,7 +23,7 @@ class BgpSessionManager : public TcpServer { virtual ~BgpSessionManager(); virtual TcpSession *CreateSession(); - virtual bool Initialize(short port); + virtual bool Initialize(unsigned short port); void Shutdown(); void Terminate(); bool MayDelete() const; diff --git a/src/bgp/bgp_show_handler.h b/src/bgp/bgp_show_handler.h index 679bf08e3d8..dd8076a12aa 100644 --- a/src/bgp/bgp_show_handler.h +++ b/src/bgp/bgp_show_handler.h @@ -2,13 +2,17 @@ * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ -#ifndef BGP_BGP_SHOW_HANDLER_H__ -#define BGP_BGP_SHOW_HANDLER_H__ +#ifndef SRC_BGP_BGP_SHOW_HANDLER_H__ +#define SRC_BGP_BGP_SHOW_HANDLER_H__ + +#include "bgp/bgp_sandesh.h" #include #include #include -#include "bgp/bgp_sandesh.h" + +#include +#include static char kIterSeparator[] = "||"; @@ -223,4 +227,4 @@ bool BgpShowHandler::CallbackIterate( return true; } -#endif // BGP_BGP_SHOW_HANDLER_H__ +#endif // SRC_BGP_BGP_SHOW_HANDLER_H__ diff --git a/src/bgp/bgp_table.cc b/src/bgp/bgp_table.cc index 15356816c21..78480ef2b79 100644 --- a/src/bgp/bgp_table.cc +++ b/src/bgp/bgp_table.cc @@ -78,7 +78,6 @@ void BgpTable::set_routing_instance(RoutingInstance *rtinstance) { path_resolver_ = CreatePathResolver(); if (IsRouteAggregationSupported()) rtinstance->route_aggregator(family())->Initialize(); - } BgpServer *BgpTable::server() { diff --git a/src/bgp/bgp_xmpp_sandesh.cc b/src/bgp/bgp_xmpp_sandesh.cc index 7808d3f83f8..d312dcf08b0 100644 --- a/src/bgp/bgp_xmpp_sandesh.cc +++ b/src/bgp/bgp_xmpp_sandesh.cc @@ -3,6 +3,8 @@ */ #include "bgp/bgp_xmpp_sandesh.h" +#include +#include #include "bgp/bgp_peer.h" #include "bgp/bgp_peer_internal_types.h" @@ -126,7 +128,6 @@ static void ShowXmppNeighborStatistics( boost::bind(ShowXmppNeighborStatisticsVisitor, count, bsc->bgp_server, req->get_domain(), req->get_up_or_down(), _1)); - } void RegisterSandeshShowXmppExtensions(BgpSandeshContext *bsc) { diff --git a/src/bgp/bgp_xmpp_sandesh.h b/src/bgp/bgp_xmpp_sandesh.h index cdcb1eacb8c..c2847c3291d 100644 --- a/src/bgp/bgp_xmpp_sandesh.h +++ b/src/bgp/bgp_xmpp_sandesh.h @@ -1,8 +1,12 @@ -#ifndef BGP__BGP_XMPP_SANDESH_H__ -#define BGP__BGP_XMPP_SANDESH_H__ +/* + * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. + */ + +#ifndef SRC_BGP_BGP_XMPP_SANDESH_H__ +#define SRC_BGP_BGP_XMPP_SANDESH_H__ struct BgpSandeshContext; -extern void RegisterSandeshShowXmppExtensions(BgpSandeshContext *); +extern void RegisterSandeshShowXmppExtensions(BgpSandeshContext *bsc); -#endif // BGP__BGP_XMPP_SANDESH_H__ +#endif // SRC_BGP_BGP_XMPP_SANDESH_H__ diff --git a/src/bgp/community.cc b/src/bgp/community.cc index 7e192f4364d..049cec7c433 100644 --- a/src/bgp/community.cc +++ b/src/bgp/community.cc @@ -4,11 +4,11 @@ #include "bgp/community.h" +#include + #include #include -#include - #include "base/string_util.h" #include "bgp/bgp_proto.h" #include "bgp/tunnel_encap/tunnel_encap.h" diff --git a/src/bgp/routing-instance/path_resolver.h b/src/bgp/routing-instance/path_resolver.h index 79fecf84d4f..bf22ed54755 100644 --- a/src/bgp/routing-instance/path_resolver.h +++ b/src/bgp/routing-instance/path_resolver.h @@ -10,7 +10,9 @@ #include #include +#include #include +#include #include "base/lifetime.h" #include "base/util.h" diff --git a/src/bgp/routing-instance/routepath_replicator.cc b/src/bgp/routing-instance/routepath_replicator.cc index 7f210353790..e830d2fcf1f 100644 --- a/src/bgp/routing-instance/routepath_replicator.cc +++ b/src/bgp/routing-instance/routepath_replicator.cc @@ -48,7 +48,7 @@ do { \ class TableState::DeleteActor : public LifetimeActor { public: - DeleteActor(TableState *ts) + explicit DeleteActor(TableState *ts) : LifetimeActor(ts->replicator()->server()->lifetime_manager()), ts_(ts) { } diff --git a/src/bgp/routing-instance/routepath_replicator.h b/src/bgp/routing-instance/routepath_replicator.h index e626bbdbeca..8657346039d 100644 --- a/src/bgp/routing-instance/routepath_replicator.h +++ b/src/bgp/routing-instance/routepath_replicator.h @@ -13,6 +13,7 @@ #include #include #include +#include #include "base/lifetime.h" #include "base/util.h" @@ -311,7 +312,7 @@ class RoutePathReplicator { BgpServer *server() { return server_; } Address::Family family() const { return family_; } - const BgpServer *server() const { return server_; }; + const BgpServer *server() const { return server_; } // Mutex to protect bulk_sync_ from multiple DBTable tasks. tbb::mutex mutex_; diff --git a/src/bgp/routing-instance/routing_instance.h b/src/bgp/routing-instance/routing_instance.h index a51fc283e04..1925d76a5f5 100644 --- a/src/bgp/routing-instance/routing_instance.h +++ b/src/bgp/routing-instance/routing_instance.h @@ -124,7 +124,7 @@ class RoutingInstance { RoutingInstanceInfo GetDataCollection(const char *operation); BgpServer *server() { return server_; } - const BgpServer *server() const { return server_; }; + const BgpServer *server() const { return server_; } // Remove import and export route target // and Leave corresponding RtGroup diff --git a/src/bgp/routing-instance/routing_instance_log.h b/src/bgp/routing-instance/routing_instance_log.h index 31c79a36038..f6407ed6b8e 100644 --- a/src/bgp/routing-instance/routing_instance_log.h +++ b/src/bgp/routing-instance/routing_instance_log.h @@ -2,12 +2,17 @@ * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ +#ifndef SRC_BGP_ROUTING_INSTANCE_ROUTING_INSTANCE_LOG_H_ +#define SRC_BGP_ROUTING_INSTANCE_ROUTING_INSTANCE_LOG_H_ + #include #include #include #include #include +#include + #include "bgp/routing-instance/routing_instance_analytics_types.h" // @@ -62,3 +67,5 @@ do { \ if (LoggingDisabled()) break; \ ROUTING_INSTANCE_COLLECTOR_SEND(info); \ } while (false) + +#endif // SRC_BGP_ROUTING_INSTANCE_ROUTING_INSTANCE_LOG_H_ diff --git a/src/bgp/routing-instance/rtarget_group.cc b/src/bgp/routing-instance/rtarget_group.cc index 05bd235e00c..14cc21d2ebe 100644 --- a/src/bgp/routing-instance/rtarget_group.cc +++ b/src/bgp/routing-instance/rtarget_group.cc @@ -4,9 +4,10 @@ #include "bgp/routing-instance/rtarget_group.h" -#include #include +#include + #include "sandesh/sandesh_types.h" #include "sandesh/sandesh.h" #include "sandesh/sandesh_trace.h" diff --git a/src/bgp/routing-instance/service_chaining.cc b/src/bgp/routing-instance/service_chaining.cc index be848e1cd64..d530a1b15fa 100644 --- a/src/bgp/routing-instance/service_chaining.cc +++ b/src/bgp/routing-instance/service_chaining.cc @@ -866,7 +866,8 @@ bool ServiceChainMgr::RequestHandler(ServiceChainRequestT *req) { delete state; if (!info->num_matchstate()) { if (info->dest_table_unregistered()) { - listener_->UnregisterMatchCondition(info->dest_table(), info); + listener_->UnregisterMatchCondition( + info->dest_table(), info); } if (info->connected_table_unregistered()) { listener_->UnregisterMatchCondition( diff --git a/src/bgp/routing-instance/show_route_aggregate.cc b/src/bgp/routing-instance/show_route_aggregate.cc index e78db5a7d3d..7b253dd1184 100644 --- a/src/bgp/routing-instance/show_route_aggregate.cc +++ b/src/bgp/routing-instance/show_route_aggregate.cc @@ -2,8 +2,6 @@ * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved. */ -#include "bgp/bgp_show_handler.h" - #include #include diff --git a/src/bgp/routing-instance/show_service_chaining.cc b/src/bgp/routing-instance/show_service_chaining.cc index f33681d5ce8..c437073a2fe 100644 --- a/src/bgp/routing-instance/show_service_chaining.cc +++ b/src/bgp/routing-instance/show_service_chaining.cc @@ -2,8 +2,6 @@ * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ -#include "bgp/bgp_show_handler.h" - #include "bgp/bgp_config.h" #include "bgp/bgp_server.h" #include "bgp/bgp_show_handler.h" diff --git a/src/bgp/routing-instance/show_static_route.cc b/src/bgp/routing-instance/show_static_route.cc index cded6ad36d0..d5539fc49b0 100644 --- a/src/bgp/routing-instance/show_static_route.cc +++ b/src/bgp/routing-instance/show_static_route.cc @@ -2,8 +2,6 @@ * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ -#include "bgp/bgp_show_handler.h" - #include "bgp/bgp_config.h" #include "bgp/bgp_server.h" #include "bgp/bgp_show_handler.h" diff --git a/src/bgp/routing-instance/static_route.cc b/src/bgp/routing-instance/static_route.cc index 7aa9a0fb455..ff7b6fb9803 100644 --- a/src/bgp/routing-instance/static_route.cc +++ b/src/bgp/routing-instance/static_route.cc @@ -900,9 +900,8 @@ uint32_t StaticRouteMgr::GetDownRouteCount() const { return count; } -template -bool StaticRouteMgr::FillStaticRouteInfo(RoutingInstance *ri, - StaticRouteEntriesInfo *info) const{ +template bool StaticRouteMgr::FillStaticRouteInfo( + RoutingInstance *ri, StaticRouteEntriesInfo *info) const { if (static_route_map_.empty()) return false; diff --git a/src/bgp/scheduling_group.cc b/src/bgp/scheduling_group.cc index f381738cd45..43130d4acbb 100644 --- a/src/bgp/scheduling_group.cc +++ b/src/bgp/scheduling_group.cc @@ -7,6 +7,7 @@ #include #include +#include #include "base/task_annotations.h" #include "bgp/bgp_factory.h" @@ -17,6 +18,7 @@ using std::auto_ptr; using std::make_pair; using std::map; using std::pair; +using std::string; using std::swap; using std::vector; @@ -428,7 +430,7 @@ class SchedulingGroup::Worker : public Task { return true; } - std::string Description() const { return "SchedulingGroup::Worker"; } + string Description() const { return "SchedulingGroup::Worker"; } private: SchedulingGroup *group_; @@ -559,7 +561,8 @@ void SchedulingGroup::GetRibPeerList(RibOut *ribout, PeerList *plist) const { // Build the bitset of peers advertising at least one RibOut corresponding to // the RibState list. // -void SchedulingGroup::GetSubsetPeers(const RibStateList &list, GroupPeerSet *pg) { +void SchedulingGroup::GetSubsetPeers(const RibStateList &list, + GroupPeerSet *pg) { CHECK_CONCURRENCY("bgp::PeerMembership"); pg->clear();