Skip to content

Commit

Permalink
Do not access esi segment_id from segment being erased
Browse files Browse the repository at this point in the history
boost::ptr_map::erase() API takes key argument by reference. Hence, by passing
segment->esi() as a reference to erase(), this key can be still accessed within
the boost container code while the segment that contains the key gets destroyed

Also fix a minor minor leak in bgp_evpn_aliasing_test.cc using scoped_ptr.

Change-Id: I2045699e103546a5fe3aef679b45c2a373326475
Closes-Bug: 1735558
  • Loading branch information
ananth-at-camphor-networks committed Nov 30, 2017
1 parent a2a861a commit 516bef0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/bgp/bgp_evpn.cc
Expand Up @@ -1043,7 +1043,8 @@ bool EvpnManager::ProcessSegmentDeleteSet() {
BOOST_FOREACH(EvpnSegment *segment, segment_delete_set_) {
if (segment->MayDelete()) {
segment_update_set_.erase(segment);
segment_map_.erase(segment->esi());
EthernetSegmentId esi = segment->esi();
segment_map_.erase(esi);
}
}
segment_delete_set_.clear();
Expand Down
5 changes: 3 additions & 2 deletions src/bgp/test/bgp_evpn_aliasing_test.cc
Expand Up @@ -147,7 +147,8 @@ class BgpEvpnAliasingTest : public ::testing::Test {
blue_ = static_cast<EvpnTable *>(db->FindTable("blue.evpn.0"));
blue_manager_ = blue_->GetEvpnManager();
RibExportPolicy policy(BgpProto::XMPP, RibExportPolicy::XMPP, 0, 0);
blue_ribout_ = blue_->RibOutLocate(server_->update_sender(), policy);
blue_ribout_.reset(
blue_->RibOutLocate(server_->update_sender(), policy));

CreateAllPeers();

Expand Down Expand Up @@ -462,7 +463,7 @@ class BgpEvpnAliasingTest : public ::testing::Test {
EvpnTable *blue_;
EvpnTable *master_;
EvpnManager *blue_manager_;
RibOut *blue_ribout_;
boost::scoped_ptr<RibOut> blue_ribout_;
vector<PeerMock *> bgp_peers_;
EthernetSegmentId esi_null_, esi1_, esi2_, esi3_;
};
Expand Down

0 comments on commit 516bef0

Please sign in to comment.