diff options
author | Gao feng <gaofeng@cn.fujitsu.com> | 2013-01-21 17:10:33 -0500 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-01-23 08:39:20 -0500 |
commit | 6330750d566d764ce4916d8fe2bcdcad28fc7a42 (patch) | |
tree | ed0aaaabedb35628bf9ef5a4a459a1c52773714b /net/netfilter | |
parent | 04d870017908f40bbb1c51910acc030ae4979db4 (diff) |
netfilter: nf_conntrack: refactor l3proto support for netns
Move the code that register/unregister l3proto to the
module_init/exit context.
Given that we have to modify some interfaces to accomodate
these changes, it is a good time to use shorter function names
for this using the nf_ct_* prefix instead of nf_conntrack_*,
that is:
nf_ct_l3proto_register
nf_ct_l3proto_pernet_register
nf_ct_l3proto_unregister
nf_ct_l3proto_pernet_unregister
We same many line breaks with it.
Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/nf_conntrack_proto.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c index f0ec07c3fb6c..076d82707226 100644 --- a/net/netfilter/nf_conntrack_proto.c +++ b/net/netfilter/nf_conntrack_proto.c | |||
@@ -212,8 +212,7 @@ static void nf_ct_l3proto_unregister_sysctl(struct net *net, | |||
212 | #endif | 212 | #endif |
213 | } | 213 | } |
214 | 214 | ||
215 | static int | 215 | int nf_ct_l3proto_register(struct nf_conntrack_l3proto *proto) |
216 | nf_conntrack_l3proto_register_net(struct nf_conntrack_l3proto *proto) | ||
217 | { | 216 | { |
218 | int ret = 0; | 217 | int ret = 0; |
219 | struct nf_conntrack_l3proto *old; | 218 | struct nf_conntrack_l3proto *old; |
@@ -242,8 +241,9 @@ out_unlock: | |||
242 | return ret; | 241 | return ret; |
243 | 242 | ||
244 | } | 243 | } |
244 | EXPORT_SYMBOL_GPL(nf_ct_l3proto_register); | ||
245 | 245 | ||
246 | int nf_conntrack_l3proto_register(struct net *net, | 246 | int nf_ct_l3proto_pernet_register(struct net *net, |
247 | struct nf_conntrack_l3proto *proto) | 247 | struct nf_conntrack_l3proto *proto) |
248 | { | 248 | { |
249 | int ret = 0; | 249 | int ret = 0; |
@@ -254,22 +254,11 @@ int nf_conntrack_l3proto_register(struct net *net, | |||
254 | return ret; | 254 | return ret; |
255 | } | 255 | } |
256 | 256 | ||
257 | ret = nf_ct_l3proto_register_sysctl(net, proto); | 257 | return nf_ct_l3proto_register_sysctl(net, proto); |
258 | if (ret < 0) | ||
259 | return ret; | ||
260 | |||
261 | if (net == &init_net) { | ||
262 | ret = nf_conntrack_l3proto_register_net(proto); | ||
263 | if (ret < 0) | ||
264 | nf_ct_l3proto_unregister_sysctl(net, proto); | ||
265 | } | ||
266 | |||
267 | return ret; | ||
268 | } | 258 | } |
269 | EXPORT_SYMBOL_GPL(nf_conntrack_l3proto_register); | 259 | EXPORT_SYMBOL_GPL(nf_ct_l3proto_pernet_register); |
270 | 260 | ||
271 | static void | 261 | void nf_ct_l3proto_unregister(struct nf_conntrack_l3proto *proto) |
272 | nf_conntrack_l3proto_unregister_net(struct nf_conntrack_l3proto *proto) | ||
273 | { | 262 | { |
274 | BUG_ON(proto->l3proto >= AF_MAX); | 263 | BUG_ON(proto->l3proto >= AF_MAX); |
275 | 264 | ||
@@ -283,19 +272,17 @@ nf_conntrack_l3proto_unregister_net(struct nf_conntrack_l3proto *proto) | |||
283 | 272 | ||
284 | synchronize_rcu(); | 273 | synchronize_rcu(); |
285 | } | 274 | } |
275 | EXPORT_SYMBOL_GPL(nf_ct_l3proto_unregister); | ||
286 | 276 | ||
287 | void nf_conntrack_l3proto_unregister(struct net *net, | 277 | void nf_ct_l3proto_pernet_unregister(struct net *net, |
288 | struct nf_conntrack_l3proto *proto) | 278 | struct nf_conntrack_l3proto *proto) |
289 | { | 279 | { |
290 | if (net == &init_net) | ||
291 | nf_conntrack_l3proto_unregister_net(proto); | ||
292 | |||
293 | nf_ct_l3proto_unregister_sysctl(net, proto); | 280 | nf_ct_l3proto_unregister_sysctl(net, proto); |
294 | 281 | ||
295 | /* Remove all contrack entries for this protocol */ | 282 | /* Remove all contrack entries for this protocol */ |
296 | nf_ct_iterate_cleanup(net, kill_l3proto, proto); | 283 | nf_ct_iterate_cleanup(net, kill_l3proto, proto); |
297 | } | 284 | } |
298 | EXPORT_SYMBOL_GPL(nf_conntrack_l3proto_unregister); | 285 | EXPORT_SYMBOL_GPL(nf_ct_l3proto_pernet_unregister); |
299 | 286 | ||
300 | static struct nf_proto_net *nf_ct_l4proto_net(struct net *net, | 287 | static struct nf_proto_net *nf_ct_l4proto_net(struct net *net, |
301 | struct nf_conntrack_l4proto *l4proto) | 288 | struct nf_conntrack_l4proto *l4proto) |