Skip to content

Commit

Permalink
Acquire flow locks in FlowMgmt task
Browse files Browse the repository at this point in the history
AddFlow API invoked from FlowMgmtManager::RequestHandler accesses fields of flow which is now done
under flow locks
Also, moved EnqueueUveAddEvent/EnqueueUveDeleteEvent from from FlowMgmt instance 1 to instance 0 task
to make it consistent with changes in other branches.

Change-Id: Ic2ad37e27fb3d1a873dbe4eab5f08852dbe04870
Closes-Bug: #1641833
  • Loading branch information
ashoksr committed May 30, 2017
1 parent ca19037 commit 99c5b07
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions src/vnsw/agent/pkt/flow_mgmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,27 +415,39 @@ bool FlowMgmtManager::RequestHandler(FlowMgmtRequestPtr req) {
switch (req->event()) {
case FlowMgmtRequest::UPDATE_FLOW: {
FlowEntry *flow = req->flow().get();
{
// Before processing event, set the request pointer in flow to
// NULL. This ensures flow-entry enqueues new request from now
// onwards
tbb::mutex::scoped_lock mutex(flow->mutex());
flow->set_flow_mgmt_request(NULL);
}
// Before processing event, set the request pointer in flow to
// NULL. This ensures flow-entry enqueues new request from now
// onwards
tbb::mutex::scoped_lock mutex(flow->mutex());
flow->set_flow_mgmt_request(NULL);

// Update flow-mgmt information based on flow-state
if (req->flow()->deleted() == false) {
if (flow->deleted() == false) {
FlowMgmtRequestPtr log_req(new FlowMgmtRequest
(FlowMgmtRequest::ADD_FLOW,
req->flow().get()));
log_queue_.Enqueue(log_req);

//Enqueue Add request to flow-stats-collector
agent_->flow_stats_manager()->AddEvent(req->flow());

//Enqueue Add request to UVE module for ACE stats
EnqueueUveAddEvent(flow);

AddFlow(req->flow());

} else {
FlowMgmtRequestPtr log_req(new FlowMgmtRequest
(FlowMgmtRequest::DELETE_FLOW,
req->flow().get(), req->params()));
log_queue_.Enqueue(log_req);

//Enqueue Delete request to flow-stats-collector
agent_->flow_stats_manager()->DeleteEvent(flow, req->params());

//Enqueue Delete request to UVE module for ACE stats
EnqueueUveDeleteEvent(flow);

DeleteFlow(req->flow(), req->params());
}
break;
Expand Down Expand Up @@ -492,25 +504,11 @@ bool FlowMgmtManager::LogHandler(FlowMgmtRequestPtr req) {
switch (req->event()) {
case FlowMgmtRequest::ADD_FLOW: {
LogFlowUnlocked(flow, "ADD");

//Enqueue Add request to flow-stats-collector
agent_->flow_stats_manager()->AddEvent(req->flow());

//Enqueue Add request to UVE module for ACE stats
EnqueueUveAddEvent(flow);

break;
}

case FlowMgmtRequest::DELETE_FLOW: {
LogFlowUnlocked(flow, "DEL");

//Enqueue Delete request to flow-stats-collector
agent_->flow_stats_manager()->DeleteEvent(flow, req->params());

//Enqueue Delete request to UVE module for ACE stats
EnqueueUveDeleteEvent(flow);

break;
}

Expand Down Expand Up @@ -538,7 +536,6 @@ void FlowMgmtManager::LogFlowUnlocked(FlowEntry *flow, const std::string &op) {
// Extract all the FlowMgmtKey for a flow
void FlowMgmtManager::MakeFlowMgmtKeyTree(FlowEntry *flow,
FlowMgmtKeyTree *tree) {
tbb::mutex::scoped_lock mutex(flow->mutex());
acl_flow_mgmt_tree_.ExtractKeys(flow, tree);
interface_flow_mgmt_tree_.ExtractKeys(flow, tree);
vn_flow_mgmt_tree_.ExtractKeys(flow, tree);
Expand Down

0 comments on commit 99c5b07

Please sign in to comment.