1 From: Vasily Averin <vvs@virtuozzo.com>
2 Date: Sun, 12 Nov 2017 14:32:37 +0300
3 Subject: [PATCH] netfilter: exit_net cleanup check added
5 Be sure that lists initialized in net_init hook was return to initial
8 Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
9 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
12 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
13 +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
14 @@ -835,6 +835,7 @@ static void clusterip_net_exit(struct ne
17 nf_unregister_net_hook(net, &cip_arp_ops);
18 + WARN_ON_ONCE(!list_empty(&cn->configs));
21 static struct pernet_operations clusterip_net_ops = {
22 --- a/net/netfilter/nf_tables_api.c
23 +++ b/net/netfilter/nf_tables_api.c
24 @@ -6573,6 +6573,12 @@ static int __net_init nf_tables_init_net
28 +static void __net_exit nf_tables_exit_net(struct net *net)
30 + WARN_ON_ONCE(!list_empty(&net->nft.af_info));
31 + WARN_ON_ONCE(!list_empty(&net->nft.commit_list));
34 int __nft_release_basechain(struct nft_ctx *ctx)
36 struct nft_rule *rule, *nr;
37 @@ -6650,6 +6656,7 @@ static void __nft_release_afinfo(struct
39 static struct pernet_operations nf_tables_net_ops = {
40 .init = nf_tables_init_net,
41 + .exit = nf_tables_exit_net,
44 static int __init nf_tables_module_init(void)
45 --- a/net/netfilter/nfnetlink_log.c
46 +++ b/net/netfilter/nfnetlink_log.c
47 @@ -1094,10 +1094,15 @@ static int __net_init nfnl_log_net_init(
49 static void __net_exit nfnl_log_net_exit(struct net *net)
51 + struct nfnl_log_net *log = nfnl_log_pernet(net);
55 remove_proc_entry("nfnetlink_log", net->nf.proc_netfilter);
57 nf_log_unset(net, &nfulnl_logger);
58 + for (i = 0; i < INSTANCE_BUCKETS; i++)
59 + WARN_ON_ONCE(!hlist_empty(&log->instance_table[i]));
62 static struct pernet_operations nfnl_log_net_ops = {
63 --- a/net/netfilter/nfnetlink_queue.c
64 +++ b/net/netfilter/nfnetlink_queue.c
65 @@ -1511,10 +1511,15 @@ static int __net_init nfnl_queue_net_ini
67 static void __net_exit nfnl_queue_net_exit(struct net *net)
69 + struct nfnl_queue_net *q = nfnl_queue_pernet(net);
72 nf_unregister_queue_handler(net);
74 remove_proc_entry("nfnetlink_queue", net->nf.proc_netfilter);
76 + for (i = 0; i < INSTANCE_BUCKETS; i++)
77 + WARN_ON_ONCE(!hlist_empty(&q->instance_table[i]));
80 static void nfnl_queue_net_exit_batch(struct list_head *net_exit_list)
81 --- a/net/netfilter/x_tables.c
82 +++ b/net/netfilter/x_tables.c
83 @@ -1784,8 +1784,17 @@ static int __net_init xt_net_init(struct
87 +static void __net_exit xt_net_exit(struct net *net)
91 + for (i = 0; i < NFPROTO_NUMPROTO; i++)
92 + WARN_ON_ONCE(!list_empty(&net->xt.tables[i]));
95 static struct pernet_operations xt_net_ops = {
97 + .exit = xt_net_exit,
100 static int __init xt_init(void)