[INET]: Let inet_ctl_sock_create return sock rather than socket.
All upper protocol layers are already use sock internally. 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>
This commit is contained in:
committed by
David S. Miller
parent
8258175c81
commit
eee4fe4ded
@@ -39,7 +39,7 @@ extern int inet_getname(struct socket *sock,
|
|||||||
extern int inet_ioctl(struct socket *sock,
|
extern int inet_ioctl(struct socket *sock,
|
||||||
unsigned int cmd, unsigned long arg);
|
unsigned int cmd, unsigned long arg);
|
||||||
|
|
||||||
extern int inet_ctl_sock_create(struct socket **sock,
|
extern int inet_ctl_sock_create(struct sock **sk,
|
||||||
unsigned short family,
|
unsigned short family,
|
||||||
unsigned short type,
|
unsigned short type,
|
||||||
unsigned char protocol);
|
unsigned char protocol);
|
||||||
|
@@ -991,7 +991,6 @@ static struct inet_protosw dccp_v4_protosw = {
|
|||||||
|
|
||||||
static int __init dccp_v4_init(void)
|
static int __init dccp_v4_init(void)
|
||||||
{
|
{
|
||||||
struct socket *socket;
|
|
||||||
int err = proto_register(&dccp_v4_prot, 1);
|
int err = proto_register(&dccp_v4_prot, 1);
|
||||||
|
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
@@ -1003,11 +1002,10 @@ static int __init dccp_v4_init(void)
|
|||||||
|
|
||||||
inet_register_protosw(&dccp_v4_protosw);
|
inet_register_protosw(&dccp_v4_protosw);
|
||||||
|
|
||||||
err = inet_ctl_sock_create(&socket, PF_INET,
|
err = inet_ctl_sock_create(&dccp_v4_ctl_sk, PF_INET,
|
||||||
SOCK_DCCP, IPPROTO_DCCP);
|
SOCK_DCCP, IPPROTO_DCCP);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_unregister_protosw;
|
goto out_unregister_protosw;
|
||||||
dccp_v4_ctl_sk = socket->sk;
|
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
out_unregister_protosw:
|
out_unregister_protosw:
|
||||||
|
@@ -1173,7 +1173,6 @@ static struct inet_protosw dccp_v6_protosw = {
|
|||||||
|
|
||||||
static int __init dccp_v6_init(void)
|
static int __init dccp_v6_init(void)
|
||||||
{
|
{
|
||||||
struct socket *socket;
|
|
||||||
int err = proto_register(&dccp_v6_prot, 1);
|
int err = proto_register(&dccp_v6_prot, 1);
|
||||||
|
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
@@ -1185,11 +1184,10 @@ static int __init dccp_v6_init(void)
|
|||||||
|
|
||||||
inet6_register_protosw(&dccp_v6_protosw);
|
inet6_register_protosw(&dccp_v6_protosw);
|
||||||
|
|
||||||
err = inet_ctl_sock_create(&socket, PF_INET6,
|
err = inet_ctl_sock_create(&dccp_v6_ctl_sk, PF_INET6,
|
||||||
SOCK_DCCP, IPPROTO_DCCP);
|
SOCK_DCCP, IPPROTO_DCCP);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
goto out_unregister_protosw;
|
goto out_unregister_protosw;
|
||||||
dccp_v6_ctl_sk = socket->sk;
|
|
||||||
out:
|
out:
|
||||||
return err;
|
return err;
|
||||||
out_unregister_protosw:
|
out_unregister_protosw:
|
||||||
|
@@ -1250,19 +1250,21 @@ out:
|
|||||||
return segs;
|
return segs;
|
||||||
}
|
}
|
||||||
|
|
||||||
int inet_ctl_sock_create(struct socket **sock, unsigned short family,
|
int inet_ctl_sock_create(struct sock **sk, unsigned short family,
|
||||||
unsigned short type, unsigned char protocol)
|
unsigned short type, unsigned char protocol)
|
||||||
{
|
{
|
||||||
int rc = sock_create_kern(family, type, protocol, sock);
|
struct socket *sock;
|
||||||
|
int rc = sock_create_kern(family, type, protocol, &sock);
|
||||||
|
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
(*sock)->sk->sk_allocation = GFP_ATOMIC;
|
*sk = sock->sk;
|
||||||
inet_sk((*sock)->sk)->uc_ttl = -1;
|
(*sk)->sk_allocation = GFP_ATOMIC;
|
||||||
|
inet_sk(*sk)->uc_ttl = -1;
|
||||||
/*
|
/*
|
||||||
* Unhash it so that IP input processing does not even see it,
|
* Unhash it so that IP input processing does not even see it,
|
||||||
* we do not wish this socket to see incoming packets.
|
* we do not wish this socket to see incoming packets.
|
||||||
*/
|
*/
|
||||||
(*sock)->sk->sk_prot->unhash((*sock)->sk);
|
(*sk)->sk_prot->unhash(*sk);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@@ -2490,11 +2490,9 @@ struct proto tcp_prot = {
|
|||||||
|
|
||||||
void __init tcp_v4_init(void)
|
void __init tcp_v4_init(void)
|
||||||
{
|
{
|
||||||
struct socket *__tcp_socket;
|
if (inet_ctl_sock_create(&tcp_sock, PF_INET, SOCK_RAW,
|
||||||
if (inet_ctl_sock_create(&__tcp_socket, PF_INET, SOCK_RAW,
|
|
||||||
IPPROTO_TCP) < 0)
|
IPPROTO_TCP) < 0)
|
||||||
panic("Failed to create the TCP control socket.\n");
|
panic("Failed to create the TCP control socket.\n");
|
||||||
tcp_sock = __tcp_socket->sk;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(ipv4_specific);
|
EXPORT_SYMBOL(ipv4_specific);
|
||||||
|
@@ -2200,14 +2200,13 @@ static struct inet_protosw tcpv6_protosw = {
|
|||||||
static int tcpv6_net_init(struct net *net)
|
static int tcpv6_net_init(struct net *net)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
struct socket *sock;
|
|
||||||
struct sock *sk;
|
struct sock *sk;
|
||||||
|
|
||||||
err = inet_ctl_sock_create(&sock, PF_INET6, SOCK_RAW, IPPROTO_TCP);
|
err = inet_ctl_sock_create(&sk, PF_INET6, SOCK_RAW, IPPROTO_TCP);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
net->ipv6.tcp_sk = sk = sock->sk;
|
net->ipv6.tcp_sk = sk;
|
||||||
sk_change_net(sk, net);
|
sk_change_net(sk, net);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@@ -674,21 +674,19 @@ static int sctp_ctl_sock_init(void)
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
sa_family_t family;
|
sa_family_t family;
|
||||||
struct socket *socket;
|
|
||||||
|
|
||||||
if (sctp_get_pf_specific(PF_INET6))
|
if (sctp_get_pf_specific(PF_INET6))
|
||||||
family = PF_INET6;
|
family = PF_INET6;
|
||||||
else
|
else
|
||||||
family = PF_INET;
|
family = PF_INET;
|
||||||
|
|
||||||
err = inet_ctl_sock_create(&socket, family,
|
err = inet_ctl_sock_create(&sctp_ctl_sock, family,
|
||||||
SOCK_SEQPACKET, IPPROTO_SCTP);
|
SOCK_SEQPACKET, IPPROTO_SCTP);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printk(KERN_ERR
|
printk(KERN_ERR
|
||||||
"SCTP: Failed to create the SCTP control socket.\n");
|
"SCTP: Failed to create the SCTP control socket.\n");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
sctp_ctl_sock = socket->sk;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user