aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2008-11-12 00:53:30 -0800
committerDavid S. Miller <davem@davemloft.net>2008-11-12 00:53:30 -0800
commit8f424b5f32d78b4f353b3cddca9804808ef063eb (patch)
tree4e481fd6ed7ab82c5d70c30a66842fa432065f64
parent9eca0a47dee201a73967026985b5f0a79a46bd36 (diff)
downloadlinux-2.6.38-lt-ux500-8f424b5f32d78b4f353b3cddca9804808ef063eb.tar.gz
net: Introduce read_pnet() and write_pnet() helpers
This patch introduces two helpers that deal with reading and writing struct net pointers in various network structures. Their implementation depends on CONFIG_NET_NS For symmetry, both functions work with "struct net **pnet". Their usage should reduce the number of #ifdef CONFIG_NET_NS, without adding many helpers for each network structure that hold a "struct net *pointer" Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/net_namespace.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 700c53a3c6f..319557789a4 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -192,6 +192,24 @@ static inline void release_net(struct net *net)
}
#endif
+#ifdef CONFIG_NET_NS
+
+static inline void write_pnet(struct net **pnet, struct net *net)
+{
+ *pnet = net;
+}
+
+static inline struct net *read_pnet(struct net * const *pnet)
+{
+ return *pnet;
+}
+
+#else
+
+#define write_pnet(pnet, net) do { (void)(net);} while (0)
+#define read_pnet(pnet) (&init_net)
+
+#endif
#define for_each_net(VAR) \
list_for_each_entry(VAR, &net_namespace_list, list)