netfilter: flowtable: do not hw offload flows in teardown state
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH v2 1/1 netfilter: flowtable: do not hw offload flows in teardown state
Sashiko reports that refreshing hw offload from packet path is racy since the flow might be already going away. Refresh the flow instead via GC worker to address this, ie. if hardware offload fails, next GC run will give this flow a chance to offload it to hardware.
Since commit 7c549fb7eecd ("netfilter: flowtable: generalize pending status bit"), GC skips flow entries that are still pending to be offloaded. Let's just check for the teardown status bit after the pending bit is set on to address this race.
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
v2: restrict this only for add/refresh.
net/netfilter/nf_flow_table_offload.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/netfilter/nf_flow_table_offload.c +6 -0
@@ -1123,6 +1123,12 @@ void nf_flow_offload_refresh(struct nf_flowtable *flowtable,if (!offload)return ; +if (test_bit (NF_FLOW_TEARDOWN , &flow->flags)) { +clear_bit (NF_FLOW_PENDING , &flow->flags); +kfree (offload); +return ; + } +flow_offload_queue_work (offload); }
Signature · 1 line
2.47.3