Skip to contentSkip to conversation

netfilter: flowtable: move hardware offload refresh to GC worker

PATCH New Pablo Neira Ayuso 1 participant 1 message Oct 15

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: flowtable: move hardware offload refresh to GC worker

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.

Fixes 8b3646d6e0c4 ("net/sched: act_ct: Support refreshing the flow table entries")

---
This replaces:
[PATCH nf] netfilter: flowtable: set on NF_FLOW_HW once flow has been offloaded

 net/netfilter/nf_flow_table_core.c    | 11 ++---------
 net/netfilter/nf_flow_table_offload.c |  3 +++
 2 files changed, 5 insertions(+), 9 deletions(-)
net/netfilter/nf_flow_table_core.c +2 -9
index 36bbc7be2f74..ba18c8f0e1b1 100644
@@ -372,15 +372,6 @@ void flow_offload_refresh(struct nf_flowtable *flow_table,
 	timeout = nf_flowtable_time_stamp + flow_offload_get_timeout(flow);
 	if (force || timeout - READ_ONCE(flow->timeout) > HZ)
 		WRITE_ONCE(flow->timeout, timeout);
-	else
-		return;
-
-	if (likely(!nf_flowtable_hw_offload(flow_table)) ||
-	    test_bit(NF_FLOW_CLOSING, &flow->flags))
-		return;
-
-	if (test_bit(NF_FLOW_HW, &flow->flags))
-		nf_flow_offload_refresh(flow_table, flow);
 }
 EXPORT_SYMBOL_GPL(flow_offload_refresh);
 
@@ -608,6 +599,8 @@ static void nf_flow_offload_gc_step(struct nf_flowtable *flow_table,
 		nf_flow_offload_del(flow_table, flow);
 	} else if (test_bit(NF_FLOW_HW, &flow->flags)) {
 		nf_flow_offload_stats(flow_table, flow);
+	} else if (nf_flowtable_hw_offload(flow_table)) {
+		nf_flow_offload_refresh(flow_table, flow);
 	}
 }
 
net/netfilter/nf_flow_table_offload.c +3 -0
index 4365859220e6..aa6fa2196765 100644
@@ -1116,6 +1116,9 @@ void nf_flow_offload_refresh(struct nf_flowtable *flowtable,
 {
 	struct flow_offload_work *offload;
 
+	if (nf_flow_offload_unsupported(flow))
+		return;
+
 	offload = nf_flow_offload_work_alloc(flowtable, flow, FLOW_CLS_REPLACE);
 	if (!offload)
 		return;
Signature · 1 line
2.47.3