Skip to content

Commit

Permalink
dpif-netdev: Fix a race condition in deletion of offloaded flows.
Browse files Browse the repository at this point in the history
In dp_netdev_pmd_remove_flow() we schedule the deletion of an
offloaded flow, if a mark has been assigned to the flow. But if
this occurs in the window in which the offload thread completes
offloading the flow and assigns a mark to the flow, then we miss
deleting the flow. This problem has been observed while adding
and deleting flows in a loop. To fix this, always enqueue flow
deletion regardless of the flow->mark being set.

Fixes: 241bad1("dpif-netdev: associate flow with a mark id")
Co-authored-by: Gaetan Rivet <[email protected]>
Signed-off-by: Gaetan Rivet <[email protected]>
Signed-off-by: Sriharsha Basavapatna <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
2 people authored and igsilya committed Feb 16, 2022
1 parent a81bb67 commit 7d8b6ab
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2929,6 +2929,10 @@ queue_netdev_flow_del(struct dp_netdev_pmd_thread *pmd,
{
struct dp_offload_thread_item *offload;

if (!netdev_is_flow_api_enabled()) {
return;
}

offload = dp_netdev_alloc_flow_offload(pmd, flow,
DP_NETDEV_FLOW_OFFLOAD_OP_DEL);
offload->timestamp = pmd->ctx.now;
Expand Down Expand Up @@ -3040,9 +3044,7 @@ dp_netdev_pmd_remove_flow(struct dp_netdev_pmd_thread *pmd,
dp_netdev_simple_match_remove(pmd, flow);
cmap_remove(&pmd->flow_table, node, dp_netdev_flow_hash(&flow->ufid));
ccmap_dec(&pmd->n_flows, odp_to_u32(in_port));
if (flow->mark != INVALID_FLOW_MARK) {
queue_netdev_flow_del(pmd, flow);
}
queue_netdev_flow_del(pmd, flow);
flow->dead = true;

dp_netdev_flow_unref(flow);
Expand Down

0 comments on commit 7d8b6ab

Please sign in to comment.