* [PATCH net,v2 1/2] ipvs: fix WARNING in __ip_vs_cleanup_batch()
2022-10-31 12:07 [PATCH net,v2 0/2] fix WARNING when removing file in ipvs Zhengchao Shao
@ 2022-10-31 12:07 ` Zhengchao Shao
2022-10-31 12:07 ` [PATCH net,v2 2/2] ipvs: fix WARNING in ip_vs_app_net_cleanup() Zhengchao Shao
2022-10-31 15:05 ` [PATCH net,v2 0/2] fix WARNING when removing file in ipvs Julian Anastasov
2 siblings, 0 replies; 4+ messages in thread
From: Zhengchao Shao @ 2022-10-31 12:07 UTC (permalink / raw)
To: netdev, lvs-devel, netfilter-devel, coreteam, horms, ja, pablo,
kadlec, fw, davem, edumazet, kuba, pabeni
Cc: hans.schillstrom, ebiederm, weiyongjun1, yuehaibing,
shaozhengchao
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: 61b1ab4583e2 ("IPVS: netns, add basic init per netns.")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
net/netfilter/ipvs/ip_vs_conn.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 8c04bb57dd6f..fa548c9e6aae 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -1447,20 +1447,36 @@ int __net_init ip_vs_conn_net_init(struct netns_ipvs *ipvs)
{
atomic_set(&ipvs->conn_count, 0);
- proc_create_net("ip_vs_conn", 0, ipvs->net->proc_net,
- &ip_vs_conn_seq_ops, sizeof(struct ip_vs_iter_state));
- proc_create_net("ip_vs_conn_sync", 0, ipvs->net->proc_net,
- &ip_vs_conn_sync_seq_ops,
- sizeof(struct ip_vs_iter_state));
+#ifdef CONFIG_PROC_FS
+ if (!proc_create_net("ip_vs_conn", 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,
+ sizeof(struct ip_vs_iter_state)))
+ goto err_conn_sync;
+#endif
+
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)
{
/* flush all the connection entries first */
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_sync", ipvs->net->proc_net);
+#endif
}
int __init ip_vs_conn_init(void)
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net,v2 2/2] ipvs: fix WARNING in ip_vs_app_net_cleanup()
2022-10-31 12:07 [PATCH net,v2 0/2] fix WARNING when removing file in ipvs Zhengchao Shao
2022-10-31 12:07 ` [PATCH net,v2 1/2] ipvs: fix WARNING in __ip_vs_cleanup_batch() Zhengchao Shao
@ 2022-10-31 12:07 ` Zhengchao Shao
2022-10-31 15:05 ` [PATCH net,v2 0/2] fix WARNING when removing file in ipvs Julian Anastasov
2 siblings, 0 replies; 4+ messages in thread
From: Zhengchao Shao @ 2022-10-31 12:07 UTC (permalink / raw)
To: netdev, lvs-devel, netfilter-devel, coreteam, horms, ja, pablo,
kadlec, fw, davem, edumazet, kuba, pabeni
Cc: hans.schillstrom, ebiederm, weiyongjun1, yuehaibing,
shaozhengchao
During the initialization of ip_vs_app_net_init(), if file ip_vs_app
fails to be created, the initialization is successful by default.
Therefore, the ip_vs_app file doesn't be found during the remove in
ip_vs_app_net_cleanup(). It will cause WRNING.
The following is the stack information:
name 'ip_vs_app'
WARNING: CPU: 1 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>
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: 457c4cbc5a3d ("[NET]: Make /proc/net per network namespace")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
net/netfilter/ipvs/ip_vs_app.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_app.c b/net/netfilter/ipvs/ip_vs_app.c
index f9b16f2b2219..fdacbc3c15be 100644
--- a/net/netfilter/ipvs/ip_vs_app.c
+++ b/net/netfilter/ipvs/ip_vs_app.c
@@ -599,13 +599,19 @@ static const struct seq_operations ip_vs_app_seq_ops = {
int __net_init ip_vs_app_net_init(struct netns_ipvs *ipvs)
{
INIT_LIST_HEAD(&ipvs->app_list);
- proc_create_net("ip_vs_app", 0, ipvs->net->proc_net, &ip_vs_app_seq_ops,
- sizeof(struct seq_net_private));
+#ifdef CONFIG_PROC_FS
+ if (!proc_create_net("ip_vs_app", 0, ipvs->net->proc_net,
+ &ip_vs_app_seq_ops,
+ sizeof(struct seq_net_private)))
+ return -ENOMEM;
+#endif
return 0;
}
void __net_exit ip_vs_app_net_cleanup(struct netns_ipvs *ipvs)
{
unregister_ip_vs_app(ipvs, NULL /* all */);
+#ifdef CONFIG_PROC_FS
remove_proc_entry("ip_vs_app", ipvs->net->proc_net);
+#endif
}
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net,v2 0/2] fix WARNING when removing file in ipvs
2022-10-31 12:07 [PATCH net,v2 0/2] fix WARNING when removing file in ipvs Zhengchao Shao
2022-10-31 12:07 ` [PATCH net,v2 1/2] ipvs: fix WARNING in __ip_vs_cleanup_batch() Zhengchao Shao
2022-10-31 12:07 ` [PATCH net,v2 2/2] ipvs: fix WARNING in ip_vs_app_net_cleanup() Zhengchao Shao
@ 2022-10-31 15:05 ` Julian Anastasov
2 siblings, 0 replies; 4+ messages in thread
From: Julian Anastasov @ 2022-10-31 15:05 UTC (permalink / raw)
To: Zhengchao Shao
Cc: netdev, lvs-devel, netfilter-devel, coreteam, Simon Horman, pablo,
kadlec, fw, weiyongjun1, yuehaibing
Hello,
On Mon, 31 Oct 2022, Zhengchao Shao wrote:
> When using strace for fault injection, some warnings are trigged when
> files are removed. This is because the file fails to be created during
> the initialization, but the initialization continues normally. Therefore,
> a WARNING is reported when the file is removed during the exit.
>
> ---
> v2: add macro isolation
> ---
> Zhengchao Shao (2):
> ipvs: fix WARNING in __ip_vs_cleanup_batch()
> ipvs: fix WARNING in ip_vs_app_net_cleanup()
Both patches in v2 look good to me, thanks!
Acked-by: Julian Anastasov <ja@ssi.bg>
> net/netfilter/ipvs/ip_vs_app.c | 10 ++++++++--
> net/netfilter/ipvs/ip_vs_conn.c | 26 +++++++++++++++++++++-----
> 2 files changed, 29 insertions(+), 7 deletions(-)
>
> --
> 2.17.1
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 4+ messages in thread