aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-04-03 17:31:03 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-03 17:31:03 -0400
commit1ed8516f09e510e4595bc900ad9266c15aacfdd2 (patch)
treee41fa4151f3b13031291dae5b3ef5a83b3de23d8
parent5616bdd6dfeb4e36be499dbac245e4d3be90a138 (diff)
[IPV6]: Simplify IPv6 control sockets creation.
Do this by replacing sock_create_kern with inet_ctl_sock_create. Signed-off-by: Denis V. Lunev <den@openvz.org> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv6/icmp.c16
-rw-r--r--net/ipv6/mcast.c19
-rw-r--r--net/ipv6/ndisc.c12
3 files changed, 17 insertions, 30 deletions
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 227ce3d2339d..195086114e63 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -64,6 +64,7 @@
64#include <net/addrconf.h> 64#include <net/addrconf.h>
65#include <net/icmp.h> 65#include <net/icmp.h>
66#include <net/xfrm.h> 66#include <net/xfrm.h>
67#include <net/inet_common.h>
67 68
68#include <asm/uaccess.h> 69#include <asm/uaccess.h>
69#include <asm/system.h> 70#include <asm/system.h>
@@ -808,9 +809,8 @@ static int __net_init icmpv6_sk_init(struct net *net)
808 return -ENOMEM; 809 return -ENOMEM;
809 810
810 for_each_possible_cpu(i) { 811 for_each_possible_cpu(i) {
811 struct socket *sock; 812 err = inet_ctl_sock_create(&sk, PF_INET6,
812 err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, 813 SOCK_RAW, IPPROTO_ICMPV6, net);
813 &sock);
814 if (err < 0) { 814 if (err < 0) {
815 printk(KERN_ERR 815 printk(KERN_ERR
816 "Failed to initialize the ICMP6 control socket " 816 "Failed to initialize the ICMP6 control socket "
@@ -819,10 +819,8 @@ static int __net_init icmpv6_sk_init(struct net *net)
819 goto fail; 819 goto fail;
820 } 820 }
821 821
822 net->ipv6.icmp_sk[i] = sk = sock->sk; 822 net->ipv6.icmp_sk[i] = sk;
823 sk_change_net(sk, net);
824 823
825 sk->sk_allocation = GFP_ATOMIC;
826 /* 824 /*
827 * Split off their lock-class, because sk->sk_dst_lock 825 * Split off their lock-class, because sk->sk_dst_lock
828 * gets used from softirqs, which is safe for 826 * gets used from softirqs, which is safe for
@@ -837,14 +835,12 @@ static int __net_init icmpv6_sk_init(struct net *net)
837 */ 835 */
838 sk->sk_sndbuf = 836 sk->sk_sndbuf =
839 (2 * ((64 * 1024) + sizeof(struct sk_buff))); 837 (2 * ((64 * 1024) + sizeof(struct sk_buff)));
840
841 sk->sk_prot->unhash(sk);
842 } 838 }
843 return 0; 839 return 0;
844 840
845 fail: 841 fail:
846 for (j = 0; j < i; j++) 842 for (j = 0; j < i; j++)
847 sk_release_kernel(net->ipv6.icmp_sk[j]); 843 inet_ctl_sock_destroy(net->ipv6.icmp_sk[j]);
848 kfree(net->ipv6.icmp_sk); 844 kfree(net->ipv6.icmp_sk);
849 return err; 845 return err;
850} 846}
@@ -854,7 +850,7 @@ static void __net_exit icmpv6_sk_exit(struct net *net)
854 int i; 850 int i;
855 851
856 for_each_possible_cpu(i) { 852 for_each_possible_cpu(i) {
857 sk_release_kernel(net->ipv6.icmp_sk[i]); 853 inet_ctl_sock_destroy(net->ipv6.icmp_sk[i]);
858 } 854 }
859 kfree(net->ipv6.icmp_sk); 855 kfree(net->ipv6.icmp_sk);
860} 856}
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index d810cff818cf..2e6a53f3cc38 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -59,6 +59,7 @@
59#include <net/ndisc.h> 59#include <net/ndisc.h>
60#include <net/addrconf.h> 60#include <net/addrconf.h>
61#include <net/ip6_route.h> 61#include <net/ip6_route.h>
62#include <net/inet_common.h>
62 63
63#include <net/ip6_checksum.h> 64#include <net/ip6_checksum.h>
64 65
@@ -2672,12 +2673,10 @@ static void igmp6_proc_exit(struct net *net)
2672 2673
2673static int igmp6_net_init(struct net *net) 2674static int igmp6_net_init(struct net *net)
2674{ 2675{
2675 struct ipv6_pinfo *np;
2676 struct socket *sock;
2677 struct sock *sk;
2678 int err; 2676 int err;
2679 2677
2680 err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, &sock); 2678 err = inet_ctl_sock_create(&net->ipv6.igmp_sk, PF_INET6,
2679 SOCK_RAW, IPPROTO_ICMPV6, net);
2681 if (err < 0) { 2680 if (err < 0) {
2682 printk(KERN_ERR 2681 printk(KERN_ERR
2683 "Failed to initialize the IGMP6 control socket (err %d).\n", 2682 "Failed to initialize the IGMP6 control socket (err %d).\n",
@@ -2685,13 +2684,7 @@ static int igmp6_net_init(struct net *net)
2685 goto out; 2684 goto out;
2686 } 2685 }
2687 2686
2688 net->ipv6.igmp_sk = sk = sock->sk; 2687 inet6_sk(net->ipv6.igmp_sk)->hop_limit = 1;
2689 sk_change_net(sk, net);
2690 sk->sk_allocation = GFP_ATOMIC;
2691 sk->sk_prot->unhash(sk);
2692
2693 np = inet6_sk(sk);
2694 np->hop_limit = 1;
2695 2688
2696 err = igmp6_proc_init(net); 2689 err = igmp6_proc_init(net);
2697 if (err) 2690 if (err)
@@ -2700,13 +2693,13 @@ out:
2700 return err; 2693 return err;
2701 2694
2702out_sock_create: 2695out_sock_create:
2703 sk_release_kernel(net->ipv6.igmp_sk); 2696 inet_ctl_sock_destroy(net->ipv6.igmp_sk);
2704 goto out; 2697 goto out;
2705} 2698}
2706 2699
2707static void igmp6_net_exit(struct net *net) 2700static void igmp6_net_exit(struct net *net)
2708{ 2701{
2709 sk_release_kernel(net->ipv6.igmp_sk); 2702 inet_ctl_sock_destroy(net->ipv6.igmp_sk);
2710 igmp6_proc_exit(net); 2703 igmp6_proc_exit(net);
2711} 2704}
2712 2705
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 510aa747a404..06d80c6dc5ce 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -84,6 +84,7 @@
84 84
85#include <net/flow.h> 85#include <net/flow.h>
86#include <net/ip6_checksum.h> 86#include <net/ip6_checksum.h>
87#include <net/inet_common.h>
87#include <linux/proc_fs.h> 88#include <linux/proc_fs.h>
88 89
89#include <linux/netfilter.h> 90#include <linux/netfilter.h>
@@ -1731,12 +1732,12 @@ static int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, int __user *name,
1731 1732
1732static int ndisc_net_init(struct net *net) 1733static int ndisc_net_init(struct net *net)
1733{ 1734{
1734 struct socket *sock;
1735 struct ipv6_pinfo *np; 1735 struct ipv6_pinfo *np;
1736 struct sock *sk; 1736 struct sock *sk;
1737 int err; 1737 int err;
1738 1738
1739 err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, &sock); 1739 err = inet_ctl_sock_create(&sk, PF_INET6,
1740 SOCK_RAW, IPPROTO_ICMPV6, net);
1740 if (err < 0) { 1741 if (err < 0) {
1741 ND_PRINTK0(KERN_ERR 1742 ND_PRINTK0(KERN_ERR
1742 "ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n", 1743 "ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n",
@@ -1744,22 +1745,19 @@ static int ndisc_net_init(struct net *net)
1744 return err; 1745 return err;
1745 } 1746 }
1746 1747
1747 net->ipv6.ndisc_sk = sk = sock->sk; 1748 net->ipv6.ndisc_sk = sk;
1748 sk_change_net(sk, net);
1749 1749
1750 np = inet6_sk(sk); 1750 np = inet6_sk(sk);
1751 sk->sk_allocation = GFP_ATOMIC;
1752 np->hop_limit = 255; 1751 np->hop_limit = 255;
1753 /* Do not loopback ndisc messages */ 1752 /* Do not loopback ndisc messages */
1754 np->mc_loop = 0; 1753 np->mc_loop = 0;
1755 sk->sk_prot->unhash(sk);
1756 1754
1757 return 0; 1755 return 0;
1758} 1756}
1759 1757
1760static void ndisc_net_exit(struct net *net) 1758static void ndisc_net_exit(struct net *net)
1761{ 1759{
1762 sk_release_kernel(net->ipv6.ndisc_sk); 1760 inet_ctl_sock_destroy(net->ipv6.ndisc_sk);
1763} 1761}
1764 1762
1765static struct pernet_operations ndisc_net_ops = { 1763static struct pernet_operations ndisc_net_ops = {