aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2006-04-06 17:11:30 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-04-10 01:25:34 -0400
commit32292a7ff1d9306841a8da6ea286847b1070cc6a (patch)
treee2149c5b4c7bc50a937f95657a2cb1814dea8ddb /net/ipv4
parent964ddaa10de8f3aeed12bc2a30726514ff309e64 (diff)
[NETFILTER]: Fix section mismatch warnings
Fix section mismatch warnings caused by netfilter's init_or_cleanup functions used in many places by splitting the init from the cleanup parts. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/netfilter/ip_conntrack_standalone.c90
-rw-r--r--net/ipv4/netfilter/ip_nat_standalone.c18
-rw-r--r--net/ipv4/netfilter/ip_queue.c31
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c40
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c36
5 files changed, 97 insertions, 118 deletions
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
index adc1a0f66409..929d61f7be91 100644
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -776,18 +776,46 @@ static ctl_table ip_ct_net_table[] = {
776EXPORT_SYMBOL(ip_ct_log_invalid); 776EXPORT_SYMBOL(ip_ct_log_invalid);
777#endif /* CONFIG_SYSCTL */ 777#endif /* CONFIG_SYSCTL */
778 778
779static int init_or_cleanup(int init) 779/* FIXME: Allow NULL functions and sub in pointers to generic for
780 them. --RR */
781int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto)
782{
783 int ret = 0;
784
785 write_lock_bh(&ip_conntrack_lock);
786 if (ip_ct_protos[proto->proto] != &ip_conntrack_generic_protocol) {
787 ret = -EBUSY;
788 goto out;
789 }
790 ip_ct_protos[proto->proto] = proto;
791 out:
792 write_unlock_bh(&ip_conntrack_lock);
793 return ret;
794}
795
796void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto)
797{
798 write_lock_bh(&ip_conntrack_lock);
799 ip_ct_protos[proto->proto] = &ip_conntrack_generic_protocol;
800 write_unlock_bh(&ip_conntrack_lock);
801
802 /* Somebody could be still looking at the proto in bh. */
803 synchronize_net();
804
805 /* Remove all contrack entries for this protocol */
806 ip_ct_iterate_cleanup(kill_proto, &proto->proto);
807}
808
809static int __init ip_conntrack_standalone_init(void)
780{ 810{
781#ifdef CONFIG_PROC_FS 811#ifdef CONFIG_PROC_FS
782 struct proc_dir_entry *proc, *proc_exp, *proc_stat; 812 struct proc_dir_entry *proc, *proc_exp, *proc_stat;
783#endif 813#endif
784 int ret = 0; 814 int ret = 0;
785 815
786 if (!init) goto cleanup;
787
788 ret = ip_conntrack_init(); 816 ret = ip_conntrack_init();
789 if (ret < 0) 817 if (ret < 0)
790 goto cleanup_nothing; 818 return ret;
791 819
792#ifdef CONFIG_PROC_FS 820#ifdef CONFIG_PROC_FS
793 ret = -ENOMEM; 821 ret = -ENOMEM;
@@ -819,16 +847,12 @@ static int init_or_cleanup(int init)
819 goto cleanup_hooks; 847 goto cleanup_hooks;
820 } 848 }
821#endif 849#endif
822
823 return ret; 850 return ret;
824 851
825 cleanup:
826 synchronize_net();
827#ifdef CONFIG_SYSCTL 852#ifdef CONFIG_SYSCTL
828 unregister_sysctl_table(ip_ct_sysctl_header);
829 cleanup_hooks: 853 cleanup_hooks:
830#endif
831 nf_unregister_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops)); 854 nf_unregister_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
855#endif
832 cleanup_proc_stat: 856 cleanup_proc_stat:
833#ifdef CONFIG_PROC_FS 857#ifdef CONFIG_PROC_FS
834 remove_proc_entry("ip_conntrack", proc_net_stat); 858 remove_proc_entry("ip_conntrack", proc_net_stat);
@@ -839,48 +863,22 @@ static int init_or_cleanup(int init)
839 cleanup_init: 863 cleanup_init:
840#endif /* CONFIG_PROC_FS */ 864#endif /* CONFIG_PROC_FS */
841 ip_conntrack_cleanup(); 865 ip_conntrack_cleanup();
842 cleanup_nothing:
843 return ret; 866 return ret;
844} 867}
845 868
846/* FIXME: Allow NULL functions and sub in pointers to generic for
847 them. --RR */
848int ip_conntrack_protocol_register(struct ip_conntrack_protocol *proto)
849{
850 int ret = 0;
851
852 write_lock_bh(&ip_conntrack_lock);
853 if (ip_ct_protos[proto->proto] != &ip_conntrack_generic_protocol) {
854 ret = -EBUSY;
855 goto out;
856 }
857 ip_ct_protos[proto->proto] = proto;
858 out:
859 write_unlock_bh(&ip_conntrack_lock);
860 return ret;
861}
862
863void ip_conntrack_protocol_unregister(struct ip_conntrack_protocol *proto)
864{
865 write_lock_bh(&ip_conntrack_lock);
866 ip_ct_protos[proto->proto] = &ip_conntrack_generic_protocol;
867 write_unlock_bh(&ip_conntrack_lock);
868
869 /* Somebody could be still looking at the proto in bh. */
870 synchronize_net();
871
872 /* Remove all contrack entries for this protocol */
873 ip_ct_iterate_cleanup(kill_proto, &proto->proto);
874}
875
876static int __init ip_conntrack_standalone_init(void)
877{
878 return init_or_cleanup(1);
879}
880
881static void __exit ip_conntrack_standalone_fini(void) 869static void __exit ip_conntrack_standalone_fini(void)
882{ 870{
883 init_or_cleanup(0); 871 synchronize_net();
872#ifdef CONFIG_SYSCTL
873 unregister_sysctl_table(ip_ct_sysctl_header);
874#endif
875 nf_unregister_hooks(ip_conntrack_ops, ARRAY_SIZE(ip_conntrack_ops));
876#ifdef CONFIG_PROC_FS
877 remove_proc_entry("ip_conntrack", proc_net_stat);
878 proc_net_remove("ip_conntrack_expect");
879 proc_net_remove("ip_conntrack");
880#endif /* CONFIG_PROC_FS */
881 ip_conntrack_cleanup();
884} 882}
885 883
886module_init(ip_conntrack_standalone_init); 884module_init(ip_conntrack_standalone_init);
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
index 5f02f439b07e..8f760b28617e 100644
--- a/net/ipv4/netfilter/ip_nat_standalone.c
+++ b/net/ipv4/netfilter/ip_nat_standalone.c
@@ -350,14 +350,12 @@ static struct nf_hook_ops ip_nat_ops[] = {
350 }, 350 },
351}; 351};
352 352
353static int init_or_cleanup(int init) 353static int __init ip_nat_standalone_init(void)
354{ 354{
355 int ret = 0; 355 int ret = 0;
356 356
357 need_conntrack(); 357 need_conntrack();
358 358
359 if (!init) goto cleanup;
360
361#ifdef CONFIG_XFRM 359#ifdef CONFIG_XFRM
362 BUG_ON(ip_nat_decode_session != NULL); 360 BUG_ON(ip_nat_decode_session != NULL);
363 ip_nat_decode_session = nat_decode_session; 361 ip_nat_decode_session = nat_decode_session;
@@ -374,8 +372,6 @@ static int init_or_cleanup(int init)
374 } 372 }
375 return ret; 373 return ret;
376 374
377 cleanup:
378 nf_unregister_hooks(ip_nat_ops, ARRAY_SIZE(ip_nat_ops));
379 cleanup_rule_init: 375 cleanup_rule_init:
380 ip_nat_rule_cleanup(); 376 ip_nat_rule_cleanup();
381 cleanup_decode_session: 377 cleanup_decode_session:
@@ -386,14 +382,14 @@ static int init_or_cleanup(int init)
386 return ret; 382 return ret;
387} 383}
388 384
389static int __init ip_nat_standalone_init(void)
390{
391 return init_or_cleanup(1);
392}
393
394static void __exit ip_nat_standalone_fini(void) 385static void __exit ip_nat_standalone_fini(void)
395{ 386{
396 init_or_cleanup(0); 387 nf_unregister_hooks(ip_nat_ops, ARRAY_SIZE(ip_nat_ops));
388 ip_nat_rule_cleanup();
389#ifdef CONFIG_XFRM
390 ip_nat_decode_session = NULL;
391 synchronize_net();
392#endif
397} 393}
398 394
399module_init(ip_nat_standalone_init); 395module_init(ip_nat_standalone_init);
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index 896a244f8f91..b93f0494362f 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -662,15 +662,11 @@ static struct nf_queue_handler nfqh = {
662 .outfn = &ipq_enqueue_packet, 662 .outfn = &ipq_enqueue_packet,
663}; 663};
664 664
665static int 665static int __init ip_queue_init(void)
666init_or_cleanup(int init)
667{ 666{
668 int status = -ENOMEM; 667 int status = -ENOMEM;
669 struct proc_dir_entry *proc; 668 struct proc_dir_entry *proc;
670 669
671 if (!init)
672 goto cleanup;
673
674 netlink_register_notifier(&ipq_nl_notifier); 670 netlink_register_notifier(&ipq_nl_notifier);
675 ipqnl = netlink_kernel_create(NETLINK_FIREWALL, 0, ipq_rcv_sk, 671 ipqnl = netlink_kernel_create(NETLINK_FIREWALL, 0, ipq_rcv_sk,
676 THIS_MODULE); 672 THIS_MODULE);
@@ -697,11 +693,6 @@ init_or_cleanup(int init)
697 } 693 }
698 return status; 694 return status;
699 695
700cleanup:
701 nf_unregister_queue_handlers(&nfqh);
702 synchronize_net();
703 ipq_flush(NF_DROP);
704
705cleanup_sysctl: 696cleanup_sysctl:
706 unregister_sysctl_table(ipq_sysctl_header); 697 unregister_sysctl_table(ipq_sysctl_header);
707 unregister_netdevice_notifier(&ipq_dev_notifier); 698 unregister_netdevice_notifier(&ipq_dev_notifier);
@@ -717,15 +708,21 @@ cleanup_netlink_notifier:
717 return status; 708 return status;
718} 709}
719 710
720static int __init ip_queue_init(void)
721{
722
723 return init_or_cleanup(1);
724}
725
726static void __exit ip_queue_fini(void) 711static void __exit ip_queue_fini(void)
727{ 712{
728 init_or_cleanup(0); 713 nf_unregister_queue_handlers(&nfqh);
714 synchronize_net();
715 ipq_flush(NF_DROP);
716
717 unregister_sysctl_table(ipq_sysctl_header);
718 unregister_netdevice_notifier(&ipq_dev_notifier);
719 proc_net_remove(IPQ_PROC_FS_NAME);
720
721 sock_release(ipqnl->sk_socket);
722 mutex_lock(&ipqnl_mutex);
723 mutex_unlock(&ipqnl_mutex);
724
725 netlink_unregister_notifier(&ipq_nl_notifier);
729} 726}
730 727
731MODULE_DESCRIPTION("IPv4 packet queue handler"); 728MODULE_DESCRIPTION("IPv4 packet queue handler");
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index e4768a31718b..aad9d28c8d71 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -725,22 +725,17 @@ static struct file_operations clusterip_proc_fops = {
725 725
726#endif /* CONFIG_PROC_FS */ 726#endif /* CONFIG_PROC_FS */
727 727
728static int init_or_cleanup(int fini) 728static int __init ipt_clusterip_init(void)
729{ 729{
730 int ret; 730 int ret;
731 731
732 if (fini) 732 ret = ipt_register_target(&clusterip_tgt);
733 goto cleanup; 733 if (ret < 0)
734 734 return ret;
735 if (ipt_register_target(&clusterip_tgt)) {
736 ret = -EINVAL;
737 goto cleanup_none;
738 }
739 735
740 if (nf_register_hook(&cip_arp_ops) < 0) { 736 ret = nf_register_hook(&cip_arp_ops);
741 ret = -EINVAL; 737 if (ret < 0)
742 goto cleanup_target; 738 goto cleanup_target;
743 }
744 739
745#ifdef CONFIG_PROC_FS 740#ifdef CONFIG_PROC_FS
746 clusterip_procdir = proc_mkdir("ipt_CLUSTERIP", proc_net); 741 clusterip_procdir = proc_mkdir("ipt_CLUSTERIP", proc_net);
@@ -753,31 +748,24 @@ static int init_or_cleanup(int fini)
753 748
754 printk(KERN_NOTICE "ClusterIP Version %s loaded successfully\n", 749 printk(KERN_NOTICE "ClusterIP Version %s loaded successfully\n",
755 CLUSTERIP_VERSION); 750 CLUSTERIP_VERSION);
756
757 return 0; 751 return 0;
758 752
759cleanup:
760 printk(KERN_NOTICE "ClusterIP Version %s unloading\n",
761 CLUSTERIP_VERSION);
762#ifdef CONFIG_PROC_FS
763 remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);
764#endif
765cleanup_hook: 753cleanup_hook:
766 nf_unregister_hook(&cip_arp_ops); 754 nf_unregister_hook(&cip_arp_ops);
767cleanup_target: 755cleanup_target:
768 ipt_unregister_target(&clusterip_tgt); 756 ipt_unregister_target(&clusterip_tgt);
769cleanup_none: 757 return ret;
770 return -EINVAL;
771}
772
773static int __init ipt_clusterip_init(void)
774{
775 return init_or_cleanup(0);
776} 758}
777 759
778static void __exit ipt_clusterip_fini(void) 760static void __exit ipt_clusterip_fini(void)
779{ 761{
780 init_or_cleanup(1); 762 printk(KERN_NOTICE "ClusterIP Version %s unloading\n",
763 CLUSTERIP_VERSION);
764#ifdef CONFIG_PROC_FS
765 remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);
766#endif
767 nf_unregister_hook(&cip_arp_ops);
768 ipt_unregister_target(&clusterip_tgt);
781} 769}
782 770
783module_init(ipt_clusterip_init); 771module_init(ipt_clusterip_init);
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 3fadaccbc582..5bc9f64d7b5b 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -432,16 +432,20 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 = {
432extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp4; 432extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp4;
433extern struct nf_conntrack_protocol nf_conntrack_protocol_udp4; 433extern struct nf_conntrack_protocol nf_conntrack_protocol_udp4;
434extern struct nf_conntrack_protocol nf_conntrack_protocol_icmp; 434extern struct nf_conntrack_protocol nf_conntrack_protocol_icmp;
435static int init_or_cleanup(int init) 435
436MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET));
437MODULE_LICENSE("GPL");
438
439static int __init nf_conntrack_l3proto_ipv4_init(void)
436{ 440{
437 int ret = 0; 441 int ret = 0;
438 442
439 if (!init) goto cleanup; 443 need_conntrack();
440 444
441 ret = nf_register_sockopt(&so_getorigdst); 445 ret = nf_register_sockopt(&so_getorigdst);
442 if (ret < 0) { 446 if (ret < 0) {
443 printk(KERN_ERR "Unable to register netfilter socket option\n"); 447 printk(KERN_ERR "Unable to register netfilter socket option\n");
444 goto cleanup_nothing; 448 return ret;
445 } 449 }
446 450
447 ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_tcp4); 451 ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_tcp4);
@@ -484,13 +488,10 @@ static int init_or_cleanup(int init)
484#endif 488#endif
485 return ret; 489 return ret;
486 490
487 cleanup:
488 synchronize_net();
489#ifdef CONFIG_SYSCTL 491#ifdef CONFIG_SYSCTL
490 unregister_sysctl_table(nf_ct_ipv4_sysctl_header);
491 cleanup_hooks: 492 cleanup_hooks:
492#endif
493 nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops)); 493 nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops));
494#endif
494 cleanup_ipv4: 495 cleanup_ipv4:
495 nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4); 496 nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4);
496 cleanup_icmp: 497 cleanup_icmp:
@@ -501,22 +502,21 @@ static int init_or_cleanup(int init)
501 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp4); 502 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp4);
502 cleanup_sockopt: 503 cleanup_sockopt:
503 nf_unregister_sockopt(&so_getorigdst); 504 nf_unregister_sockopt(&so_getorigdst);
504 cleanup_nothing:
505 return ret; 505 return ret;
506} 506}
507 507
508MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET));
509MODULE_LICENSE("GPL");
510
511static int __init nf_conntrack_l3proto_ipv4_init(void)
512{
513 need_conntrack();
514 return init_or_cleanup(1);
515}
516
517static void __exit nf_conntrack_l3proto_ipv4_fini(void) 508static void __exit nf_conntrack_l3proto_ipv4_fini(void)
518{ 509{
519 init_or_cleanup(0); 510 synchronize_net();
511#ifdef CONFIG_SYSCTL
512 unregister_sysctl_table(nf_ct_ipv4_sysctl_header);
513#endif
514 nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops));
515 nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4);
516 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_icmp);
517 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_udp4);
518 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp4);
519 nf_unregister_sockopt(&so_getorigdst);
520} 520}
521 521
522module_init(nf_conntrack_l3proto_ipv4_init); 522module_init(nf_conntrack_l3proto_ipv4_init);