Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1869611ybg; Thu, 30 Jul 2020 05:01:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymBgZraqAOUdMJPstVThJl1efGAnQ8m/AF9mgidAcqMUk1SHSqSSSJXP+tK/uHo1IktK0p X-Received: by 2002:a50:d9cb:: with SMTP id x11mr2207095edj.93.1596110517840; Thu, 30 Jul 2020 05:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596110517; cv=none; d=google.com; s=arc-20160816; b=aw7BIOXKT489Ui8TvhB/xPGOv+KRKbwlcBr3USHvXj5IHXMjth04M57XqO7pFAiDe8 ejFA5sDBmZ3W+dEZ0AGcBMzB3P33MTYsHcKzzHy34TmDeyQveweZBWAlajgUyTQEExl7 24t6FxomJd8Fu1eIRohPqCmhQOxXYFfpETbOB/JRI+XvsgMh1lc14C4HeWjZC1UROpE/ 2qg86aNrhToL/MWHaCO5zFZ1zTIjIFAsB6zwhKci+Ob31JkBvagA3QkmxhkHgvRb7adr E8fzQLQk5EUy7OYuwvKmcLazFA3LLY/NMrcrhNAYxG0gRqzwR8HnuEdC4eRcw8OJEolh eyEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject; bh=3LyBd9JhyzllQ57LMqiZ/rF7aA6fzTiKRLV78KoSk4E=; b=iR1BJaj49Csc1M3e/naubRlEZ5d3kIwyN/eULW6aMDBZ04UWxLLHg0QSlgpnB2XTNB suxtZp/weM6+654cTvHdxFfHfEI6dAwnjbpQlBNpBMmfQ16ykLDrDZVFJcgxbDTYQdaK LAlDFkPIHT14BAFy80ibYqgAIaJKBZlJ3Jm1M7UOVdkFOXWE2tFqfFqfWwOnB1Y4kEHZ HBjLq/xMFtfBlTS42+ejde1fbkUVVphRAogisWR0woAMb3A+uuKt9Br2c5vOrlA5CZTd swEGUBRNRpg37T1t3S0rFeU//0t+2I1oir4g8Bz2DS1aYfarD/ZFVwvhi3YUFHXORlFA qOXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cf15si3062103edb.350.2020.07.30.05.01.35; Thu, 30 Jul 2020 05:01:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728376AbgG3MAo (ORCPT + 99 others); Thu, 30 Jul 2020 08:00:44 -0400 Received: from relay.sw.ru ([185.231.240.75]:56914 "EHLO relay3.sw.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728318AbgG3MAk (ORCPT ); Thu, 30 Jul 2020 08:00:40 -0400 Received: from [192.168.15.64] (helo=localhost.localdomain) by relay3.sw.ru with esmtp (Exim 4.93) (envelope-from ) id 1k17ET-0002yZ-U7; Thu, 30 Jul 2020 15:00:21 +0300 Subject: [PATCH 14/23] net: Add net namespaces into ns_idr From: Kirill Tkhai To: viro@zeniv.linux.org.uk, adobriyan@gmail.com, davem@davemloft.net, ebiederm@xmission.com, akpm@linux-foundation.org, christian.brauner@ubuntu.com, areber@redhat.com, serge@hallyn.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, ktkhai@virtuozzo.com Date: Thu, 30 Jul 2020 15:00:35 +0300 Message-ID: <159611043578.535980.14525601933828392397.stgit@localhost.localdomain> In-Reply-To: <159611007271.535980.15362304262237658692.stgit@localhost.localdomain> References: <159611007271.535980.15362304262237658692.stgit@localhost.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now they are exposed in /proc/namespace/ directory. We already wait RCU grace period in cleanup_net() before pernet_operations exit, so ns_idr_unregister() works as expected. Signed-off-by: Kirill Tkhai --- net/core/net_namespace.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 5f658cbedd34..f78655a670e5 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -701,14 +701,24 @@ EXPORT_SYMBOL_GPL(get_net_ns_by_pid); static __net_init int net_ns_net_init(struct net *net) { + int ret; #ifdef CONFIG_NET_NS net->ns.ops = &netns_operations; #endif - return ns_alloc_inum(&net->ns); + ret = ns_alloc_inum(&net->ns); + if (ret) + return ret; + + ret = ns_idr_register(&net->ns); + if (ret < 0) + ns_free_inum(&net->ns); + + return ret; } static __net_exit void net_ns_net_exit(struct net *net) { + ns_idr_unregister(&net->ns); ns_free_inum(&net->ns); }