Commit 1ed8516f authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[IPV6]: Simplify IPv6 control sockets creation.

Do this by replacing sock_create_kern with inet_ctl_sock_create.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Acked-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5616bdd6
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#include <net/addrconf.h> #include <net/addrconf.h>
#include <net/icmp.h> #include <net/icmp.h>
#include <net/xfrm.h> #include <net/xfrm.h>
#include <net/inet_common.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -808,9 +809,8 @@ static int __net_init icmpv6_sk_init(struct net *net) ...@@ -808,9 +809,8 @@ static int __net_init icmpv6_sk_init(struct net *net)
return -ENOMEM; return -ENOMEM;
for_each_possible_cpu(i) { for_each_possible_cpu(i) {
struct socket *sock; err = inet_ctl_sock_create(&sk, PF_INET6,
err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, SOCK_RAW, IPPROTO_ICMPV6, net);
&sock);
if (err < 0) { if (err < 0) {
printk(KERN_ERR printk(KERN_ERR
"Failed to initialize the ICMP6 control socket " "Failed to initialize the ICMP6 control socket "
...@@ -819,10 +819,8 @@ static int __net_init icmpv6_sk_init(struct net *net) ...@@ -819,10 +819,8 @@ static int __net_init icmpv6_sk_init(struct net *net)
goto fail; goto fail;
} }
net->ipv6.icmp_sk[i] = sk = sock->sk; net->ipv6.icmp_sk[i] = sk;
sk_change_net(sk, net);
sk->sk_allocation = GFP_ATOMIC;
/* /*
* Split off their lock-class, because sk->sk_dst_lock * Split off their lock-class, because sk->sk_dst_lock
* gets used from softirqs, which is safe for * gets used from softirqs, which is safe for
...@@ -837,14 +835,12 @@ static int __net_init icmpv6_sk_init(struct net *net) ...@@ -837,14 +835,12 @@ static int __net_init icmpv6_sk_init(struct net *net)
*/ */
sk->sk_sndbuf = sk->sk_sndbuf =
(2 * ((64 * 1024) + sizeof(struct sk_buff))); (2 * ((64 * 1024) + sizeof(struct sk_buff)));
sk->sk_prot->unhash(sk);
} }
return 0; return 0;
fail: fail:
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
sk_release_kernel(net->ipv6.icmp_sk[j]); inet_ctl_sock_destroy(net->ipv6.icmp_sk[j]);
kfree(net->ipv6.icmp_sk); kfree(net->ipv6.icmp_sk);
return err; return err;
} }
...@@ -854,7 +850,7 @@ static void __net_exit icmpv6_sk_exit(struct net *net) ...@@ -854,7 +850,7 @@ static void __net_exit icmpv6_sk_exit(struct net *net)
int i; int i;
for_each_possible_cpu(i) { for_each_possible_cpu(i) {
sk_release_kernel(net->ipv6.icmp_sk[i]); inet_ctl_sock_destroy(net->ipv6.icmp_sk[i]);
} }
kfree(net->ipv6.icmp_sk); kfree(net->ipv6.icmp_sk);
} }
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include <net/ndisc.h> #include <net/ndisc.h>
#include <net/addrconf.h> #include <net/addrconf.h>
#include <net/ip6_route.h> #include <net/ip6_route.h>
#include <net/inet_common.h>
#include <net/ip6_checksum.h> #include <net/ip6_checksum.h>
...@@ -2672,12 +2673,10 @@ static void igmp6_proc_exit(struct net *net) ...@@ -2672,12 +2673,10 @@ static void igmp6_proc_exit(struct net *net)
static int igmp6_net_init(struct net *net) static int igmp6_net_init(struct net *net)
{ {
struct ipv6_pinfo *np;
struct socket *sock;
struct sock *sk;
int err; int err;
err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, &sock); err = inet_ctl_sock_create(&net->ipv6.igmp_sk, PF_INET6,
SOCK_RAW, IPPROTO_ICMPV6, net);
if (err < 0) { if (err < 0) {
printk(KERN_ERR printk(KERN_ERR
"Failed to initialize the IGMP6 control socket (err %d).\n", "Failed to initialize the IGMP6 control socket (err %d).\n",
...@@ -2685,13 +2684,7 @@ static int igmp6_net_init(struct net *net) ...@@ -2685,13 +2684,7 @@ static int igmp6_net_init(struct net *net)
goto out; goto out;
} }
net->ipv6.igmp_sk = sk = sock->sk; inet6_sk(net->ipv6.igmp_sk)->hop_limit = 1;
sk_change_net(sk, net);
sk->sk_allocation = GFP_ATOMIC;
sk->sk_prot->unhash(sk);
np = inet6_sk(sk);
np->hop_limit = 1;
err = igmp6_proc_init(net); err = igmp6_proc_init(net);
if (err) if (err)
...@@ -2700,13 +2693,13 @@ static int igmp6_net_init(struct net *net) ...@@ -2700,13 +2693,13 @@ static int igmp6_net_init(struct net *net)
return err; return err;
out_sock_create: out_sock_create:
sk_release_kernel(net->ipv6.igmp_sk); inet_ctl_sock_destroy(net->ipv6.igmp_sk);
goto out; goto out;
} }
static void igmp6_net_exit(struct net *net) static void igmp6_net_exit(struct net *net)
{ {
sk_release_kernel(net->ipv6.igmp_sk); inet_ctl_sock_destroy(net->ipv6.igmp_sk);
igmp6_proc_exit(net); igmp6_proc_exit(net);
} }
......
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
#include <net/flow.h> #include <net/flow.h>
#include <net/ip6_checksum.h> #include <net/ip6_checksum.h>
#include <net/inet_common.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/netfilter.h> #include <linux/netfilter.h>
...@@ -1731,12 +1732,12 @@ static int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, int __user *name, ...@@ -1731,12 +1732,12 @@ static int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, int __user *name,
static int ndisc_net_init(struct net *net) static int ndisc_net_init(struct net *net)
{ {
struct socket *sock;
struct ipv6_pinfo *np; struct ipv6_pinfo *np;
struct sock *sk; struct sock *sk;
int err; int err;
err = sock_create_kern(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, &sock); err = inet_ctl_sock_create(&sk, PF_INET6,
SOCK_RAW, IPPROTO_ICMPV6, net);
if (err < 0) { if (err < 0) {
ND_PRINTK0(KERN_ERR ND_PRINTK0(KERN_ERR
"ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n", "ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n",
...@@ -1744,22 +1745,19 @@ static int ndisc_net_init(struct net *net) ...@@ -1744,22 +1745,19 @@ static int ndisc_net_init(struct net *net)
return err; return err;
} }
net->ipv6.ndisc_sk = sk = sock->sk; net->ipv6.ndisc_sk = sk;
sk_change_net(sk, net);
np = inet6_sk(sk); np = inet6_sk(sk);
sk->sk_allocation = GFP_ATOMIC;
np->hop_limit = 255; np->hop_limit = 255;
/* Do not loopback ndisc messages */ /* Do not loopback ndisc messages */
np->mc_loop = 0; np->mc_loop = 0;
sk->sk_prot->unhash(sk);
return 0; return 0;
} }
static void ndisc_net_exit(struct net *net) static void ndisc_net_exit(struct net *net)
{ {
sk_release_kernel(net->ipv6.ndisc_sk); inet_ctl_sock_destroy(net->ipv6.ndisc_sk);
} }
static struct pernet_operations ndisc_net_ops = { static struct pernet_operations ndisc_net_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment