* [PATCH 1/2] netns: add register_pernet_gen_subsys/unregister_pernet_gen_subsys
@ 2008-10-25 22:43 Alexey Dobriyan
2008-10-27 4:56 ` David Miller
2008-10-28 12:09 ` Patrick McHardy
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Dobriyan @ 2008-10-25 22:43 UTC (permalink / raw)
To: davem, kaber; +Cc: netdev, netfiter-devel, containters
netns ops which are registered with register_pernet_gen_device() are
shutdown strictly before those which are registered with
register_pernet_subsys(). Sometimes this leads to opposite (read: buggy)
shutdown ordering between two modules.
Add register_pernet_gen_subsys()/unregister_pernet_gen_subsys() for modules
which aren't elite enough for entry in struct net, and which can't use
register_pernet_gen_device(). PPTP conntracking module is such one.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
include/net/net_namespace.h | 2 ++
net/core/net_namespace.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -215,6 +215,8 @@ struct pernet_operations {
extern int register_pernet_subsys(struct pernet_operations *);
extern void unregister_pernet_subsys(struct pernet_operations *);
+extern int register_pernet_gen_subsys(int *id, struct pernet_operations *);
+extern void unregister_pernet_gen_subsys(int id, struct pernet_operations *);
extern int register_pernet_device(struct pernet_operations *);
extern void unregister_pernet_device(struct pernet_operations *);
extern int register_pernet_gen_device(int *id, struct pernet_operations *);
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -325,6 +325,38 @@ void unregister_pernet_subsys(struct pernet_operations *module)
}
EXPORT_SYMBOL_GPL(unregister_pernet_subsys);
+int register_pernet_gen_subsys(int *id, struct pernet_operations *ops)
+{
+ int rv;
+
+ mutex_lock(&net_mutex);
+again:
+ rv = ida_get_new_above(&net_generic_ids, 1, id);
+ if (rv < 0) {
+ if (rv == -EAGAIN) {
+ ida_pre_get(&net_generic_ids, GFP_KERNEL);
+ goto again;
+ }
+ goto out;
+ }
+ rv = register_pernet_operations(first_device, ops);
+ if (rv < 0)
+ ida_remove(&net_generic_ids, *id);
+ mutex_unlock(&net_mutex);
+out:
+ return rv;
+}
+EXPORT_SYMBOL_GPL(register_pernet_gen_subsys);
+
+void unregister_pernet_gen_subsys(int id, struct pernet_operations *ops)
+{
+ mutex_lock(&net_mutex);
+ unregister_pernet_operations(ops);
+ ida_remove(&net_generic_ids, id);
+ mutex_unlock(&net_mutex);
+}
+EXPORT_SYMBOL_GPL(unregister_pernet_gen_subsys);
+
/**
* register_pernet_device - register a network namespace device
* @ops: pernet operations structure for the subsystem
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 1/2] netns: add register_pernet_gen_subsys/unregister_pernet_gen_subsys
2008-10-25 22:43 [PATCH 1/2] netns: add register_pernet_gen_subsys/unregister_pernet_gen_subsys Alexey Dobriyan
@ 2008-10-27 4:56 ` David Miller
2008-10-28 12:09 ` Patrick McHardy
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2008-10-27 4:56 UTC (permalink / raw)
To: adobriyan; +Cc: kaber, netdev, netfiter-devel, containters
From: Alexey Dobriyan <adobriyan@gmail.com>
Date: Sun, 26 Oct 2008 02:43:24 +0400
> netns ops which are registered with register_pernet_gen_device() are
> shutdown strictly before those which are registered with
> register_pernet_subsys(). Sometimes this leads to opposite (read: buggy)
> shutdown ordering between two modules.
>
> Add register_pernet_gen_subsys()/unregister_pernet_gen_subsys() for modules
> which aren't elite enough for entry in struct net, and which can't use
> register_pernet_gen_device(). PPTP conntracking module is such one.
>
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
I'll let Patrick take this one with your PPTP netns changes.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] netns: add register_pernet_gen_subsys/unregister_pernet_gen_subsys
2008-10-25 22:43 [PATCH 1/2] netns: add register_pernet_gen_subsys/unregister_pernet_gen_subsys Alexey Dobriyan
2008-10-27 4:56 ` David Miller
@ 2008-10-28 12:09 ` Patrick McHardy
1 sibling, 0 replies; 3+ messages in thread
From: Patrick McHardy @ 2008-10-28 12:09 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: davem, netdev, netfiter-devel, containters
Alexey Dobriyan wrote:
> netns ops which are registered with register_pernet_gen_device() are
> shutdown strictly before those which are registered with
> register_pernet_subsys(). Sometimes this leads to opposite (read: buggy)
> shutdown ordering between two modules.
>
> Add register_pernet_gen_subsys()/unregister_pernet_gen_subsys() for modules
> which aren't elite enough for entry in struct net, and which can't use
> register_pernet_gen_device(). PPTP conntracking module is such one.
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-28 12:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-25 22:43 [PATCH 1/2] netns: add register_pernet_gen_subsys/unregister_pernet_gen_subsys Alexey Dobriyan
2008-10-27 4:56 ` David Miller
2008-10-28 12:09 ` Patrick McHardy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).