netfilter 00/02: netfilter fixes
Subsystems (3)
Hi Dave,
the following two patches contain the GRE conntrack netns fix for an oops on unload from Alexey and the preparatory patch, introducing register_pernet_gen_subsys/unregister_pernet_gen_subsys.
Please apply, thanks.
include/net/net_namespace.h | 2 ++ net/core/net_namespace.c | 32 ++++++++++++++++++++++++++++++++ net/netfilter/nf_conntrack_proto_gre.c | 4 ++-- 3 files changed, 36 insertions(+), 2 deletions(-)
Alexey Dobriyan (2):
netns: add register_pernet_gen_subsys/unregister_pernet_gen_subsys
netfilter: nf_conntrack_proto_gre: switch to register_pernet_gen_subsys()
netns 01/02: add register_pernet_gen_subsys/unregister_pernet_gen_subsys
commit 616b16ca5561a4cb0fc6796ebf551e11636a3156
Author: Alexey Dobriyan <[email protected]> Date: Thu Oct 30 08:15:35 2008 +0100
netns: add register_pernet_gen_subsys/unregister_pernet_gen_subsys
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.
include/net/net_namespace.h +2 -0
@@ -214,6 +214,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 *);
net/core/net_namespace.c +32 -0
@@ -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
netfilter 02/02: nf_conntrack_proto_gre: switch to register_pernet_gen_subsys()
In reply to Patrick McHardycommit fd0e558a126650fa335acaacc42e697cc84deb12
Author: Alexey Dobriyan <[email protected]> Date: Thu Oct 30 08:15:36 2008 +0100
netfilter: nf_conntrack_proto_gre: switch to register_pernet_gen_subsys()
register_pernet_gen_device() can't be used is nf_conntrack_pptp module is also used (compiled in or loaded).
Right now, proto_gre_net_exit() is called before nf_conntrack_pptp_net_exit(). The former shutdowns and frees GRE piece of netns, however the latter absolutely needs it to flush keymap. Oops is inevitable.
Switch to shiny new register_pernet_gen_subsys() to get correct ordering in netns ops list.
net/netfilter/nf_conntrack_proto_gre.c +2 -2
@@ -335,7 +335,7 @@ static int __init nf_ct_proto_gre_init(void) rv =nf_conntrack_l4proto_register (&nf_conntrack_l4proto_gre4);if (rv <0 )return rv; - rv =register_pernet_gen_device (&proto_gre_net_id, &proto_gre_net_ops); + rv =register_pernet_gen_subsys (&proto_gre_net_id, &proto_gre_net_ops);if (rv <0 )nf_conntrack_l4proto_unregister (&nf_conntrack_l4proto_gre4);return rv;
@@ -344,7 +344,7 @@ static int __init nf_ct_proto_gre_init(void)static void nf_ct_proto_gre_fini (void ) {nf_conntrack_l4proto_unregister (&nf_conntrack_l4proto_gre4); -unregister_pernet_gen_device (proto_gre_net_id, &proto_gre_net_ops); +unregister_pernet_gen_subsys (proto_gre_net_id, &proto_gre_net_ops); }module_init (nf_ct_proto_gre_init);
Re: netns 01/02: add register_pernet_gen_subsys/unregister_pernet_gen_subsys
In reply to Patrick McHardyFrom: Patrick McHardy <[email protected]>
Date: Thu, 30 Oct 2008 08:31:46 +0100 (MET)
Quoted 7 lines
netns: add register_pernet_gen_subsys/unregister_pernet_gen_subsys
netns ops which are registered with
register_pernet_gen_device()are shutdown strictly before those which are registered withregister_pernet_subsys(). Sometimes this leads to opposite (read: buggy) shutdown ordering between two modules.
Quoted 6 lines
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 <[email protected]>Signed-off-by Patrick McHardy <[email protected]>
Applied.
David Miller
maintainerRe: netfilter 02/02: nf_conntrack_proto_gre: switch to register_pernet_gen_subsys()
In reply to Patrick McHardyFrom: Patrick McHardy <[email protected]>
Date: Thu, 30 Oct 2008 08:31:47 +0100 (MET)
Quoted 9 lines
netfilter:
nf_conntrack_proto_gre: switch toregister_pernet_gen_subsys()
register_pernet_gen_device()can't be used isnf_conntrack_pptpmodule is also used (compiled in or loaded).Right now,
proto_gre_net_exit()is called beforenf_conntrack_pptp_net_exit(). The former shutdowns and frees GRE piece of netns, however the latter absolutely needs it to flush keymap. Oops is inevitable.
Quoted 5 lines
Switch to shiny new
register_pernet_gen_subsys()to get correct ordering in netns ops list.Signed-off-by Alexey Dobriyan <[email protected]>Signed-off-by Patrick McHardy <[email protected]>
Also applied, thanks.