]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blame - include/net/net_namespace.h
[NET]: Make /proc/net per network namespace
[mirror_ubuntu-kernels.git] / include / net / net_namespace.h
CommitLineData
5f256bec
EB
1/*
2 * Operations on the network namespace
3 */
4#ifndef __NET_NET_NAMESPACE_H
5#define __NET_NET_NAMESPACE_H
6
7#include <asm/atomic.h>
8#include <linux/workqueue.h>
9#include <linux/list.h>
10
457c4cbc 11struct proc_dir_entry;
5f256bec
EB
12struct net {
13 atomic_t count; /* To decided when the network
14 * namespace should be freed.
15 */
16 atomic_t use_count; /* To track references we
17 * destroy on demand
18 */
19 struct list_head list; /* list of network namespaces */
20 struct work_struct work; /* work struct for freeing */
457c4cbc
EB
21
22 struct proc_dir_entry *proc_net;
23 struct proc_dir_entry *proc_net_stat;
24 struct proc_dir_entry *proc_net_root;
5f256bec
EB
25};
26
27extern struct net init_net;
28extern struct list_head net_namespace_list;
29
30extern void __put_net(struct net *net);
31
32static inline struct net *get_net(struct net *net)
33{
34 atomic_inc(&net->count);
35 return net;
36}
37
38static inline void put_net(struct net *net)
39{
40 if (atomic_dec_and_test(&net->count))
41 __put_net(net);
42}
43
44static inline struct net *hold_net(struct net *net)
45{
46 atomic_inc(&net->use_count);
47 return net;
48}
49
50static inline void release_net(struct net *net)
51{
52 atomic_dec(&net->use_count);
53}
54
55extern void net_lock(void);
56extern void net_unlock(void);
57
58#define for_each_net(VAR) \
59 list_for_each_entry(VAR, &net_namespace_list, list)
60
61
62struct pernet_operations {
63 struct list_head list;
64 int (*init)(struct net *net);
65 void (*exit)(struct net *net);
66};
67
68extern int register_pernet_subsys(struct pernet_operations *);
69extern void unregister_pernet_subsys(struct pernet_operations *);
70extern int register_pernet_device(struct pernet_operations *);
71extern void unregister_pernet_device(struct pernet_operations *);
72
73#endif /* __NET_NET_NAMESPACE_H */