diff options
author | Gao feng <gaofeng@cn.fujitsu.com> | 2013-01-21 17:10:32 -0500 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-01-23 06:56:33 -0500 |
commit | 04d870017908f40bbb1c51910acc030ae4979db4 (patch) | |
tree | 552a8d3d957bbfb6626270f1304a3d10acefdf61 /net/netfilter | |
parent | 5f69b8f5218dc303cbcb6f71d221c27d3cd17ebb (diff) |
netfilter: nf_ct_proto: move initialization out of pernet_operations
Move the global initial codes to the module_init/exit context.
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_core.c | 13 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_proto.c | 34 |
2 files changed, 29 insertions, 18 deletions
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index a4a3bcf77627..c8e001a9c45b 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -1348,6 +1348,7 @@ void nf_conntrack_cleanup_end(void) | |||
1348 | #ifdef CONFIG_NF_CONNTRACK_ZONES | 1348 | #ifdef CONFIG_NF_CONNTRACK_ZONES |
1349 | nf_ct_extend_unregister(&nf_ct_zone_extend); | 1349 | nf_ct_extend_unregister(&nf_ct_zone_extend); |
1350 | #endif | 1350 | #endif |
1351 | nf_conntrack_proto_fini(); | ||
1351 | nf_conntrack_labels_fini(); | 1352 | nf_conntrack_labels_fini(); |
1352 | nf_conntrack_helper_fini(); | 1353 | nf_conntrack_helper_fini(); |
1353 | nf_conntrack_timeout_fini(); | 1354 | nf_conntrack_timeout_fini(); |
@@ -1378,7 +1379,7 @@ void nf_conntrack_cleanup_net(struct net *net) | |||
1378 | } | 1379 | } |
1379 | 1380 | ||
1380 | nf_ct_free_hashtable(net->ct.hash, net->ct.htable_size); | 1381 | nf_ct_free_hashtable(net->ct.hash, net->ct.htable_size); |
1381 | nf_conntrack_proto_fini(net); | 1382 | nf_conntrack_proto_pernet_fini(net); |
1382 | nf_conntrack_helper_pernet_fini(net); | 1383 | nf_conntrack_helper_pernet_fini(net); |
1383 | nf_conntrack_ecache_pernet_fini(net); | 1384 | nf_conntrack_ecache_pernet_fini(net); |
1384 | nf_conntrack_tstamp_pernet_fini(net); | 1385 | nf_conntrack_tstamp_pernet_fini(net); |
@@ -1540,6 +1541,10 @@ int nf_conntrack_init_start(void) | |||
1540 | if (ret < 0) | 1541 | if (ret < 0) |
1541 | goto err_extend; | 1542 | goto err_extend; |
1542 | #endif | 1543 | #endif |
1544 | ret = nf_conntrack_proto_init(); | ||
1545 | if (ret < 0) | ||
1546 | goto err_proto; | ||
1547 | |||
1543 | /* Set up fake conntrack: to never be deleted, not in any hashes */ | 1548 | /* Set up fake conntrack: to never be deleted, not in any hashes */ |
1544 | for_each_possible_cpu(cpu) { | 1549 | for_each_possible_cpu(cpu) { |
1545 | struct nf_conn *ct = &per_cpu(nf_conntrack_untracked, cpu); | 1550 | struct nf_conn *ct = &per_cpu(nf_conntrack_untracked, cpu); |
@@ -1550,10 +1555,12 @@ int nf_conntrack_init_start(void) | |||
1550 | nf_ct_untracked_status_or(IPS_CONFIRMED | IPS_UNTRACKED); | 1555 | nf_ct_untracked_status_or(IPS_CONFIRMED | IPS_UNTRACKED); |
1551 | return 0; | 1556 | return 0; |
1552 | 1557 | ||
1558 | err_proto: | ||
1553 | #ifdef CONFIG_NF_CONNTRACK_ZONES | 1559 | #ifdef CONFIG_NF_CONNTRACK_ZONES |
1560 | nf_ct_extend_unregister(&nf_ct_zone_extend); | ||
1554 | err_extend: | 1561 | err_extend: |
1555 | nf_conntrack_labels_fini(); | ||
1556 | #endif | 1562 | #endif |
1563 | nf_conntrack_labels_fini(); | ||
1557 | err_labels: | 1564 | err_labels: |
1558 | nf_conntrack_helper_fini(); | 1565 | nf_conntrack_helper_fini(); |
1559 | err_helper: | 1566 | err_helper: |
@@ -1638,7 +1645,7 @@ int nf_conntrack_init_net(struct net *net) | |||
1638 | ret = nf_conntrack_helper_pernet_init(net); | 1645 | ret = nf_conntrack_helper_pernet_init(net); |
1639 | if (ret < 0) | 1646 | if (ret < 0) |
1640 | goto err_helper; | 1647 | goto err_helper; |
1641 | ret = nf_conntrack_proto_init(net); | 1648 | ret = nf_conntrack_proto_pernet_init(net); |
1642 | if (ret < 0) | 1649 | if (ret < 0) |
1643 | goto err_proto; | 1650 | goto err_proto; |
1644 | return 0; | 1651 | return 0; |
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c index 51e928db48c8..f0ec07c3fb6c 100644 --- a/net/netfilter/nf_conntrack_proto.c +++ b/net/netfilter/nf_conntrack_proto.c | |||
@@ -503,9 +503,8 @@ void nf_conntrack_l4proto_unregister(struct net *net, | |||
503 | } | 503 | } |
504 | EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_unregister); | 504 | EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_unregister); |
505 | 505 | ||
506 | int nf_conntrack_proto_init(struct net *net) | 506 | int nf_conntrack_proto_pernet_init(struct net *net) |
507 | { | 507 | { |
508 | unsigned int i; | ||
509 | int err; | 508 | int err; |
510 | struct nf_proto_net *pn = nf_ct_l4proto_net(net, | 509 | struct nf_proto_net *pn = nf_ct_l4proto_net(net, |
511 | &nf_conntrack_l4proto_generic); | 510 | &nf_conntrack_l4proto_generic); |
@@ -520,19 +519,12 @@ int nf_conntrack_proto_init(struct net *net) | |||
520 | if (err < 0) | 519 | if (err < 0) |
521 | return err; | 520 | return err; |
522 | 521 | ||
523 | if (net == &init_net) { | ||
524 | for (i = 0; i < AF_MAX; i++) | ||
525 | rcu_assign_pointer(nf_ct_l3protos[i], | ||
526 | &nf_conntrack_l3proto_generic); | ||
527 | } | ||
528 | |||
529 | pn->users++; | 522 | pn->users++; |
530 | return 0; | 523 | return 0; |
531 | } | 524 | } |
532 | 525 | ||
533 | void nf_conntrack_proto_fini(struct net *net) | 526 | void nf_conntrack_proto_pernet_fini(struct net *net) |
534 | { | 527 | { |
535 | unsigned int i; | ||
536 | struct nf_proto_net *pn = nf_ct_l4proto_net(net, | 528 | struct nf_proto_net *pn = nf_ct_l4proto_net(net, |
537 | &nf_conntrack_l4proto_generic); | 529 | &nf_conntrack_l4proto_generic); |
538 | 530 | ||
@@ -540,9 +532,21 @@ void nf_conntrack_proto_fini(struct net *net) | |||
540 | nf_ct_l4proto_unregister_sysctl(net, | 532 | nf_ct_l4proto_unregister_sysctl(net, |
541 | pn, | 533 | pn, |
542 | &nf_conntrack_l4proto_generic); | 534 | &nf_conntrack_l4proto_generic); |
543 | if (net == &init_net) { | 535 | } |
544 | /* free l3proto protocol tables */ | 536 | |
545 | for (i = 0; i < PF_MAX; i++) | 537 | int nf_conntrack_proto_init(void) |
546 | kfree(nf_ct_protos[i]); | 538 | { |
547 | } | 539 | unsigned int i; |
540 | for (i = 0; i < AF_MAX; i++) | ||
541 | rcu_assign_pointer(nf_ct_l3protos[i], | ||
542 | &nf_conntrack_l3proto_generic); | ||
543 | return 0; | ||
544 | } | ||
545 | |||
546 | void nf_conntrack_proto_fini(void) | ||
547 | { | ||
548 | unsigned int i; | ||
549 | /* free l3proto protocol tables */ | ||
550 | for (i = 0; i < PF_MAX; i++) | ||
551 | kfree(nf_ct_protos[i]); | ||
548 | } | 552 | } |