1 From: Pablo Neira Ayuso <pablo@netfilter.org>
2 Date: Thu, 1 Feb 2018 18:49:00 +0100
3 Subject: [PATCH] netfilter: nft_flow_offload: wait for garbage collector
6 If netdevice goes down, then flowtable entries are scheduled to be
7 removed. Wait for garbage collector to have a chance to run so it can
8 delete them from the hashtable.
10 The flush call might sleep, so hold the nfnl mutex from
11 nft_flow_table_iterate() instead of rcu read side lock. The use of the
12 nfnl mutex is also implicitly fixing races between updates via nfnetlink
15 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
18 --- a/net/netfilter/nf_tables_api.c
19 +++ b/net/netfilter/nf_tables_api.c
20 @@ -4818,13 +4818,13 @@ void nft_flow_table_iterate(struct net *
21 struct nft_flowtable *flowtable;
22 const struct nft_table *table;
25 - list_for_each_entry_rcu(table, &net->nft.tables, list) {
26 - list_for_each_entry_rcu(flowtable, &table->flowtables, list) {
27 + nfnl_lock(NFNL_SUBSYS_NFTABLES);
28 + list_for_each_entry(table, &net->nft.tables, list) {
29 + list_for_each_entry(flowtable, &table->flowtables, list) {
30 iter(&flowtable->data, data);
34 + nfnl_unlock(NFNL_SUBSYS_NFTABLES);
36 EXPORT_SYMBOL_GPL(nft_flow_table_iterate);
38 --- a/net/netfilter/nft_flow_offload.c
39 +++ b/net/netfilter/nft_flow_offload.c
40 @@ -208,6 +208,7 @@ static void nft_flow_offload_iterate_cle
43 nf_flow_table_iterate(flowtable, flow_offload_iterate_cleanup, data);
44 + flush_delayed_work(&flowtable->gc_work);
47 static int flow_offload_netdev_event(struct notifier_block *this,