mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
net: support ns lookup
Support the generic ns lookup infrastructure to support file handles for namespaces. The network namespace has a separate list with different lifetime rules which we can just leave in tact. We have a similar concept for mount namespaces as well where it is on two differenet lists for different purposes. Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
74b24a582e
commit
195f742229
|
|
@ -20,6 +20,7 @@
|
||||||
#include <linux/sched/task.h>
|
#include <linux/sched/task.h>
|
||||||
#include <linux/uidgid.h>
|
#include <linux/uidgid.h>
|
||||||
#include <linux/proc_fs.h>
|
#include <linux/proc_fs.h>
|
||||||
|
#include <linux/nstree.h>
|
||||||
|
|
||||||
#include <net/aligned_data.h>
|
#include <net/aligned_data.h>
|
||||||
#include <net/sock.h>
|
#include <net/sock.h>
|
||||||
|
|
@ -445,7 +446,7 @@ static __net_init int setup_net(struct net *net)
|
||||||
LIST_HEAD(net_exit_list);
|
LIST_HEAD(net_exit_list);
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
net->net_cookie = atomic64_inc_return(&net_aligned_data.net_cookie);
|
net->net_cookie = ns_tree_gen_id(&net->ns);
|
||||||
|
|
||||||
list_for_each_entry(ops, &pernet_list, list) {
|
list_for_each_entry(ops, &pernet_list, list) {
|
||||||
error = ops_init(ops, net);
|
error = ops_init(ops, net);
|
||||||
|
|
@ -455,6 +456,7 @@ static __net_init int setup_net(struct net *net)
|
||||||
down_write(&net_rwsem);
|
down_write(&net_rwsem);
|
||||||
list_add_tail_rcu(&net->list, &net_namespace_list);
|
list_add_tail_rcu(&net->list, &net_namespace_list);
|
||||||
up_write(&net_rwsem);
|
up_write(&net_rwsem);
|
||||||
|
ns_tree_add_raw(net);
|
||||||
out:
|
out:
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
|
@ -674,8 +676,10 @@ static void cleanup_net(struct work_struct *work)
|
||||||
|
|
||||||
/* Don't let anyone else find us. */
|
/* Don't let anyone else find us. */
|
||||||
down_write(&net_rwsem);
|
down_write(&net_rwsem);
|
||||||
llist_for_each_entry(net, net_kill_list, cleanup_list)
|
llist_for_each_entry(net, net_kill_list, cleanup_list) {
|
||||||
|
ns_tree_remove(net);
|
||||||
list_del_rcu(&net->list);
|
list_del_rcu(&net->list);
|
||||||
|
}
|
||||||
/* Cache last net. After we unlock rtnl, no one new net
|
/* Cache last net. After we unlock rtnl, no one new net
|
||||||
* added to net_namespace_list can assign nsid pointer
|
* added to net_namespace_list can assign nsid pointer
|
||||||
* to a net from net_kill_list (see peernet2id_alloc()).
|
* to a net from net_kill_list (see peernet2id_alloc()).
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user