Skip to content

Commit

Permalink
Avoid redundant clear of peer when admin down is changed/set
Browse files Browse the repository at this point in the history
- Log a message when session is cleared dur to admin down
- Make sure that BgpPeerInfo UVE is updated on admin down change

Change-Id: I74303ce9d078a9b7f7f552b631a0c4eddce0799a
Closes-Bug: 1514670
  • Loading branch information
Nischal Sheth committed Nov 16, 2015
1 parent ab5f2c9 commit 7934ac4
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/bgp/bgp_peer.cc
Expand Up @@ -554,12 +554,14 @@ void BgpPeer::ConfigUpdate(const BgpNeighborConfig *config) {
return;

bool clear_session = false;
bool admin_down_changed = false;
BgpPeerInfoData peer_info;
peer_info.set_name(ToUVEKey());

if (admin_down_ != config->admin_down()) {
SetAdminState(config->admin_down());
peer_info.set_admin_down(admin_down_);
admin_down_changed = true;
}

if (passive_ != config->passive()) {
Expand All @@ -583,8 +585,8 @@ void BgpPeer::ConfigUpdate(const BgpNeighborConfig *config) {

// Check if there is any change in the configured address families.
if (ProcessFamilyAttributesConfig(config)) {
clear_session = true;
peer_info.set_configured_families(configured_families_);
clear_session = true;
}

BgpProto::BgpPeerType old_type = PeerType();
Expand Down Expand Up @@ -620,13 +622,20 @@ void BgpPeer::ConfigUpdate(const BgpNeighborConfig *config) {
clear_session = true;
}

if (clear_session) {
// Note that the state machine would have been stopped via SetAdminDown
// if admin down was set to true above. Further, it's not necessary to
// clear the peer if it's already admin down.
if (!admin_down_changed && !admin_down_ && clear_session) {
BGP_LOG_PEER(Config, this, SandeshLevel::SYS_INFO, BGP_LOG_FLAG_ALL,
BGP_PEER_DIR_NA,
"Session cleared due to configuration change");
BGPPeerInfo::Send(peer_info);
Clear(BgpProto::Notification::OtherConfigChange);
}

// Send the UVE as appropriate.
if (admin_down_changed || clear_session) {
BGPPeerInfo::Send(peer_info);
}
}

void BgpPeer::ClearConfig() {
Expand Down Expand Up @@ -765,9 +774,13 @@ BgpSession *BgpPeer::CreateSession() {
}

void BgpPeer::SetAdminState(bool down) {
if (admin_down_ != down) {
admin_down_ = down;
state_machine_->SetAdminState(down);
if (admin_down_ == down)
return;
admin_down_ = down;
state_machine_->SetAdminState(down);
if (admin_down_) {
BGP_LOG_PEER(Config, this, SandeshLevel::SYS_INFO, BGP_LOG_FLAG_ALL,
BGP_PEER_DIR_NA, "Session cleared due to admin down");
}
}

Expand Down

0 comments on commit 7934ac4

Please sign in to comment.