[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200720140919.22342-1-Jianlin.Lv@arm.com>
Date: Mon, 20 Jul 2020 22:09:19 +0800
From: Jianlin Lv <Jianlin.Lv@....com>
To: bpf@...r.kernel.org
Cc: davem@...emloft.net, kuba@...nel.org, ast@...nel.org,
daniel@...earbox.net, yhs@...com, Song.Zhu@....com,
Jianlin.Lv@....com, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org
Subject: [PATCH bpf-next] bpf: Generate cookie for new non-initial net NS
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 <Jianlin.Lv@....com>
---
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))
--
2.17.1
Powered by blists - more mailing lists