On Wed, Dec 13, 2017 at 2:04 AM, Cong Wang <xiyou.wangc...@gmail.com> wrote:
> On Sun, Dec 10, 2017 at 7:12 AM, Tonghao Zhang <xiangxia.m....@gmail.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.

Reply via email to