aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-11-01 03:43:49 -0400
committerDavid S. Miller <davem@davemloft.net>2007-11-01 03:43:49 -0400
commitd46557955f2a35e58772518775464cdf354b3245 (patch)
tree1b61906c5ce3ccabdbeb4cec1815c4e0cc5faa0c /include/net
parent1dba323b3f92cf4a475236763b0373cb7d49395d (diff)
[NET]: Relax the reference counting of init_net_ns
When the CONFIG_NET_NS is n there's no need in refcounting the initial net namespace. So relax this code by making a stupid stubs for the "n" case. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/net_namespace.h33
1 files changed, 25 insertions, 8 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 5279466606d2..1fd449a6530b 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -51,13 +51,12 @@ static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns)
51} 51}
52#endif 52#endif
53 53
54#ifdef CONFIG_NET_NS
54extern void __put_net(struct net *net); 55extern void __put_net(struct net *net);
55 56
56static inline struct net *get_net(struct net *net) 57static inline struct net *get_net(struct net *net)
57{ 58{
58#ifdef CONFIG_NET
59 atomic_inc(&net->count); 59 atomic_inc(&net->count);
60#endif
61 return net; 60 return net;
62} 61}
63 62
@@ -75,26 +74,44 @@ static inline struct net *maybe_get_net(struct net *net)
75 74
76static inline void put_net(struct net *net) 75static inline void put_net(struct net *net)
77{ 76{
78#ifdef CONFIG_NET
79 if (atomic_dec_and_test(&net->count)) 77 if (atomic_dec_and_test(&net->count))
80 __put_net(net); 78 __put_net(net);
81#endif
82} 79}
83 80
84static inline struct net *hold_net(struct net *net) 81static inline struct net *hold_net(struct net *net)
85{ 82{
86#ifdef CONFIG_NET
87 atomic_inc(&net->use_count); 83 atomic_inc(&net->use_count);
88#endif
89 return net; 84 return net;
90} 85}
91 86
92static inline void release_net(struct net *net) 87static inline void release_net(struct net *net)
93{ 88{
94#ifdef CONFIG_NET
95 atomic_dec(&net->use_count); 89 atomic_dec(&net->use_count);
96#endif
97} 90}
91#else
92static inline struct net *get_net(struct net *net)
93{
94 return net;
95}
96
97static inline void put_net(struct net *net)
98{
99}
100
101static inline struct net *hold_net(struct net *net)
102{
103 return net;
104}
105
106static inline void release_net(struct net *net)
107{
108}
109
110static inline struct net *maybe_get_net(struct net *net)
111{
112 return net;
113}
114#endif
98 115
99#define for_each_net(VAR) \ 116#define for_each_net(VAR) \
100 list_for_each_entry(VAR, &net_namespace_list, list) 117 list_for_each_entry(VAR, &net_namespace_list, list)