Merge branch 'for-2.6.26' of git://neil.brown.name/md
[pandora-kernel.git] / include / net / net_namespace.h
index e2aee26..d9dd0f7 100644 (file)
@@ -20,14 +20,17 @@ struct proc_dir_entry;
 struct net_device;
 struct sock;
 struct ctl_table_header;
+struct net_generic;
 
 struct net {
        atomic_t                count;          /* To decided when the network
                                                 *  namespace should be freed.
                                                 */
+#ifdef NETNS_REFCNT_DEBUG
        atomic_t                use_count;      /* To track references we
                                                 * destroy on demand
                                                 */
+#endif
        struct list_head        list;           /* list of network namespaces */
        struct work_struct      work;           /* work struct for freeing */
 
@@ -61,6 +64,7 @@ struct net {
 #ifdef CONFIG_NETFILTER
        struct netns_xt         xt;
 #endif
+       struct net_generic      *gen;
 };
 
 
@@ -91,6 +95,11 @@ extern struct list_head net_namespace_list;
 #ifdef CONFIG_NET_NS
 extern void __put_net(struct net *net);
 
+static inline int net_alive(struct net *net)
+{
+       return net && atomic_read(&net->count);
+}
+
 static inline struct net *get_net(struct net *net)
 {
        atomic_inc(&net->count);
@@ -115,23 +124,18 @@ static inline void put_net(struct net *net)
                __put_net(net);
 }
 
-static inline struct net *hold_net(struct net *net)
-{
-       atomic_inc(&net->use_count);
-       return net;
-}
-
-static inline void release_net(struct net *net)
-{
-       atomic_dec(&net->use_count);
-}
-
 static inline
 int net_eq(const struct net *net1, const struct net *net2)
 {
        return net1 == net2;
 }
 #else
+
+static inline int net_alive(struct net *net)
+{
+       return 1;
+}
+
 static inline struct net *get_net(struct net *net)
 {
        return net;
@@ -141,27 +145,44 @@ static inline void put_net(struct net *net)
 {
 }
 
+static inline struct net *maybe_get_net(struct net *net)
+{
+       return net;
+}
+
+static inline
+int net_eq(const struct net *net1, const struct net *net2)
+{
+       return 1;
+}
+#endif
+
+
+#ifdef NETNS_REFCNT_DEBUG
 static inline struct net *hold_net(struct net *net)
 {
+       if (net)
+               atomic_inc(&net->use_count);
        return net;
 }
 
 static inline void release_net(struct net *net)
 {
+       if (net)
+               atomic_dec(&net->use_count);
 }
-
-static inline struct net *maybe_get_net(struct net *net)
+#else
+static inline struct net *hold_net(struct net *net)
 {
        return net;
 }
 
-static inline
-int net_eq(const struct net *net1, const struct net *net2)
+static inline void release_net(struct net *net)
 {
-       return 1;
 }
 #endif
 
+
 #define for_each_net(VAR)                              \
        list_for_each_entry(VAR, &net_namespace_list, list)
 
@@ -185,6 +206,8 @@ extern int register_pernet_subsys(struct pernet_operations *);
 extern void unregister_pernet_subsys(struct pernet_operations *);
 extern int register_pernet_device(struct pernet_operations *);
 extern void unregister_pernet_device(struct pernet_operations *);
+extern int register_pernet_gen_device(int *id, struct pernet_operations *);
+extern void unregister_pernet_gen_device(int id, struct pernet_operations *);
 
 struct ctl_path;
 struct ctl_table;