Skip to content

Commit

Permalink
Check Gen id for processing recompute events for flows
Browse files Browse the repository at this point in the history
it is possible that enqueued forward flow become reverse flow when
flows get evicted from vrouter and traffic is received for reverse flow,

made changes to pass gen_id also when flow is enquwqued for recompute
and when it gets processed for recompute , check whether gen id present
in the event and gen id of flow matches, if it does not match,
ignore the event.

Change-Id: Ib647a157ecd852a3520a90ffba5f392ae3b33e1e
Closes-Bug: #1768322
(cherry picked from commit e5df8e0)
  • Loading branch information
Sangarshan committed Jul 23, 2018
1 parent ac4e397 commit c065431
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/vnsw/agent/pkt/flow_proto.cc
Expand Up @@ -426,11 +426,28 @@ bool FlowProto::FlowEventHandler(FlowEvent *req, FlowTable *table) {

case FlowEvent::FLOW_MESSAGE: {
FlowEntry *flow = req->flow();
FlowTaskMsg *flow_msg = new FlowTaskMsg(flow);
PktInfoPtr pkt_info(new PktInfo(PktHandler::FLOW, flow_msg));
FlowHandler *handler = new FlowHandler(agent(), pkt_info, io_,
// process event only for forward flow with same gen_id
// it may happen that after enqueued for recompute,
// flow become reverse flow when the following sequence of
// events occur.
// 1. route is changed , flow is enqueued for recompute
// 2. flow get evicted in vrouter
// 3. traffic is received for reverse flow and get the same flow handle
// 4. since flow handle is same , existing flow entries in agent won't
// be deleted but forward flow become reverse and vice versa
// added check to process events only if gen id matches,
// otherwise ignore it. added assertion not to process reverseflow
// at this stage as we only enqueue forward flows.

if ((flow->flow_handle() == req->flow_handle()) &&
(flow->gen_id() == req->gen_id())) {
assert(flow->is_flags_set(FlowEntry::ReverseFlow) == false);
FlowTaskMsg *flow_msg = new FlowTaskMsg(flow);
PktInfoPtr pkt_info(new PktInfo(PktHandler::FLOW, flow_msg));
FlowHandler *handler = new FlowHandler(agent(), pkt_info, io_,
this, table->table_index());
RunProtoHandler(handler);
RunProtoHandler(handler);
}
break;
}

Expand Down Expand Up @@ -607,7 +624,8 @@ void FlowProto::KSyncEventRequest(KSyncEntry *ksync_entry,
}

void FlowProto::MessageRequest(FlowEntry *flow) {
EnqueueFlowEvent(new FlowEvent(FlowEvent::FLOW_MESSAGE, flow));
EnqueueFlowEvent(new FlowEvent(FlowEvent::FLOW_MESSAGE, flow,
flow->flow_handle(), flow->gen_id()));
return;
}

Expand Down

0 comments on commit c065431

Please sign in to comment.