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, then it is possible to set NF_FLOW_HW flag once the flow entry has been offloaded. If this fails, GC will give it another offload try later. Fixes: 8b3646d6e0c4 ("net/sched: act_ct: Support refreshing the flow table entries") Signed-off-by: Pablo Neira Ayuso --- v2: re-target to nf-next, restore postponing NF_FLOW_HW bit net/netfilter/nf_flow_table_core.c | 11 ++--------- net/netfilter/nf_flow_table_offload.c | 6 +----- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c index 2f5df3bf3943..6ed542d1f57d 100644 --- a/net/netfilter/nf_flow_table_core.c +++ b/net/netfilter/nf_flow_table_core.c @@ -374,15 +374,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); @@ -656,6 +647,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); } } diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c index 44e4c6a64431..5955b520d0a2 100644 --- a/net/netfilter/nf_flow_table_offload.c +++ b/net/netfilter/nf_flow_table_offload.c @@ -984,7 +984,7 @@ static void flow_offload_work_add(struct flow_offload_work *offload) goto out; set_bit(IPS_HW_OFFLOAD_BIT, &offload->flow->ct->status); - + set_bit(NF_FLOW_HW, &offload->flow->flags); out: nf_flow_offload_destroy(flow_rule); } @@ -1129,10 +1129,6 @@ void nf_flow_offload_refresh(struct nf_flowtable *flowtable, void nf_flow_offload_add(struct nf_flowtable *flowtable, struct flow_offload *flow) { - if (nf_flow_offload_unsupported(flow)) - return; - - set_bit(NF_FLOW_HW, &flow->flags); nf_flow_offload_refresh(flowtable, flow); } -- 2.47.3