diff mbox series

[v3,20/21] phonet: exit_net cleanup check added

Message ID 23f507fd-576c-d1be-3531-3a98364eb9ba@virtuozzo.com
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series exit_net checks for objects initialized in net_init hook | expand

Commit Message

Vasily Averin Nov. 6, 2017, 1:25 p.m. UTC
Be sure that pndevs.list initialized in net_init hook was return
to initial state.

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 net/phonet/pn_dev.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Rémi Denis-Courmont Nov. 6, 2017, 7:37 p.m. UTC | #1
Le maanantaina 6. marraskuuta 2017, 16.25.54 EET Vasily Averin a écrit :
> Be sure that pndevs.list initialized in net_init hook was return
> to initial state.
> 
> Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
> ---
>  net/phonet/pn_dev.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
> index 2cb4c5d..f0ab85d 100644
> --- a/net/phonet/pn_dev.c
> +++ b/net/phonet/pn_dev.c
> @@ -331,7 +331,12 @@ static int __net_init phonet_init_net(struct net *net)
> 
>  static void __net_exit phonet_exit_net(struct net *net)
>  {
> +	struct phonet_net *pnn = phonet_pernet(net);
> +
>  	remove_proc_entry("phonet", net->proc_net);
> +	WARN_ONCE(!list_empty(&pnn->pndevs.list),
> +		  "net %x %s: pndevs.list is not empty\n",
> +		  net->ns.inum, __func__);
>  }
> 
>  static struct pernet_operations phonet_net_ops = {

In my opinon, tis is still utterly pointless. Really, what bug did this 
specific patch help to fix?

If you want to debug network namespaces, I have a feeling that the network 
namespace code is a better place to do so than individual protocol stacks.
Vasily Averin Nov. 12, 2017, 9:24 a.m. UTC | #2
On 2017-11-06 22:37, Rémi Denis-Courmont wrote:
> In my opinon, tis is still utterly pointless. Really, what bug did this 
> specific patch help to fix?

I'm maintainer of legacy OpenVz kernels, we release containers-ready kernels 15+ years,
they are widely used by hosting providers, usually they use 30-300 containers per node.
In this scenario if any of container causes the problem it affects many other.

For many years we got lot of strange memory corruptions and found lot of memory leaks
in namespace-fied subsytems.

These bugs are invisible on usual kernls, because init_net lives forever and never destroyed.
However they are quite important for systems running lott of independent namespaces,
that can be restarted many times without host admin assistance.
Each memory leak can be repeated many times and finally it enables OOM-killer 
that disables whole node. And nobody understand what's happen.

Such kind of checks allows to be sure that net namespace exit was clear and leaked nothing.

> If you want to debug network namespaces, I have a feeling that the network 
> namespace code is a better place to do so than individual protocol stacks.

Common network namespace code knows nothing about specific of each individual driver/subsystem.
I do not understand how it's possible to do it in common netns code.

Thank you,
	Vasily Averin
diff mbox series

Patch

diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index 2cb4c5d..f0ab85d 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -331,7 +331,12 @@  static int __net_init phonet_init_net(struct net *net)
 
 static void __net_exit phonet_exit_net(struct net *net)
 {
+	struct phonet_net *pnn = phonet_pernet(net);
+
 	remove_proc_entry("phonet", net->proc_net);
+	WARN_ONCE(!list_empty(&pnn->pndevs.list),
+		  "net %x %s: pndevs.list is not empty\n",
+		  net->ns.inum, __func__);
 }
 
 static struct pernet_operations phonet_net_ops = {