Merge branch 'for-4.2/writeback' of git://git.kernel.dk/linux-block
[firefly-linux-kernel-4.4.55.git] / include / net / net_namespace.h
index 36faf4990c4b6f2604fd2b00178c941d75f540a8..e951453e0a2378caf405f62910dd91d7c768ea3b 100644 (file)
 #endif
 #include <net/netns/nftables.h>
 #include <net/netns/xfrm.h>
+#include <net/netns/mpls.h>
 #include <linux/ns_common.h>
+#include <linux/idr.h>
+#include <linux/skbuff.h>
 
 struct user_namespace;
 struct proc_dir_entry;
@@ -48,18 +51,16 @@ struct net {
        atomic_t                count;          /* To decided when the network
                                                 *  namespace should be shut down.
                                                 */
-#ifdef NETNS_REFCNT_DEBUG
-       atomic_t                use_count;      /* To track references we
-                                                * destroy on demand
-                                                */
-#endif
        spinlock_t              rules_mod_lock;
 
+       atomic64_t              cookie_gen;
+
        struct list_head        list;           /* list of network namespaces */
        struct list_head        cleanup_list;   /* namespaces on death row */
        struct list_head        exit_list;      /* Use only net_mutex */
 
        struct user_namespace   *user_ns;       /* Owning user namespace */
+       spinlock_t              nsid_lock;
        struct idr              netns_ids;
 
        struct ns_common        ns;
@@ -129,6 +130,9 @@ struct net {
 #endif
 #if IS_ENABLED(CONFIG_IP_VS)
        struct netns_ipvs       *ipvs;
+#endif
+#if IS_ENABLED(CONFIG_MPLS)
+       struct netns_mpls       mpls;
 #endif
        struct sock             *diag_nlsk;
        atomic_t                fnhe_genid;
@@ -230,48 +234,27 @@ int net_eq(const struct net *net1, const struct net *net2)
 #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);
-}
-#else
-static inline struct net *hold_net(struct net *net)
-{
-       return net;
-}
-
-static inline void release_net(struct net *net)
-{
-}
-#endif
-
+typedef struct {
 #ifdef CONFIG_NET_NS
+       struct net *net;
+#endif
+} possible_net_t;
 
-static inline void write_pnet(struct net **pnet, struct net *net)
+static inline void write_pnet(possible_net_t *pnet, struct net *net)
 {
-       *pnet = net;
+#ifdef CONFIG_NET_NS
+       pnet->net = net;
+#endif
 }
 
-static inline struct net *read_pnet(struct net * const *pnet)
+static inline struct net *read_pnet(const possible_net_t *pnet)
 {
-       return *pnet;
-}
-
+#ifdef CONFIG_NET_NS
+       return pnet->net;
 #else
-
-#define write_pnet(pnet, net)  do { (void)(net);} while (0)
-#define read_pnet(pnet)                (&init_net)
-
+       return &init_net;
 #endif
+}
 
 #define for_each_net(VAR)                              \
        list_for_each_entry(VAR, &net_namespace_list, list)
@@ -291,7 +274,9 @@ static inline struct net *read_pnet(struct net * const *pnet)
 #define __net_initconst        __initconst
 #endif
 
+int peernet2id_alloc(struct net *net, struct net *peer);
 int peernet2id(struct net *net, struct net *peer);
+bool peernet_has_id(struct net *net, struct net *peer);
 struct net *get_net_ns_by_id(struct net *net, int id);
 
 struct pernet_operations {