Skip to content

Commit 3d00c6a

Browse files
zhengchaoshaoummakynes
authored andcommitted
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: 61b1ab4 ("IPVS: netns, add basic init per netns.") Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com> Acked-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 5c26159 commit 3d00c6a

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

net/netfilter/ipvs/ip_vs_conn.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,20 +1447,36 @@ int __net_init ip_vs_conn_net_init(struct netns_ipvs *ipvs)
14471447
{
14481448
atomic_set(&ipvs->conn_count, 0);
14491449

1450-
proc_create_net("ip_vs_conn", 0, ipvs->net->proc_net,
1451-
&ip_vs_conn_seq_ops, sizeof(struct ip_vs_iter_state));
1452-
proc_create_net("ip_vs_conn_sync", 0, ipvs->net->proc_net,
1453-
&ip_vs_conn_sync_seq_ops,
1454-
sizeof(struct ip_vs_iter_state));
1450+
#ifdef CONFIG_PROC_FS
1451+
if (!proc_create_net("ip_vs_conn", 0, ipvs->net->proc_net,
1452+
&ip_vs_conn_seq_ops,
1453+
sizeof(struct ip_vs_iter_state)))
1454+
goto err_conn;
1455+
1456+
if (!proc_create_net("ip_vs_conn_sync", 0, ipvs->net->proc_net,
1457+
&ip_vs_conn_sync_seq_ops,
1458+
sizeof(struct ip_vs_iter_state)))
1459+
goto err_conn_sync;
1460+
#endif
1461+
14551462
return 0;
1463+
1464+
#ifdef CONFIG_PROC_FS
1465+
err_conn_sync:
1466+
remove_proc_entry("ip_vs_conn", ipvs->net->proc_net);
1467+
err_conn:
1468+
return -ENOMEM;
1469+
#endif
14561470
}
14571471

14581472
void __net_exit ip_vs_conn_net_cleanup(struct netns_ipvs *ipvs)
14591473
{
14601474
/* flush all the connection entries first */
14611475
ip_vs_conn_flush(ipvs);
1476+
#ifdef CONFIG_PROC_FS
14621477
remove_proc_entry("ip_vs_conn", ipvs->net->proc_net);
14631478
remove_proc_entry("ip_vs_conn_sync", ipvs->net->proc_net);
1479+
#endif
14641480
}
14651481

14661482
int __init ip_vs_conn_init(void)

0 commit comments

Comments
 (0)