Skip to content

Commit

Permalink
Allocate hold array when the action is set as 'hold' in the flow tabl…
Browse files Browse the repository at this point in the history
…e entry

HOLD is an action that is allowed to be set in a flow entry. Agent can set HOLD
as action and expect the first packet to be trapped. To hold packets in an
entry there needs to be hold list (an array, rather). While this hold list is
allocated when a new flow is created by kernel, the hold list is freed once all
the cached packets are flushed. A subsequent 'HOLD' set needs to have the hold
list allocated so that packets can be cached.

Closes BUG: #1425992

Change-Id: Ic32a03f402278a351c72cb6a4f72bafdaad2149c
  • Loading branch information
anandhk-juniper committed Apr 2, 2015
1 parent f81d90a commit e5b7c91
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions dp-core/vr_flow.c
Expand Up @@ -449,8 +449,10 @@ vr_enqueue_flow(struct vrouter *router, struct vr_flow_entry *fe,
struct vr_flow_queue *vfq = fe->fe_hold_list;
struct vr_packet_node *pnode;

if (!vfq)
return -EINVAL;
if (!vfq) {
drop_reason = VP_DROP_FLOW_UNUSABLE;
goto drop;
}

i = __sync_fetch_and_add(&vfq->vfq_entries, 1);
if (i >= VR_MAX_FLOW_QUEUE_ENTRIES) {
Expand Down Expand Up @@ -1077,6 +1079,9 @@ vr_flush_entry(struct vrouter *router, struct vr_flow_entry *fe,
{
struct vr_flow_queue *vfq;

if (fe->fe_action == VR_FLOW_ACTION_HOLD)
return;

vfq = fe->fe_hold_list;
if (!vfq)
return;
Expand Down Expand Up @@ -1347,6 +1352,15 @@ vr_flow_set(struct vrouter *router, vr_flow_req *req)
fe = vr_add_flow_req(req, &fe_index);
if (!fe)
return -ENOSPC;
} else {
if ((req->fr_action == VR_FLOW_ACTION_HOLD) &&
(fe->fe_action != req->fr_action)) {
if (!fe->fe_hold_list) {
fe->fe_hold_list = vr_zalloc(sizeof(struct vr_flow_queue));
if (!fe->fe_hold_list)
return -ENOMEM;
}
}
}

vr_flow_set_mirror(router, req, fe);
Expand Down

0 comments on commit e5b7c91

Please sign in to comment.