From 966f27eeb0f508319d566091a7ae866eb56b8408 Mon Sep 17 00:00:00 2001 From: Prabhjot Singh Sethi Date: Sat, 27 Feb 2016 23:21:58 +0530 Subject: [PATCH] Disable Eviction of flow in Vrouter Vrouter will track tcp flags, but will not evict the flow entry once the session is closed and let vrouter agent look at the flag to delete the flow eventually. This is required till vrouter agent handles evict event in a more stable way Change-Id: I4aa0878f240e92988f8d84e054a2635852d40b7f Partial-Bug: 1550759 Vrouter to generate EEXIST error appropriately Vrouter to generate EEXIST error when flow add request failed due to race between agent and datapath, where flow entry was already created due to packet trap Closes-Bug: 1547501 Change-Id: I0d2073622b06998dd5778fb94749958afc09bac0 (cherry picked from commit c17b4d4c45270d63a704d7e0cd9e04c5f8e4ad4f) (cherry picked from commit b679020e0382a0c2f0bd8b4b84c22671441885df) Vrouter to return error for invalid flow op If a flow operation is requested for an index which is not active, vrouter should return an ENOENT error for such operation Closes-Bug: 1548678 Change-Id: I42bbd58f41a868b1ce630046ae40e911df0d9491 (cherry picked from commit 1cf37614abb25bca4a93e8101f1af68a77a59552) (cherry picked from commit 99763a1fa5509e4fe2384ee36bdb300bc26f1352) --- dp-core/vr_flow.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/dp-core/vr_flow.c b/dp-core/vr_flow.c index 9846fe0c9..992e30c76 100644 --- a/dp-core/vr_flow.c +++ b/dp-core/vr_flow.c @@ -806,8 +806,18 @@ vr_flow_action(struct vrouter *router, struct vr_flow_entry *fe, break; } + /* + * Eviction of Flow in vrouter add additional events to vrouter + * agent state machine making it complex and unstable, till + * agent is handling vrouter eviction appropriately, disabling + * eviction from vrouter. + * NOTE: Vrouter agent will look at VR_FLOW_TCP_DEAD flag to + * clear/evict flow immediately + */ +#if 0 if (fe->fe_tcp_flags & VR_FLOW_TCP_DEAD) vr_flow_mark_evict(router, fe); +#endif return result; } @@ -1557,6 +1567,15 @@ vr_flow_set_req_is_invalid(struct vrouter *router, vr_flow_req *req, goto invalid_req; } } + } else { + /* + * flow set request received with an index which is + * not active anymore, return ENOENT error + */ + if ((req->fr_flags & VR_FLOW_FLAG_ACTIVE) && !(req->fr_index < 0)) { + error = -ENOENT; + goto invalid_req; + } } if (req->fr_flags & VR_FLOW_FLAG_VRFT) { @@ -1681,7 +1700,7 @@ static int vr_flow_set(struct vrouter *router, vr_flow_req *req) { int ret; - unsigned int fe_index; + unsigned int fe_index = (unsigned int)-1; bool new_flow = false, modified = false; struct vr_flow_entry *fe = NULL, *rfe = NULL; @@ -1725,8 +1744,19 @@ vr_flow_set(struct vrouter *router, vr_flow_req *req) */ if (!fe) { fe = vr_add_flow_req(req, &fe_index); - if (!fe) + if (!fe) { + if (fe_index != (unsigned int)-1) { + /* + * add flow req failed to allocate an entry due to race + * between agent and datapath, where flow entry at fe_index + * was already created due to packet trap, return EEXIST + * error and allow agent to wait and handle flow add due to + * packet trap + */ + return -EEXIST; + } return -ENOSPC; + } new_flow = true; infop->vfti_added++;