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>
12 atomic_t count
; /* To decided when the network
13 * namespace should be freed.
15 atomic_t use_count
; /* To track references we
18 struct list_head list
; /* list of network namespaces */
19 struct work_struct work
; /* work struct for freeing */
22 extern struct net init_net
;
23 extern struct list_head net_namespace_list
;
25 extern void __put_net(struct net
*net
);
27 static inline struct net
*get_net(struct net
*net
)
29 atomic_inc(&net
->count
);
33 static inline void put_net(struct net
*net
)
35 if (atomic_dec_and_test(&net
->count
))
39 static inline struct net
*hold_net(struct net
*net
)
41 atomic_inc(&net
->use_count
);
45 static inline void release_net(struct net
*net
)
47 atomic_dec(&net
->use_count
);
50 extern void net_lock(void);
51 extern void net_unlock(void);
53 #define for_each_net(VAR) \
54 list_for_each_entry(VAR, &net_namespace_list, list)
57 struct pernet_operations
{
58 struct list_head list
;
59 int (*init
)(struct net
*net
);
60 void (*exit
)(struct net
*net
);
63 extern int register_pernet_subsys(struct pernet_operations
*);
64 extern void unregister_pernet_subsys(struct pernet_operations
*);
65 extern int register_pernet_device(struct pernet_operations
*);
66 extern void unregister_pernet_device(struct pernet_operations
*);
68 #endif /* __NET_NET_NAMESPACE_H */