Skip to content

Commit

Permalink
Fix parallel access to flow from LogHandler
Browse files Browse the repository at this point in the history
1. Need to take lock for flow in LogHandler
2. Handle EVICT_FLOW event in FlowProto::GetToken

Change-Id: I4b97265c2d077c7f4a66e1a91d9d21cfd3267b6d
Closes-Bug: #1571453
  • Loading branch information
praveenkv committed Apr 18, 2016
1 parent d58f5da commit c5be183
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/vnsw/agent/pkt/flow_mgmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,11 @@ bool FlowMgmtManager::DBRequestHandler(FlowMgmtRequestPtr req) {
}

bool FlowMgmtManager::LogHandler(FlowMgmtRequestPtr req) {
FlowEntry *flow = req->flow().get();
tbb::mutex::scoped_lock mutex(flow->mutex());
switch (req->event()) {
case FlowMgmtRequest::ADD_FLOW: {
FlowEntry *flow = req->flow().get();
LogFlow(flow, "ADD");
LogFlowUnlocked(flow, "ADD");

//Enqueue Add request to flow-stats-collector
agent_->flow_stats_manager()->AddEvent(req->flow());
Expand All @@ -447,8 +448,7 @@ bool FlowMgmtManager::LogHandler(FlowMgmtRequestPtr req) {
}

case FlowMgmtRequest::DELETE_FLOW: {
FlowEntry *flow = req->flow().get();
LogFlow(flow, "DEL");
LogFlowUnlocked(flow, "DEL");

//Enqueue Delete request to flow-stats-collector
agent_->flow_stats_manager()->DeleteEvent(flow, req->params());
Expand All @@ -472,9 +472,8 @@ void FlowMgmtManager::RetryVrfDelete(uint32_t vrf_id) {
}

// Extract all the FlowMgmtKey for a flow
void FlowMgmtManager::LogFlow(FlowEntry *flow, const std::string &op) {
void FlowMgmtManager::LogFlowUnlocked(FlowEntry *flow, const std::string &op) {
FlowInfo trace;
tbb::mutex::scoped_lock mutex(flow->mutex());
flow->FillFlowInfo(trace);
FLOW_TRACE(Trace, op, trace);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/pkt/flow_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ class FlowMgmtManager {
FlowEntryInfo *LocateFlowEntryInfo(FlowEntryPtr &flow);
void DeleteFlowEntryInfo(FlowEntryPtr &flow);
void MakeFlowMgmtKeyTree(FlowEntry *flow, FlowMgmtKeyTree *tree);
void LogFlow(FlowEntry *flow, const std::string &op);
void LogFlowUnlocked(FlowEntry *flow, const std::string &op);
void SetAceSandeshData(const AclDBEntry *acl, AclFlowCountResp &data,
int ace_id);
void SetAclFlowSandeshData(const AclDBEntry *acl, AclFlowResp &data,
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/pkt/flow_proto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ FlowTokenPtr FlowProto::GetToken(FlowEvent::Event event) {
return del_tokens_.GetToken(NULL);
break;

// FIXME: Remove this post testing
case FlowEvent::EVICT_FLOW:
case FlowEvent::INVALID:
break;

Expand Down

0 comments on commit c5be183

Please sign in to comment.