Skip to contentSkip to conversation

netfilter: flowtable: do not hw offload flows in teardown state

PATCH New Pablo Neira Ayuso 1 participant 1 message Oct 16

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 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.

---
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
index 5aed013d6468..2b9446207cc0 100644
@@ -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