[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6988251D-1B12-4A92-9465-743B9FEA4199@didichuxing.com>
Date: Tue, 14 Nov 2017 03:23:45 +0000
From: 张军伟(基础平台部)
<zhangjunweimartin@...ichuxing.com>
To: Cong Wang <xiyou.wangcong@...il.com>
CC: Tonghao Zhang <xiangxia.m.yue@...il.com>,
Linux Kernel Network Developers <netdev@...r.kernel.org>,
张同浩(基础平台部)
<zhangtonghao@...ichuxing.com>
Subject: Re: [PATCH v2 net-next] socket: Move the socket inuse to namespace.
> On 14 Nov 2017, at 10:09, Cong Wang <xiyou.wangcong@...il.com> wrote:
>
> On Mon, Nov 13, 2017 at 4:36 AM, Tonghao Zhang <xiangxia.m.yue@...il.com> wrote:
>> From: Tonghao Zhang <xiangxia.m.yue@...il.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)
If thus, I think it could not work.
Because sock->sk is assigned after sock_alloc.
What we change is done in sock_alloc.
By the way, sock->sk may has been released(NULL) in sock_release.
Powered by blists - more mailing lists