[ARM] S3C: Fix scaler1 clock rate information
[linux-2.6/openmoko-kernel.git] / include / net / net_namespace.h
blob700c53a3c6fa22d9e49f522616da870b99522d3c
1 /*
2 * Operations on the network namespace
3 */
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 #include <net/netns/core.h>
12 #include <net/netns/mib.h>
13 #include <net/netns/unix.h>
14 #include <net/netns/packet.h>
15 #include <net/netns/ipv4.h>
16 #include <net/netns/ipv6.h>
17 #include <net/netns/dccp.h>
18 #include <net/netns/x_tables.h>
19 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
20 #include <net/netns/conntrack.h>
21 #endif
23 struct proc_dir_entry;
24 struct net_device;
25 struct sock;
26 struct ctl_table_header;
27 struct net_generic;
29 struct net {
30 atomic_t count; /* To decided when the network
31 * namespace should be freed.
33 #ifdef NETNS_REFCNT_DEBUG
34 atomic_t use_count; /* To track references we
35 * destroy on demand
37 #endif
38 struct list_head list; /* list of network namespaces */
39 struct work_struct work; /* work struct for freeing */
41 struct proc_dir_entry *proc_net;
42 struct proc_dir_entry *proc_net_stat;
44 #ifdef CONFIG_SYSCTL
45 struct ctl_table_set sysctls;
46 #endif
48 struct net_device *loopback_dev; /* The loopback */
50 struct list_head dev_base_head;
51 struct hlist_head *dev_name_head;
52 struct hlist_head *dev_index_head;
54 /* core fib_rules */
55 struct list_head rules_ops;
56 spinlock_t rules_mod_lock;
58 struct sock *rtnl; /* rtnetlink socket */
60 struct netns_core core;
61 struct netns_mib mib;
62 struct netns_packet packet;
63 struct netns_unix unx;
64 struct netns_ipv4 ipv4;
65 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
66 struct netns_ipv6 ipv6;
67 #endif
68 #if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE)
69 struct netns_dccp dccp;
70 #endif
71 #ifdef CONFIG_NETFILTER
72 struct netns_xt xt;
73 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
74 struct netns_ct ct;
75 #endif
76 #endif
77 struct net_generic *gen;
81 #include <linux/seq_file_net.h>
83 /* Init's network namespace */
84 extern struct net init_net;
86 #ifdef CONFIG_NET
87 #define INIT_NET_NS(net_ns) .net_ns = &init_net,
89 extern struct net *copy_net_ns(unsigned long flags, struct net *net_ns);
91 #else /* CONFIG_NET */
93 #define INIT_NET_NS(net_ns)
95 static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns)
97 /* There is nothing to copy so this is a noop */
98 return net_ns;
100 #endif /* CONFIG_NET */
103 extern struct list_head net_namespace_list;
105 #ifdef CONFIG_NET_NS
106 extern void __put_net(struct net *net);
108 static inline int net_alive(struct net *net)
110 return net && atomic_read(&net->count);
113 static inline struct net *get_net(struct net *net)
115 atomic_inc(&net->count);
116 return net;
119 static inline struct net *maybe_get_net(struct net *net)
121 /* Used when we know struct net exists but we
122 * aren't guaranteed a previous reference count
123 * exists. If the reference count is zero this
124 * function fails and returns NULL.
126 if (!atomic_inc_not_zero(&net->count))
127 net = NULL;
128 return net;
131 static inline void put_net(struct net *net)
133 if (atomic_dec_and_test(&net->count))
134 __put_net(net);
137 static inline
138 int net_eq(const struct net *net1, const struct net *net2)
140 return net1 == net2;
142 #else
144 static inline int net_alive(struct net *net)
146 return 1;
149 static inline struct net *get_net(struct net *net)
151 return net;
154 static inline void put_net(struct net *net)
158 static inline struct net *maybe_get_net(struct net *net)
160 return net;
163 static inline
164 int net_eq(const struct net *net1, const struct net *net2)
166 return 1;
168 #endif
171 #ifdef NETNS_REFCNT_DEBUG
172 static inline struct net *hold_net(struct net *net)
174 if (net)
175 atomic_inc(&net->use_count);
176 return net;
179 static inline void release_net(struct net *net)
181 if (net)
182 atomic_dec(&net->use_count);
184 #else
185 static inline struct net *hold_net(struct net *net)
187 return net;
190 static inline void release_net(struct net *net)
193 #endif
196 #define for_each_net(VAR) \
197 list_for_each_entry(VAR, &net_namespace_list, list)
199 #ifdef CONFIG_NET_NS
200 #define __net_init
201 #define __net_exit
202 #define __net_initdata
203 #else
204 #define __net_init __init
205 #define __net_exit __exit_refok
206 #define __net_initdata __initdata
207 #endif
209 struct pernet_operations {
210 struct list_head list;
211 int (*init)(struct net *net);
212 void (*exit)(struct net *net);
215 extern int register_pernet_subsys(struct pernet_operations *);
216 extern void unregister_pernet_subsys(struct pernet_operations *);
217 extern int register_pernet_gen_subsys(int *id, struct pernet_operations *);
218 extern void unregister_pernet_gen_subsys(int id, struct pernet_operations *);
219 extern int register_pernet_device(struct pernet_operations *);
220 extern void unregister_pernet_device(struct pernet_operations *);
221 extern int register_pernet_gen_device(int *id, struct pernet_operations *);
222 extern void unregister_pernet_gen_device(int id, struct pernet_operations *);
224 struct ctl_path;
225 struct ctl_table;
226 struct ctl_table_header;
228 extern struct ctl_table_header *register_net_sysctl_table(struct net *net,
229 const struct ctl_path *path, struct ctl_table *table);
230 extern struct ctl_table_header *register_net_sysctl_rotable(
231 const struct ctl_path *path, struct ctl_table *table);
232 extern void unregister_net_sysctl_table(struct ctl_table_header *header);
234 #endif /* __NET_NET_NAMESPACE_H */