Hi cong, we increase the socket inuse in sk_allock ?

On Tue, Nov 14, 2017 at 1:58 PM, Cong Wang <xiyou.wangc...@gmail.com> wrote:
> On Mon, Nov 13, 2017 at 7:23 PM, 张军伟(基础平台部)
> <zhangjunweimar...@didichuxing.com> wrote:
>>
>>> On 14 Nov 2017, at 10:09, Cong Wang <xiyou.wangc...@gmail.com> wrote:
>>>
>>> On Mon, Nov 13, 2017 at 4:36 AM, Tonghao Zhang <xiangxia.m....@gmail.com> 
>>> wrote:
>>>> From: Tonghao Zhang <xiangxia.m....@gmail.com>
>>>>
>>>> This patch add a member in struct netns_core. and this is
>>>> a counter for socket_inuse in the _net_ namespace. The patch
>>>> will add/sub counter in the sock_alloc or sock_release. In
>>>> the sock_alloc, the private data of inode saves the special
>>>> _net_. When releasing it, we can access the special _net_ and
>>>> dec the counter of socket in that namespace.
>>>>
>>>> By the way, we dont use the 'current->nsproxy->net_ns' in the
>>>> sock_release. In one case,when one task exits, the 'do_exit'
>>>> may set the current->nsproxy NULL, and then call the sock_release.
>>>> Use the private data of inode, saving few bytes.
>>>
>>> Why do you need to hold netns refcnt for socket? sock already holds
>>> it, so you can just access it by sock_net(sock->sk) ?
>> I think you suggestion is
>> replace get_net(net) ===> with sock_net(sock->sk)
>
> Not literally, but essentially yes.
>
>
>>
>> If thus, I think it could not work.
>> Because sock->sk is assigned after sock_alloc.
>> What we change is done in sock_alloc.
>
> You don't have to do it in sock_alloc().
>
>
>> By the way, sock->sk may has been released(NULL) in sock_release.
>
> My point is since sock is always paired with a sk and sk already
> holds refcnt, you don't need to hold it again, it looks unnecessary.

Reply via email to