diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-11-01 03:43:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-11-01 03:43:49 -0400 |
commit | d46557955f2a35e58772518775464cdf354b3245 (patch) | |
tree | 1b61906c5ce3ccabdbeb4cec1815c4e0cc5faa0c /include/net | |
parent | 1dba323b3f92cf4a475236763b0373cb7d49395d (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.h | 33 |
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 | ||
54 | extern void __put_net(struct net *net); | 55 | extern void __put_net(struct net *net); |
55 | 56 | ||
56 | static inline struct net *get_net(struct net *net) | 57 | static 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 | ||
76 | static inline void put_net(struct net *net) | 75 | static 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 | ||
84 | static inline struct net *hold_net(struct net *net) | 81 | static 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 | ||
92 | static inline void release_net(struct net *net) | 87 | static 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 | ||
92 | static inline struct net *get_net(struct net *net) | ||
93 | { | ||
94 | return net; | ||
95 | } | ||
96 | |||
97 | static inline void put_net(struct net *net) | ||
98 | { | ||
99 | } | ||
100 | |||
101 | static inline struct net *hold_net(struct net *net) | ||
102 | { | ||
103 | return net; | ||
104 | } | ||
105 | |||
106 | static inline void release_net(struct net *net) | ||
107 | { | ||
108 | } | ||
109 | |||
110 | static 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) |