From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: David Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Willem de Bruijn <willemb@google.com>,
Pavel Emelyanov <xemul@openvz.org>,
Linux Kernel Network Developers <netdev@vger.kernel.org>
Subject: Re: [PATCH v6 2/3] sock: Move the socket inuse to namespace.
Date: Thu, 14 Dec 2017 09:22:07 +0800 [thread overview]
Message-ID: <CAMDZJNX2mQLeaR6by4RJgYg97DKqMOoR9aogJVQu0EVHedUaug@mail.gmail.com> (raw)
In-Reply-To: <CAM_iQpUQb-khaHfNnvvdey69ok-FzLHUs2MmHKo2hUO0BUOKyg@mail.gmail.com>
On Wed, Dec 13, 2017 at 2:04 AM, Cong Wang <xiyou.wangcong@gmail.com> wrote:
> On Sun, Dec 10, 2017 at 7:12 AM, Tonghao Zhang <xiangxia.m.yue@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.
next prev parent reply other threads:[~2017-12-14 1:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-10 15:12 [PATCH v6 1/3] sock: Change the netns_core member name Tonghao Zhang
2017-12-10 15:12 ` [PATCH v6 2/3] sock: Move the socket inuse to namespace Tonghao Zhang
2017-12-12 18:04 ` Cong Wang
2017-12-14 1:22 ` Tonghao Zhang [this message]
2017-12-10 15:12 ` [PATCH v6 3/3] sock: Hide unused variable when !CONFIG_PROC_FS Tonghao Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMDZJNX2mQLeaR6by4RJgYg97DKqMOoR9aogJVQu0EVHedUaug@mail.gmail.com \
--to=xiangxia.m.yue@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
--cc=xemul@openvz.org \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.