aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-04-16 04:58:04 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-16 04:58:04 -0400
commit5d1e4468a7705db7c1415a65fd16f07113afc1b2 (patch)
tree41d34aa3f0e3b8cc0453973d8ce9e03303264080 /include
parent554eb27782d4bb79e0a286a08ecafb81f758058c (diff)
[NETNS]: Make netns refconting debug like a socket one.
Make release_net/hold_net noop for performance-hungry people. This is a debug staff and should be used in the debug mode only. Add check for net != NULL in hold/release calls. This will be required later on. [ Added minor simplifications suggested by Brian Haley. -DaveM ] Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/net_namespace.h40
1 files changed, 24 insertions, 16 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index f880b0f9f107..aa540e6be502 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -26,9 +26,11 @@ struct net {
26 atomic_t count; /* To decided when the network 26 atomic_t count; /* To decided when the network
27 * namespace should be freed. 27 * namespace should be freed.
28 */ 28 */
29#ifdef NETNS_REFCNT_DEBUG
29 atomic_t use_count; /* To track references we 30 atomic_t use_count; /* To track references we
30 * destroy on demand 31 * destroy on demand
31 */ 32 */
33#endif
32 struct list_head list; /* list of network namespaces */ 34 struct list_head list; /* list of network namespaces */
33 struct work_struct work; /* work struct for freeing */ 35 struct work_struct work; /* work struct for freeing */
34 36
@@ -117,17 +119,6 @@ static inline void put_net(struct net *net)
117 __put_net(net); 119 __put_net(net);
118} 120}
119 121
120static inline struct net *hold_net(struct net *net)
121{
122 atomic_inc(&net->use_count);
123 return net;
124}
125
126static inline void release_net(struct net *net)
127{
128 atomic_dec(&net->use_count);
129}
130
131static inline 122static inline
132int net_eq(const struct net *net1, const struct net *net2) 123int net_eq(const struct net *net1, const struct net *net2)
133{ 124{
@@ -143,27 +134,44 @@ static inline void put_net(struct net *net)
143{ 134{
144} 135}
145 136
137static inline struct net *maybe_get_net(struct net *net)
138{
139 return net;
140}
141
142static inline
143int net_eq(const struct net *net1, const struct net *net2)
144{
145 return 1;
146}
147#endif
148
149
150#ifdef NETNS_REFCNT_DEBUG
146static inline struct net *hold_net(struct net *net) 151static inline struct net *hold_net(struct net *net)
147{ 152{
153 if (net)
154 atomic_inc(&net->use_count);
148 return net; 155 return net;
149} 156}
150 157
151static inline void release_net(struct net *net) 158static inline void release_net(struct net *net)
152{ 159{
160 if (net)
161 atomic_dec(&net->use_count);
153} 162}
154 163#else
155static inline struct net *maybe_get_net(struct net *net) 164static inline struct net *hold_net(struct net *net)
156{ 165{
157 return net; 166 return net;
158} 167}
159 168
160static inline 169static inline void release_net(struct net *net)
161int net_eq(const struct net *net1, const struct net *net2)
162{ 170{
163 return 1;
164} 171}
165#endif 172#endif
166 173
174
167#define for_each_net(VAR) \ 175#define for_each_net(VAR) \
168 list_for_each_entry(VAR, &net_namespace_list, list) 176 list_for_each_entry(VAR, &net_namespace_list, list)
169 177