diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2009-11-29 10:46:14 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-01 19:15:58 -0500 |
commit | 86de8a631e90a96d136ffd877719471a0b8d8b6d (patch) | |
tree | 63c6fa083b8287a8adaebad9896645eb67f4690e /net/ipv4 | |
parent | cfb8fbf2299d0e028ac59afd5b8c94ebe53d0859 (diff) |
net: Simplify ipip 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/ipv4')
-rw-r--r-- | net/ipv4/ipip.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 7242ffcc44e5..eda04fed3379 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c | |||
@@ -775,17 +775,8 @@ static void ipip_destroy_tunnels(struct ipip_net *ipn, struct list_head *head) | |||
775 | 775 | ||
776 | static int ipip_init_net(struct net *net) | 776 | static int ipip_init_net(struct net *net) |
777 | { | 777 | { |
778 | struct ipip_net *ipn = net_generic(net, ipip_net_id); | ||
778 | int err; | 779 | int err; |
779 | struct ipip_net *ipn; | ||
780 | |||
781 | err = -ENOMEM; | ||
782 | ipn = kzalloc(sizeof(struct ipip_net), GFP_KERNEL); | ||
783 | if (ipn == NULL) | ||
784 | goto err_alloc; | ||
785 | |||
786 | err = net_assign_generic(net, ipip_net_id, ipn); | ||
787 | if (err < 0) | ||
788 | goto err_assign; | ||
789 | 780 | ||
790 | ipn->tunnels[0] = ipn->tunnels_wc; | 781 | ipn->tunnels[0] = ipn->tunnels_wc; |
791 | ipn->tunnels[1] = ipn->tunnels_l; | 782 | ipn->tunnels[1] = ipn->tunnels_l; |
@@ -812,29 +803,26 @@ err_reg_dev: | |||
812 | free_netdev(ipn->fb_tunnel_dev); | 803 | free_netdev(ipn->fb_tunnel_dev); |
813 | err_alloc_dev: | 804 | err_alloc_dev: |
814 | /* nothing */ | 805 | /* nothing */ |
815 | err_assign: | ||
816 | kfree(ipn); | ||
817 | err_alloc: | ||
818 | return err; | 806 | return err; |
819 | } | 807 | } |
820 | 808 | ||
821 | static void ipip_exit_net(struct net *net) | 809 | static void ipip_exit_net(struct net *net) |
822 | { | 810 | { |
823 | struct ipip_net *ipn; | 811 | struct ipip_net *ipn = net_generic(net, ipip_net_id); |
824 | LIST_HEAD(list); | 812 | LIST_HEAD(list); |
825 | 813 | ||
826 | ipn = net_generic(net, ipip_net_id); | ||
827 | rtnl_lock(); | 814 | rtnl_lock(); |
828 | ipip_destroy_tunnels(ipn, &list); | 815 | ipip_destroy_tunnels(ipn, &list); |
829 | unregister_netdevice_queue(ipn->fb_tunnel_dev, &list); | 816 | unregister_netdevice_queue(ipn->fb_tunnel_dev, &list); |
830 | unregister_netdevice_many(&list); | 817 | unregister_netdevice_many(&list); |
831 | rtnl_unlock(); | 818 | rtnl_unlock(); |
832 | kfree(ipn); | ||
833 | } | 819 | } |
834 | 820 | ||
835 | static struct pernet_operations ipip_net_ops = { | 821 | static struct pernet_operations ipip_net_ops = { |
836 | .init = ipip_init_net, | 822 | .init = ipip_init_net, |
837 | .exit = ipip_exit_net, | 823 | .exit = ipip_exit_net, |
824 | .id = &ipip_net_id, | ||
825 | .size = sizeof(struct ipip_net), | ||
838 | }; | 826 | }; |
839 | 827 | ||
840 | static int __init ipip_init(void) | 828 | static int __init ipip_init(void) |
@@ -848,7 +836,7 @@ static int __init ipip_init(void) | |||
848 | return -EAGAIN; | 836 | return -EAGAIN; |
849 | } | 837 | } |
850 | 838 | ||
851 | err = register_pernet_gen_device(&ipip_net_id, &ipip_net_ops); | 839 | err = register_pernet_device(&ipip_net_ops); |
852 | if (err) | 840 | if (err) |
853 | xfrm4_tunnel_deregister(&ipip_handler, AF_INET); | 841 | xfrm4_tunnel_deregister(&ipip_handler, AF_INET); |
854 | 842 | ||
@@ -860,7 +848,7 @@ static void __exit ipip_fini(void) | |||
860 | if (xfrm4_tunnel_deregister(&ipip_handler, AF_INET)) | 848 | if (xfrm4_tunnel_deregister(&ipip_handler, AF_INET)) |
861 | printk(KERN_INFO "ipip close: can't deregister tunnel\n"); | 849 | printk(KERN_INFO "ipip close: can't deregister tunnel\n"); |
862 | 850 | ||
863 | unregister_pernet_gen_device(ipip_net_id, &ipip_net_ops); | 851 | unregister_pernet_device(&ipip_net_ops); |
864 | } | 852 | } |
865 | 853 | ||
866 | module_init(ipip_init); | 854 | module_init(ipip_init); |