Skip to content

Commit

Permalink
Merge "GracefulRestart support in control-node (Phase 1)"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Mar 3, 2016
2 parents 1d6b4e1 + 1b62a30 commit 0ca972c
Show file tree
Hide file tree
Showing 32 changed files with 2,366 additions and 562 deletions.
4 changes: 4 additions & 0 deletions ci_unittests.json
Expand Up @@ -53,6 +53,9 @@
{
"tuples" : [
"NO_HEAPCHECK=TRUE",
"TASK_UTIL_DEFAULT_RETRY_COUNT=6000",
"TASK_UTIL_WAIT_TIME=10000",
"WAIT_FOR_IDLE=60",
"LOG_DISABLE=TRUE"
],
"tests" : [
Expand All @@ -71,6 +74,7 @@
".*/bgp/test/bgp_xmpp_inet6vpn_test$",
".*/bgp/test/bgp_xmpp_mcast_test$",
".*/bgp/test/bgp_xmpp_rtarget_test$",
".*/bgp/test/graceful_restart_test$",
".*/bgp/test/service_chain_test",
".*/bgp/test/svc_static_route_intergration_test",
".*/bgp/test/xmpp_ecmp_test$"
Expand Down
4 changes: 2 additions & 2 deletions src/base/test/task_test_util.h
Expand Up @@ -59,8 +59,8 @@ do { \
#define TASK_UTIL_WAIT_MSG(cnt, expected, actual, wait, type, msg) \
do { \
ostream << __FILE__ << ":" << __FUNCTION__ << "():" << __LINE__; \
ostream << ": " << msg << ": Waiting for " << actual << type; \
ostream << expected << "\n"; \
ostream << ": " << msg << ": Waiting for " << (actual) << type; \
ostream << (expected) << "\n"; \
log4cplus::Logger logger = log4cplus::Logger::getRoot(); \
LOG4CPLUS_DEBUG(logger, ostream.str()); \
} while (false)
Expand Down
66 changes: 24 additions & 42 deletions src/bgp/bgp_peer.cc
Expand Up @@ -49,67 +49,45 @@ class BgpPeer::PeerClose : public IPeerClose {
return peer_->ToString();
}

// If the peer is deleted or administratively held down, do not attempt
// graceful restart
virtual bool IsCloseGraceful() {

//
// If the peer is deleted or administratively held down, do not attempt
// graceful restart
//
if (peer_->IsDeleted() || peer_->IsAdminDown()) return false;

if (peer_->IsDeleted() || peer_->IsAdminDown())
return false;
return peer_->server()->IsPeerCloseGraceful();
}

virtual void CustomClose() {
return peer_->CustomClose();
}
virtual void CustomClose() { return peer_->CustomClose(); }
virtual void GracefulRestartStale() { }
virtual void GracefulRestartSweep() { }

// CloseComplete
//
// Close process for this peer is complete. Restart the state machine and
// attempt to bring up session with the neighbor
//
virtual bool CloseComplete(bool from_timer, bool gr_cancelled) {
virtual void CloseComplete() {
peer_->server()->decrement_closing_count();
if (!peer_->IsAdminDown())
peer_->state_machine_->Initialize();
}
virtual void Delete() {
if (!peer_->IsDeleted()) {

//
// If this closure is off graceful restart timer, nothing else to
// do as we retain the peer based on the configuration
//
if (from_timer) return false;

//
// Reset peer's state machine
//
if (!peer_->IsAdminDown()) peer_->state_machine_->Initialize();

return false;
CloseComplete();
return;
}

//
// This peer is deleted. Timer should have already been cancelled
//
assert(!from_timer);

peer_->server()->decrement_closing_count();
peer_->deleter()->RetryDelete();
is_closed_ = true;
return true;
}

bool IsClosed() const {
return is_closed_;
}

virtual PeerCloseManager *close_manager() {
return manager_.get();
}
bool IsClosed() const { return is_closed_; }
virtual PeerCloseManager *close_manager() { return manager_.get(); }

void Close() {
if (!is_closed_ && !manager_->IsCloseInProgress()) {
manager_->Close();
if (!manager_->IsCloseInProgress())
peer_->server()->increment_closing_count();
}
manager_->Close();
}

private:
Expand Down Expand Up @@ -1659,6 +1637,10 @@ static void FillSocketStats(const IPeerDebugStats::SocketStats &socket_stats,
}
}

void BgpPeer::FillCloseInfo(BgpNeighborResp *resp) const {
peer_close_->close_manager()->FillCloseInfo(resp);
}

void BgpPeer::FillBgpNeighborDebugState(BgpNeighborResp *bnr,
const IPeerDebugStats *peer_state) {
bnr->set_last_state(peer_state->last_state());
Expand Down Expand Up @@ -1722,7 +1704,7 @@ void BgpPeer::FillNeighborInfo(const BgpSandeshContext *bsc,
bnr->set_instance_name(rtinstance_->name());
bnr->set_peer(peer_basename_);
bnr->set_deleted(IsDeleted());
bnr->set_deleted_at(UTCUsecToString(deleter_->delete_time_stamp_usecs()));
bnr->set_closed_at(UTCUsecToString(deleter_->delete_time_stamp_usecs()));
bnr->set_admin_down(admin_down_);
bnr->set_passive(passive_);
bnr->set_peer_address(peer_address_string());
Expand Down
1 change: 1 addition & 0 deletions src/bgp/bgp_peer.h
Expand Up @@ -336,6 +336,7 @@ class BgpPeer : public IPeer {
void CustomClose();

void FillBgpNeighborFamilyAttributes(BgpNeighborResp *nbr) const;
void FillCloseInfo(BgpNeighborResp *resp) const;

std::string BytesToHexString(const u_int8_t *msg, size_t size);

Expand Down
18 changes: 17 additions & 1 deletion src/bgp/bgp_peer.sandesh
Expand Up @@ -41,11 +41,26 @@ struct ShowBgpNeighborFamily {
3: u32 prefix_limit;
}

struct PeerCloseInfo {
1: string state;
2: bool close_again;
3: u64 init;
4: u64 close;
5: u64 nested;
6: u64 deletes;
7: u64 stale;
8: u64 sweep;
9: u64 gr_timer;
10: u64 deleted_state_paths;
11: u64 deleted_paths;
12: u64 marked_state_paths;
}

struct BgpNeighborResp {
53: string instance_name;
1: string peer (link="BgpNeighborReq"); // Peer name
36: bool deleted; // Deletion in progress
43: string deleted_at;
43: string closed_at;
47: bool admin_down;
48: bool passive;
2: string peer_address (link="BgpNeighborReq");
Expand All @@ -60,6 +75,7 @@ struct BgpNeighborResp {
4: string local_address; // local ip address and port
26: string local_id;
5: u32 local_asn;
54: optional PeerCloseInfo peer_close_info;
9: optional string send_state; // in sync/not in sync
10: optional string last_event;
11: optional string last_state;
Expand Down

0 comments on commit 0ca972c

Please sign in to comment.