Commit 3d00c6a0 authored by Zhengchao Shao's avatar Zhengchao Shao Committed by Pablo Neira Ayuso

ipvs: fix WARNING in __ip_vs_cleanup_batch()

During the initialization of ip_vs_conn_net_init(), if file ip_vs_conn
or ip_vs_conn_sync fails to be created, the initialization is successful
by default. Therefore, the ip_vs_conn or ip_vs_conn_sync file doesn't
be found during the remove.

The following is the stack information:
name 'ip_vs_conn_sync'
WARNING: CPU: 3 PID: 9 at fs/proc/generic.c:712
remove_proc_entry+0x389/0x460
Modules linked in:
Workqueue: netns cleanup_net
RIP: 0010:remove_proc_entry+0x389/0x460
Call Trace:
<TASK>
__ip_vs_cleanup_batch+0x7d/0x120
ops_exit_list+0x125/0x170
cleanup_net+0x4ea/0xb00
process_one_work+0x9bf/0x1710
worker_thread+0x665/0x1080
kthread+0x2e4/0x3a0
ret_from_fork+0x1f/0x30
</TASK>

Fixes: 61b1ab45 ("IPVS: netns, add basic init per netns.")
Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
Acked-by: default avatarJulian Anastasov <ja@ssi.bg>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 5c26159c
...@@ -1447,20 +1447,36 @@ int __net_init ip_vs_conn_net_init(struct netns_ipvs *ipvs) ...@@ -1447,20 +1447,36 @@ int __net_init ip_vs_conn_net_init(struct netns_ipvs *ipvs)
{ {
atomic_set(&ipvs->conn_count, 0); atomic_set(&ipvs->conn_count, 0);
proc_create_net("ip_vs_conn", 0, ipvs->net->proc_net, #ifdef CONFIG_PROC_FS
&ip_vs_conn_seq_ops, sizeof(struct ip_vs_iter_state)); if (!proc_create_net("ip_vs_conn", 0, ipvs->net->proc_net,
proc_create_net("ip_vs_conn_sync", 0, ipvs->net->proc_net, &ip_vs_conn_seq_ops,
sizeof(struct ip_vs_iter_state)))
goto err_conn;
if (!proc_create_net("ip_vs_conn_sync", 0, ipvs->net->proc_net,
&ip_vs_conn_sync_seq_ops, &ip_vs_conn_sync_seq_ops,
sizeof(struct ip_vs_iter_state)); sizeof(struct ip_vs_iter_state)))
goto err_conn_sync;
#endif
return 0; return 0;
#ifdef CONFIG_PROC_FS
err_conn_sync:
remove_proc_entry("ip_vs_conn", ipvs->net->proc_net);
err_conn:
return -ENOMEM;
#endif
} }
void __net_exit ip_vs_conn_net_cleanup(struct netns_ipvs *ipvs) void __net_exit ip_vs_conn_net_cleanup(struct netns_ipvs *ipvs)
{ {
/* flush all the connection entries first */ /* flush all the connection entries first */
ip_vs_conn_flush(ipvs); ip_vs_conn_flush(ipvs);
#ifdef CONFIG_PROC_FS
remove_proc_entry("ip_vs_conn", ipvs->net->proc_net); remove_proc_entry("ip_vs_conn", ipvs->net->proc_net);
remove_proc_entry("ip_vs_conn_sync", ipvs->net->proc_net); remove_proc_entry("ip_vs_conn_sync", ipvs->net->proc_net);
#endif
} }
int __init ip_vs_conn_init(void) int __init ip_vs_conn_init(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment