Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1005382ybh; Tue, 21 Jul 2020 13:18:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6DBuPM/vQ0dHyhqMQeEir+ag1QYYhVJP4O4A8Vaq8kfWYo7XiwLPu8lOY/ev2dfsuY3B+ X-Received: by 2002:a17:906:8392:: with SMTP id p18mr28547977ejx.24.1595362730006; Tue, 21 Jul 2020 13:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595362730; cv=none; d=google.com; s=arc-20160816; b=QNVqrhpZgR+hFV1U44Yn5AGhUwaI+nS3dRbYR2coLjVnofWdQ+KjZCRaOJXinGynX2 pOAQIdEmg0KILrnD2PGhg7GdwGXxK36Tb3BjuATxEYL5CQ09ixXrdB2DdsqCdVRVK917 F22KvGGbFdU9YAQqg7uSQKVjkMtH1aXvdZgj2qNb2v59LkNdqA99AFSA+G1d04hZl9uR 3SEBBq5zGHrjc8EjJ7kGApc2AyFgq9hwyjpRW1rFhuSdxHFMTtX9f1h0pWBv11Mo/Ehv m1tUHq+8HMdXZSp7V78WsZnlXy33dpBUlgRF8k9LQvCP0l+v9DFKnNwFsH3VKG+YHxdF YMGw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=wuejzYV14NfhivJPX5dGwtYlxdOzmu6dKgyDLhSJcfg=; b=nBABYkjEpzJXQciqMcz0TdS7/MOaEysrhKY2Cm6qkc1YIT3Im83iWg27JDDSp+ghqE tcbRgPowiCXAjZu2K+ePEFqB4bvLNRMMcE/3jXbJsttioGcyrtDrDEJGtyhB8QsSOCzc DP5DDozp27BP2n88OTy+FlCd8Ny6t4l2vM4xlGboz8qoxS7Gjrya/Jo3Qrohh6gaWp83 RMNdfKZNGnMsDijl3ZwrL+3XvUdU8DNOnJGDboU4DqRifknuKYhkWS/RalqgwlFZ+p58 n1EP2Y6AbK1fnNtANFq4grrCbJbtcei2bA8XOi90f+1ppMMmc7NGz/ExWCB3r4Os2Yz8 EZ3A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i21si13007881edb.402.2020.07.21.13.18.26; Tue, 21 Jul 2020 13:18:49 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730312AbgGUUSL (ORCPT + 99 others); Tue, 21 Jul 2020 16:18:11 -0400 Received: from www62.your-server.de ([213.133.104.62]:35228 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726029AbgGUUSL (ORCPT ); Tue, 21 Jul 2020 16:18:11 -0400 Received: from sslproxy02.your-server.de ([78.47.166.47]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1jxyi7-0001a2-3k; Tue, 21 Jul 2020 22:17:59 +0200 Received: from [178.196.57.75] (helo=pc-9.home) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jxyi6-000HIz-T8; Tue, 21 Jul 2020 22:17:58 +0200 Subject: Re: [PATCH bpf-next] bpf: Generate cookie for new non-initial net NS To: Jianlin Lv , bpf@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, ast@kernel.org, yhs@fb.com, Song.Zhu@arm.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org References: <20200720140919.22342-1-Jianlin.Lv@arm.com> From: Daniel Borkmann Message-ID: <840a9007-3dcb-457f-8746-7f8e6fa209c5@iogearbox.net> Date: Tue, 21 Jul 2020 22:17:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20200720140919.22342-1-Jianlin.Lv@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.3/25880/Tue Jul 21 16:34:58 2020) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/20/20 4:09 PM, Jianlin Lv wrote: > For non-initial network NS, the net cookie is generated when > bpf_get_netns_cookie_sock is called for the first time, but it is more > reasonable to complete the cookie generation work when creating a new > network NS, just like init_net. > net_gen_cookie() be moved into setup_net() that it can serve the initial > and non-initial network namespace. > > Signed-off-by: Jianlin Lv What use-case are you trying to solve? Why should it be different than, say, socket cookie generation? I'm currently not seeing much of a point in moving this. When it's not used in the system, it would actually create more work. > --- > net/core/net_namespace.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c > index dcd61aca343e..5937bd0df56d 100644 > --- a/net/core/net_namespace.c > +++ b/net/core/net_namespace.c > @@ -336,6 +336,7 @@ static __net_init int setup_net(struct net *net, struct user_namespace *user_ns) > idr_init(&net->netns_ids); > spin_lock_init(&net->nsid_lock); > mutex_init(&net->ipv4.ra_mutex); > + net_gen_cookie(net); > > list_for_each_entry(ops, &pernet_list, list) { > error = ops_init(ops, net); > @@ -1101,7 +1102,6 @@ static int __init net_ns_init(void) > panic("Could not allocate generic netns"); > > rcu_assign_pointer(init_net.gen, ng); > - net_gen_cookie(&init_net); > > down_write(&pernet_ops_rwsem); > if (setup_net(&init_net, &init_user_ns)) >