diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2009-11-29 17:25:28 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-01 19:15:51 -0500 |
commit | f875bae065334907796da12523f9df85c89f5712 (patch) | |
tree | 6f14819d128e3fa7b4cc8c274c6eff5326622fc8 /include/net | |
parent | 2b035b39970740722598f7a9d548835f9bdd730f (diff) |
net: Automatically allocate per namespace data.
To get the full benefit of batched network namespace cleanup netowrk
device deletion needs to be performed by the generic code. When
using register_pernet_gen_device and freeing the data in exit_net
it is impossible to delay allocation until after exit_net has called
as the device uninit methods are no longer safe.
To correct this, and to simplify working with per network namespace data
I have moved allocation and deletion of per network namespace data into
the network namespace core. The core now frees the data only after
all of the network namespace exit routines have run.
Now it is only required to set the new fields .id and .size
in the pernet_operations structure if you want network namespace
data to be managed for you automatically.
This makes the current register_pernet_gen_device and
register_pernet_gen_subsys routines unnecessary. For the moment
I have left them as compatibility wrappers in net_namespace.h
They will be removed once all of the users have been updated.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/net_namespace.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index d69b4796030f..080774b9dbf3 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -236,6 +236,8 @@ struct pernet_operations { | |||
236 | struct list_head list; | 236 | struct list_head list; |
237 | int (*init)(struct net *net); | 237 | int (*init)(struct net *net); |
238 | void (*exit)(struct net *net); | 238 | void (*exit)(struct net *net); |
239 | int *id; | ||
240 | size_t size; | ||
239 | }; | 241 | }; |
240 | 242 | ||
241 | /* | 243 | /* |
@@ -259,12 +261,30 @@ struct pernet_operations { | |||
259 | */ | 261 | */ |
260 | extern int register_pernet_subsys(struct pernet_operations *); | 262 | extern int register_pernet_subsys(struct pernet_operations *); |
261 | extern void unregister_pernet_subsys(struct pernet_operations *); | 263 | extern void unregister_pernet_subsys(struct pernet_operations *); |
262 | extern int register_pernet_gen_subsys(int *id, struct pernet_operations *); | ||
263 | extern void unregister_pernet_gen_subsys(int id, struct pernet_operations *); | ||
264 | extern int register_pernet_device(struct pernet_operations *); | 264 | extern int register_pernet_device(struct pernet_operations *); |
265 | extern void unregister_pernet_device(struct pernet_operations *); | 265 | extern void unregister_pernet_device(struct pernet_operations *); |
266 | extern int register_pernet_gen_device(int *id, struct pernet_operations *); | 266 | |
267 | extern void unregister_pernet_gen_device(int id, struct pernet_operations *); | 267 | static inline int register_pernet_gen_subsys(int *id, struct pernet_operations *ops) |
268 | { | ||
269 | ops->id = id; | ||
270 | return register_pernet_subsys(ops); | ||
271 | } | ||
272 | |||
273 | static inline void unregister_pernet_gen_subsys(int id, struct pernet_operations *ops) | ||
274 | { | ||
275 | return unregister_pernet_subsys(ops); | ||
276 | } | ||
277 | |||
278 | static inline int register_pernet_gen_device(int *id, struct pernet_operations *ops) | ||
279 | { | ||
280 | ops->id = id; | ||
281 | return register_pernet_device(ops); | ||
282 | } | ||
283 | |||
284 | static inline void unregister_pernet_gen_device(int id, struct pernet_operations *ops) | ||
285 | { | ||
286 | return unregister_pernet_device(ops); | ||
287 | } | ||
268 | 288 | ||
269 | struct ctl_path; | 289 | struct ctl_path; |
270 | struct ctl_table; | 290 | struct ctl_table; |