Skip to content

Commit 759eebb

Browse files
committed
netfilter: flowtable: add function to invoke garbage collection immediately
Expose nf_flow_table_gc_run() to force a garbage collector run from the offload infrastructure. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent e02f0d3 commit 759eebb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

include/net/netfilter/nf_flow_table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ void flow_offload_refresh(struct nf_flowtable *flow_table,
270270

271271
struct flow_offload_tuple_rhash *flow_offload_lookup(struct nf_flowtable *flow_table,
272272
struct flow_offload_tuple *tuple);
273+
void nf_flow_table_gc_run(struct nf_flowtable *flow_table);
273274
void nf_flow_table_gc_cleanup(struct nf_flowtable *flowtable,
274275
struct net_device *dev);
275276
void nf_flow_table_cleanup(struct net_device *dev);

net/netfilter/nf_flow_table_core.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,17 @@ static void nf_flow_offload_gc_step(struct nf_flowtable *flow_table,
437437
}
438438
}
439439

440+
void nf_flow_table_gc_run(struct nf_flowtable *flow_table)
441+
{
442+
nf_flow_table_iterate(flow_table, nf_flow_offload_gc_step, NULL);
443+
}
444+
440445
static void nf_flow_offload_work_gc(struct work_struct *work)
441446
{
442447
struct nf_flowtable *flow_table;
443448

444449
flow_table = container_of(work, struct nf_flowtable, gc_work.work);
445-
nf_flow_table_iterate(flow_table, nf_flow_offload_gc_step, NULL);
450+
nf_flow_table_gc_run(flow_table);
446451
queue_delayed_work(system_power_efficient_wq, &flow_table->gc_work, HZ);
447452
}
448453

@@ -601,10 +606,11 @@ void nf_flow_table_free(struct nf_flowtable *flow_table)
601606

602607
cancel_delayed_work_sync(&flow_table->gc_work);
603608
nf_flow_table_iterate(flow_table, nf_flow_table_do_cleanup, NULL);
604-
nf_flow_table_iterate(flow_table, nf_flow_offload_gc_step, NULL);
609+
nf_flow_table_gc_run(flow_table);
605610
nf_flow_table_offload_flush(flow_table);
606611
if (nf_flowtable_hw_offload(flow_table))
607-
nf_flow_table_iterate(flow_table, nf_flow_offload_gc_step, NULL);
612+
nf_flow_table_gc_run(flow_table);
613+
608614
rhashtable_destroy(&flow_table->rhashtable);
609615
}
610616
EXPORT_SYMBOL_GPL(nf_flow_table_free);

0 commit comments

Comments
 (0)