Skip to content

Commit

Permalink
Do not trigger prefix_limit_trigger_ from BgpPeer constructor
Browse files Browse the repository at this point in the history
Instead, trigger only when configuration changes are processed.
Also, trigger prefix_limit_trigger_ through a virtualized method so that
BgpMockPeers can override and skip the actual task trigger process.

Change-Id: I16befdad1cf43ef467da8dfc7d2994ddc005ca3a
Closes-Bug: 1706792
  • Loading branch information
ananth-at-camphor-networks committed Jul 27, 2017
1 parent 1da7a19 commit c89da83
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/bgp/bgp_peer.cc
Expand Up @@ -786,7 +786,6 @@ bool BgpPeer::ProcessFamilyAttributesConfig(const BgpNeighborConfig *config) {
STLDeleteValues(&family_attributes_list_);
family_attributes_list_ = family_attributes_list;
configured_families_ = config->GetAddressFamilies();
prefix_limit_trigger_.Set();
return (ret != 0);
}

Expand All @@ -798,6 +797,10 @@ void BgpPeer::ProcessEndpointConfig(const BgpNeighborConfig *config) {
}
}

void BgpPeer::TriggerPrefixLimitCheck() const {
prefix_limit_trigger_.Set();
}

void BgpPeer::ConfigUpdate(const BgpNeighborConfig *config) {
if (IsDeleted())
return;
Expand Down Expand Up @@ -911,6 +914,8 @@ void BgpPeer::ConfigUpdate(const BgpNeighborConfig *config) {
if (ProcessFamilyAttributesConfig(config)) {
peer_info.set_configured_families(configured_families_);
clear_session = true;
} else {
TriggerPrefixLimitCheck();
}

// Note that the state machine would have been stopped via SetAdminDown
Expand Down Expand Up @@ -1740,7 +1745,7 @@ void BgpPeer::UpdatePrimaryPathCount(int count, Address::Family family) const {
if (family_attributes_list_[family])
limit = family_attributes_list_[family]->prefix_limit;
if (limit && family_primary_path_count_[family] > limit)
prefix_limit_trigger_.Set();
TriggerPrefixLimitCheck();
}

void BgpPeer::EndOfRibTimerErrorHandler(string error_name,
Expand Down
1 change: 1 addition & 0 deletions src/bgp/bgp_peer.h
Expand Up @@ -405,6 +405,7 @@ class BgpPeer : public IPeer {
std::string BytesToHexString(const u_int8_t *msg, size_t size);
virtual uint32_t GetOutputQueueDepth(Address::Family family) const;
virtual time_t GetRTargetTableLastUpdatedTimeStamp() const;
virtual void TriggerPrefixLimitCheck() const;

static const std::vector<Address::Family> supported_families_;
BgpServer *server_;
Expand Down
1 change: 1 addition & 0 deletions src/bgp/test/bgp_membership_test.cc
Expand Up @@ -55,6 +55,7 @@ class BgpTestPeer : public BgpPeer {
}
uint64_t path_cb_count() const { return path_cb_count_; }
virtual bool IsInGRTimerWaitState() const { return false; }
void TriggerPrefixLimitCheck() const { }

private:
RibExportPolicy policy_;
Expand Down
1 change: 1 addition & 0 deletions src/bgp/test/bgp_msg_builder_test.cc
Expand Up @@ -30,6 +30,7 @@ class BgpPeerMock : public BgpPeer {
bool IsReady() const { return true; }
bool notification() const { return notification_; }
void set_notification(bool notification) { notification_ = notification; }
void TriggerPrefixLimitCheck() const { }
private:
bool notification_;
};
Expand Down
1 change: 1 addition & 0 deletions src/bgp/test/bgp_peer_test.cc
Expand Up @@ -64,6 +64,7 @@ class BgpPeerMock : public BgpPeer {
is_ready_ = is_ready;
}

void TriggerPrefixLimitCheck() const { }
virtual void StartKeepaliveTimerUnlocked() { }
virtual time_t GetEorSendTimerElapsedTime() const { return elapsed_; }
virtual bool IsReady() const { return is_ready_; }
Expand Down
1 change: 1 addition & 0 deletions src/bgp/test/bgp_session_test.cc
Expand Up @@ -39,6 +39,7 @@ class BgpPeerMock : public BgpPeer {
vector<int>::const_iterator end() const {
return sizes.end();
}
void TriggerPrefixLimitCheck() const { }

private:
vector<int> sizes;
Expand Down
1 change: 1 addition & 0 deletions src/bgp/test/bgp_update_rx_test.cc
Expand Up @@ -28,6 +28,7 @@ class BgpPeerMock : public BgpPeer {
}

bool IsReady() const { return true; }
void TriggerPrefixLimitCheck() const { }
};

class BgpUpdateRxTest : public ::testing::Test {
Expand Down

0 comments on commit c89da83

Please sign in to comment.