[CRIU] [PATCH 11/28] ns: Add top_net_ns global variable
Kirill Tkhai
ktkhai at virtuozzo.com
Wed Jun 7 01:11:32 MSK 2017
On 06.06.2017 20:48, Andrei Vagin wrote:
> On Mon, Jun 05, 2017 at 08:25:05PM +0300, Kirill Tkhai wrote:
>> It will be need for fast obtaining root_item's net_ns,
>> and to fixup old dumps.
>>
>> lookup_ns_by_id() can't fail otherwise it'd failed
>> in MARK_ROOT_NS().
>>
>> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
>> ---
>> criu/include/namespaces.h | 1 +
>> criu/namespaces.c | 2 ++
>> 2 files changed, 3 insertions(+)
>>
>> diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
>> index 631d6228a..4e06ebc0f 100644
>> --- a/criu/include/namespaces.h
>> +++ b/criu/include/namespaces.h
>> @@ -163,6 +163,7 @@ struct ns_id {
>> extern struct ns_id *ns_ids;
>> extern struct ns_id *top_pid_ns;
>> extern struct ns_id *root_user_ns;
> Pls, add a description what top_net_ns is and how we are going to use
> it?
Ok
>
>> +extern struct ns_id *top_net_ns;
>>
>> #define NS_DESC_ENTRY(_cflag, _str, _alt_str) \
>> { \
>> diff --git a/criu/namespaces.c b/criu/namespaces.c
>> index d73b2d9f9..ea8e3e391 100644
>> --- a/criu/namespaces.c
>> +++ b/criu/namespaces.c
>> @@ -895,6 +895,7 @@ static int set_ns_hookups(struct ns_id *ns)
>>
>> struct ns_id *top_pid_ns = NULL;
>> struct ns_id *root_user_ns = NULL;
>> +struct ns_id *top_net_ns = NULL;
>> /* Mapping NS_ROOT to NS_CRIU */
>> UsernsEntry *userns_entry;
>>
>> @@ -2158,6 +2159,7 @@ int set_ns_roots(void)
>> if (MARK_ROOT_NS(ids, net) || MARK_ROOT_NS(ids, ipc) || MARK_ROOT_NS(ids, uts) ||
>> MARK_ROOT_NS(ids, mnt) || MARK_ROOT_NS(ids, cgroup))
>> return -1;
>> + top_net_ns = lookup_ns_by_id(ids->net_ns_id, &net_ns_desc);
> It is a second lookup of ids->net_ns_id in this function, can we avoid
> it?
Sure, thanks
>
>> return 0;
>> }
>>
>>
More information about the CRIU
mailing list