2 * Operations on the network namespace
4 #ifndef __NET_NET_NAMESPACE_H
5 #define __NET_NET_NAMESPACE_H
7 #include <asm/atomic.h>
8 #include <linux/workqueue.h>
9 #include <linux/list.h>
11 struct proc_dir_entry
;
13 atomic_t count
; /* To decided when the network
14 * namespace should be freed.
16 atomic_t use_count
; /* To track references we
19 struct list_head list
; /* list of network namespaces */
20 struct work_struct work
; /* work struct for freeing */
22 struct proc_dir_entry
*proc_net
;
23 struct proc_dir_entry
*proc_net_stat
;
24 struct proc_dir_entry
*proc_net_root
;
27 extern struct net init_net
;
28 extern struct list_head net_namespace_list
;
30 extern void __put_net(struct net
*net
);
32 static inline struct net
*get_net(struct net
*net
)
34 atomic_inc(&net
->count
);
38 static inline void put_net(struct net
*net
)
40 if (atomic_dec_and_test(&net
->count
))
44 static inline struct net
*hold_net(struct net
*net
)
46 atomic_inc(&net
->use_count
);
50 static inline void release_net(struct net
*net
)
52 atomic_dec(&net
->use_count
);
55 extern void net_lock(void);
56 extern void net_unlock(void);
58 #define for_each_net(VAR) \
59 list_for_each_entry(VAR, &net_namespace_list, list)
62 struct pernet_operations
{
63 struct list_head list
;
64 int (*init
)(struct net
*net
);
65 void (*exit
)(struct net
*net
);
68 extern int register_pernet_subsys(struct pernet_operations
*);
69 extern void unregister_pernet_subsys(struct pernet_operations
*);
70 extern int register_pernet_device(struct pernet_operations
*);
71 extern void unregister_pernet_device(struct pernet_operations
*);
73 #endif /* __NET_NET_NAMESPACE_H */