Skip to content

Commit

Permalink
Add missing locks in Agent UVE code
Browse files Browse the repository at this point in the history
(1)Acquire lock in VnUveEntry::ClearInterVnStats to prevent parallel access to
inter_vn_stats_ between kTaskFlowStatsCollector and kTaskDBExclude
(2)Acquire lock in InterfaceUveStatsTable::FipEntry to prevent parallel access to
interface_tree_ between kTaskFlowStatsCollector and kTaskDBExclude

Partial-Bug: #1641833
(cherry picked from commit 006c5e6)

Change-Id: I5a319892421664c5be23d6a2dc228e6c94271d3a
  • Loading branch information
ashoksr committed Mar 10, 2017
1 parent 63fed3c commit a24aa51
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/vnsw/agent/uve/interface_uve_stats_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ void InterfaceUveStatsTable::UpdatePortBitmap

InterfaceUveTable::FloatingIp * InterfaceUveStatsTable::FipEntry
(uint32_t fip, const string &vn, Interface *intf) {
tbb::mutex::scoped_lock lock(interface_tree_mutex_);
VmInterface *vmi = static_cast<VmInterface *>(intf);
InterfaceMap::iterator intf_it = interface_tree_.find(vmi->cfg_name());

Expand Down
3 changes: 2 additions & 1 deletion src/vnsw/agent/uve/vn_uve_entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ void VnUveEntry::UpdateInterVnStats(const string &dst_vn, uint64_t bytes,
}
}

/* Remove all the elements of map entry value which is a set */
void VnUveEntry::ClearInterVnStats() {
/* Remove all the elements of map entry value which is a set */
tbb::mutex::scoped_lock lock(mutex_);
VnStatsSet::iterator stats_it = inter_vn_stats_.begin();
VnStatsSet::iterator del_it;
while(stats_it != inter_vn_stats_.end()) {
Expand Down
7 changes: 6 additions & 1 deletion src/vnsw/agent/uve/vn_uve_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ class VnUveEntry : public VnUveEntryBase {
void BuildArpStats(const StatsManager::VrfStats *s,
UveVrfStats &vrf_stats) const;

/* For exclusion between kTaskFlowStatsCollector and Agent::Uve */
/* For exclusion between kTaskFlowStatsCollector and
* Agent::Uve/kTaskDBExclude. This is used to protect port_bitmap_ and
* inter_vn_stats_ from parallel access between
* 1. kTaskFlowStatsCollector and Agent::Uve
* 2. kTaskFlowStatsCollector and kTaskDBExclude
*/
tbb::mutex mutex_;
uint64_t in_bytes_;
uint64_t out_bytes_;
Expand Down

0 comments on commit a24aa51

Please sign in to comment.