Skip to content

Commit

Permalink
Fix cpplint errors
Browse files Browse the repository at this point in the history
Change-Id: I852a29d906e7a62185e8e0fe26051a31e8c13beb
Partial-Bug: 1548570
  • Loading branch information
Nischal Sheth committed Jun 29, 2016
1 parent d0ac986 commit f7055da
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 56 deletions.
6 changes: 4 additions & 2 deletions src/bgp/bgp_condition_listener.cc
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/bgp/bgp_config.cc
Expand Up @@ -381,27 +381,27 @@ string RoutingPolicyMatchConfig::ToString() const {
return oss.str();
}

static void PutCommunityList(ostringstream &oss, const CommunityList &list) {
copy(list.begin(), list.end(), ostream_iterator<string>(oss, ","));
oss.seekp(-1, oss.cur);
static void PutCommunityList(ostringstream *oss, const CommunityList &list) {
copy(list.begin(), list.end(), ostream_iterator<string>(*oss, ","));
oss->seekp(-1, oss->cur);
}

string RoutingPolicyActionConfig::ToString() const {
ostringstream oss;
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) {
Expand Down
6 changes: 4 additions & 2 deletions src/bgp/bgp_config_parser.cc
Expand Up @@ -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;
Expand All @@ -33,8 +37,6 @@ using std::set;
using std::string;
using std::vector;

using namespace pugi;

typedef multimap<
pair<string, string>,
pair<autogen::BgpSessionAttributes, string> > SessionMap;
Expand Down
7 changes: 5 additions & 2 deletions src/bgp/bgp_log.cc
Expand Up @@ -2,7 +2,10 @@
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/

#include "bgp_log.h"
#include "bgp/bgp_log.h"

#include <string>

#include "bgp/bgp_server.h"
#include "bgp/routing-instance/routing_instance.h"

Expand Down Expand Up @@ -77,4 +80,4 @@ void LogServerName(const IPeer *ipeer, const BgpTable *table) {
LogServerName(server);
}

}
} // namespace bgp_log_test
7 changes: 1 addition & 6 deletions src/bgp/bgp_peer.cc
Expand Up @@ -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).
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1221,8 +1218,7 @@ const vector<Address::Family> BgpPeer::supported_families_ = list_of
(Address::RTARGET)
(Address::ERMVPN)
(Address::INET6)
(Address::INET6VPN)
;
(Address::INET6VPN);

void BgpPeer::AddGRCapabilities(BgpProto::OpenMessage::OptParam *opt_param) {
vector<Address::Family> gr_families;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/bgp/bgp_peer.h
Expand Up @@ -9,6 +9,7 @@
#include <boost/scoped_ptr.hpp>
#include <tbb/spin_mutex.h>

#include <map>
#include <memory>
#include <set>
#include <string>
Expand Down Expand Up @@ -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<Address::Family> AddressFamilyList;
typedef AuthenticationData::KeyType KeyType;
Expand Down
5 changes: 2 additions & 3 deletions src/bgp/bgp_peer_close.cc
Expand Up @@ -6,14 +6,15 @@

#include <boost/foreach.hpp>

#include <list>

#include "base/task_annotations.h"
#include "base/timer.h"
#include "bgp/bgp_log.h"
#include "bgp/bgp_membership.h"
#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"

Expand Down Expand Up @@ -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) {
Expand All @@ -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_) {
Expand Down
2 changes: 2 additions & 0 deletions src/bgp/bgp_peer_close.h
Expand Up @@ -5,6 +5,8 @@
#ifndef SRC_BGP_BGP_PEER_CLOSE_H_
#define SRC_BGP_BGP_PEER_CLOSE_H_

#include <string>

#include "base/timer.h"
#include "base/util.h"
#include "base/queue_task.h"
Expand Down
6 changes: 3 additions & 3 deletions src/bgp/bgp_sandesh.cc
Expand Up @@ -237,11 +237,11 @@ class ShowMulticastManagerDetailHandler {

static void CombineMulticastPartitionInfo(
const RequestPipeline::StageData *sd,
vector<ShowMulticastTree> &tree_list) {
vector<ShowMulticastTree> *tree_list) {
for (size_t idx = 0; idx < sd->size(); idx++) {
const MulticastManagerDetailData &data =
static_cast<const MulticastManagerDetailData &>(sd->at(idx));
tree_list.insert(tree_list.end(),
tree_list->insert(tree_list->end(),
data.tree_list.begin(), data.tree_list.end());
}
}
Expand All @@ -254,7 +254,7 @@ class ShowMulticastManagerDetailHandler {
static_cast<const ShowMulticastManagerReq *>(ps.snhRequest_.get());
const RequestPipeline::StageData *sd = ps.GetStageData(0);
vector<ShowMulticastTree> tree_list;
CombineMulticastPartitionInfo(sd, tree_list);
CombineMulticastPartitionInfo(sd, &tree_list);

ShowMulticastManagerDetailResp *resp =
new ShowMulticastManagerDetailResp;
Expand Down
27 changes: 12 additions & 15 deletions src/bgp/bgp_xmpp_channel.cc
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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,
Expand All @@ -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());

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/bgp/bgp_xmpp_channel.h
Expand Up @@ -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);
Expand Down
13 changes: 3 additions & 10 deletions src/bgp/state_machine.cc
Expand Up @@ -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);
}

//
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/bgp/state_machine.h
Expand Up @@ -205,7 +205,7 @@ class StateMachine : public sc::state_machine<StateMachine, fsm::Idle> {

void TimerErrorHanlder(std::string name, std::string error) { }
void DeleteAllTimers();
void BGPPeerInfoSend(BgpPeerInfoData &peer_info);
void BGPPeerInfoSend(const BgpPeerInfoData &peer_info);

template <typename Ev> bool Enqueue(const Ev &event);
bool DequeueEvent(EventContainer ec);
Expand Down
2 changes: 1 addition & 1 deletion src/bgp/xmpp_message_builder.cc
Expand Up @@ -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<const char*>(data), size);
}
Expand Down

0 comments on commit f7055da

Please sign in to comment.