aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2009-11-29 10:46:07 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-01 19:15:54 -0500
commit32b51f92d858dd3002ec2240960b772518a6803b (patch)
tree481d10ca63961e62bc823922ec09d641b0567640 /net
parent23c049ca92548483d5e12c94cc983afb3040f626 (diff)
net: Simplify conntrack_proto_dccp pernet operations.
Take advantage of the new pernet automatic storage management, and stop using compatibility network namespace functions. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/nf_conntrack_proto_dccp.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
index 80abdf297b36..98916ef26f5d 100644
--- a/net/netfilter/nf_conntrack_proto_dccp.c
+++ b/net/netfilter/nf_conntrack_proto_dccp.c
@@ -810,12 +810,7 @@ static struct nf_conntrack_l4proto dccp_proto6 __read_mostly = {
810 810
811static __net_init int dccp_net_init(struct net *net) 811static __net_init int dccp_net_init(struct net *net)
812{ 812{
813 struct dccp_net *dn; 813 struct dccp_net *dn = dccp_pernet(net);
814 int err;
815
816 dn = kmalloc(sizeof(*dn), GFP_KERNEL);
817 if (!dn)
818 return -ENOMEM;
819 814
820 /* default values */ 815 /* default values */
821 dn->dccp_loose = 1; 816 dn->dccp_loose = 1;
@@ -827,16 +822,11 @@ static __net_init int dccp_net_init(struct net *net)
827 dn->dccp_timeout[CT_DCCP_CLOSING] = 64 * HZ; 822 dn->dccp_timeout[CT_DCCP_CLOSING] = 64 * HZ;
828 dn->dccp_timeout[CT_DCCP_TIMEWAIT] = 2 * DCCP_MSL; 823 dn->dccp_timeout[CT_DCCP_TIMEWAIT] = 2 * DCCP_MSL;
829 824
830 err = net_assign_generic(net, dccp_net_id, dn);
831 if (err)
832 goto out;
833
834#ifdef CONFIG_SYSCTL 825#ifdef CONFIG_SYSCTL
835 err = -ENOMEM;
836 dn->sysctl_table = kmemdup(dccp_sysctl_table, 826 dn->sysctl_table = kmemdup(dccp_sysctl_table,
837 sizeof(dccp_sysctl_table), GFP_KERNEL); 827 sizeof(dccp_sysctl_table), GFP_KERNEL);
838 if (!dn->sysctl_table) 828 if (!dn->sysctl_table)
839 goto out; 829 return -ENOMEM;
840 830
841 dn->sysctl_table[0].data = &dn->dccp_timeout[CT_DCCP_REQUEST]; 831 dn->sysctl_table[0].data = &dn->dccp_timeout[CT_DCCP_REQUEST];
842 dn->sysctl_table[1].data = &dn->dccp_timeout[CT_DCCP_RESPOND]; 832 dn->sysctl_table[1].data = &dn->dccp_timeout[CT_DCCP_RESPOND];
@@ -851,15 +841,11 @@ static __net_init int dccp_net_init(struct net *net)
851 nf_net_netfilter_sysctl_path, dn->sysctl_table); 841 nf_net_netfilter_sysctl_path, dn->sysctl_table);
852 if (!dn->sysctl_header) { 842 if (!dn->sysctl_header) {
853 kfree(dn->sysctl_table); 843 kfree(dn->sysctl_table);
854 goto out; 844 return -ENOMEM;
855 } 845 }
856#endif 846#endif
857 847
858 return 0; 848 return 0;
859
860out:
861 kfree(dn);
862 return err;
863} 849}
864 850
865static __net_exit void dccp_net_exit(struct net *net) 851static __net_exit void dccp_net_exit(struct net *net)
@@ -869,21 +855,20 @@ static __net_exit void dccp_net_exit(struct net *net)
869 unregister_net_sysctl_table(dn->sysctl_header); 855 unregister_net_sysctl_table(dn->sysctl_header);
870 kfree(dn->sysctl_table); 856 kfree(dn->sysctl_table);
871#endif 857#endif
872 kfree(dn);
873
874 net_assign_generic(net, dccp_net_id, NULL);
875} 858}
876 859
877static struct pernet_operations dccp_net_ops = { 860static struct pernet_operations dccp_net_ops = {
878 .init = dccp_net_init, 861 .init = dccp_net_init,
879 .exit = dccp_net_exit, 862 .exit = dccp_net_exit,
863 .id = &dccp_net_id,
864 .size = sizeof(struct dccp_net),
880}; 865};
881 866
882static int __init nf_conntrack_proto_dccp_init(void) 867static int __init nf_conntrack_proto_dccp_init(void)
883{ 868{
884 int err; 869 int err;
885 870
886 err = register_pernet_gen_subsys(&dccp_net_id, &dccp_net_ops); 871 err = register_pernet_subsys(&dccp_net_ops);
887 if (err < 0) 872 if (err < 0)
888 goto err1; 873 goto err1;
889 874
@@ -899,14 +884,14 @@ static int __init nf_conntrack_proto_dccp_init(void)
899err3: 884err3:
900 nf_conntrack_l4proto_unregister(&dccp_proto4); 885 nf_conntrack_l4proto_unregister(&dccp_proto4);
901err2: 886err2:
902 unregister_pernet_gen_subsys(dccp_net_id, &dccp_net_ops); 887 unregister_pernet_subsys(&dccp_net_ops);
903err1: 888err1:
904 return err; 889 return err;
905} 890}
906 891
907static void __exit nf_conntrack_proto_dccp_fini(void) 892static void __exit nf_conntrack_proto_dccp_fini(void)
908{ 893{
909 unregister_pernet_gen_subsys(dccp_net_id, &dccp_net_ops); 894 unregister_pernet_subsys(&dccp_net_ops);
910 nf_conntrack_l4proto_unregister(&dccp_proto6); 895 nf_conntrack_l4proto_unregister(&dccp_proto6);
911 nf_conntrack_l4proto_unregister(&dccp_proto4); 896 nf_conntrack_l4proto_unregister(&dccp_proto4);
912} 897}