[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMDZJNX2mQLeaR6by4RJgYg97DKqMOoR9aogJVQu0EVHedUaug@mail.gmail.com>
Date: Thu, 14 Dec 2017 09:22:07 +0800
From: Tonghao Zhang <xiangxia.m.yue@...il.com>
To: Cong Wang <xiyou.wangcong@...il.com>
Cc: David Miller <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Willem de Bruijn <willemb@...gle.com>,
Pavel Emelyanov <xemul@...nvz.org>,
Linux Kernel Network Developers <netdev@...r.kernel.org>
Subject: Re: [PATCH v6 2/3] sock: Move the socket inuse to namespace.
On Wed, Dec 13, 2017 at 2:04 AM, Cong Wang <xiyou.wangcong@...il.com> wrote:
> On Sun, Dec 10, 2017 at 7:12 AM, Tonghao Zhang <xiangxia.m.yue@...il.com> wrote:
>> diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
>> index b797832..6c191fb 100644
>> --- a/net/core/net_namespace.c
>> +++ b/net/core/net_namespace.c
>> @@ -363,6 +363,13 @@ static struct net *net_alloc(void)
>> if (!net)
>> goto out_free;
>>
>> +#ifdef CONFIG_PROC_FS
>> + net->core.sock_inuse = alloc_percpu(int);
>> + if (!net->core.sock_inuse) {
>> + kmem_cache_free(net_cachep, net);
>> + goto out_free;
>> + }
>> +#endif
>> rcu_assign_pointer(net->gen, ng);
>> out:
>> return net;
>> @@ -374,6 +381,9 @@ static struct net *net_alloc(void)
>>
>> static void net_free(struct net *net)
>> {
>> +#ifdef CONFIG_PROC_FS
>> + free_percpu(net->core.sock_inuse);
>> +#endif
>> kfree(rcu_access_pointer(net->gen));
>> kmem_cache_free(net_cachep, net);
>> }
>
> Putting socket code in net_namespace.c doesn't look good.
hi cong,
Thanks for your work. If we dont alloc the in the net_alloc, it's
better to counter the sock for userspace
while the sock created in kernel will be omitted.
Powered by blists - more mailing lists