Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Denis V. Lunev and committed by
David S. Miller
eee4fe4d 8258175c

+14 -21
+1 -1
include/net/inet_common.h
··· 39 39 extern int inet_ioctl(struct socket *sock, 40 40 unsigned int cmd, unsigned long arg); 41 41 42 - extern int inet_ctl_sock_create(struct socket **sock, 42 + extern int inet_ctl_sock_create(struct sock **sk, 43 43 unsigned short family, 44 44 unsigned short type, 45 45 unsigned char protocol);
+1 -3
net/dccp/ipv4.c
··· 991 991 992 992 static int __init dccp_v4_init(void) 993 993 { 994 - struct socket *socket; 995 994 int err = proto_register(&dccp_v4_prot, 1); 996 995 997 996 if (err != 0) ··· 1002 1003 1003 1004 inet_register_protosw(&dccp_v4_protosw); 1004 1005 1005 - err = inet_ctl_sock_create(&socket, PF_INET, 1006 + err = inet_ctl_sock_create(&dccp_v4_ctl_sk, PF_INET, 1006 1007 SOCK_DCCP, IPPROTO_DCCP); 1007 1008 if (err) 1008 1009 goto out_unregister_protosw; 1009 - dccp_v4_ctl_sk = socket->sk; 1010 1010 out: 1011 1011 return err; 1012 1012 out_unregister_protosw:
+1 -3
net/dccp/ipv6.c
··· 1173 1173 1174 1174 static int __init dccp_v6_init(void) 1175 1175 { 1176 - struct socket *socket; 1177 1176 int err = proto_register(&dccp_v6_prot, 1); 1178 1177 1179 1178 if (err != 0) ··· 1184 1185 1185 1186 inet6_register_protosw(&dccp_v6_protosw); 1186 1187 1187 - err = inet_ctl_sock_create(&socket, PF_INET6, 1188 + err = inet_ctl_sock_create(&dccp_v6_ctl_sk, PF_INET6, 1188 1189 SOCK_DCCP, IPPROTO_DCCP); 1189 1190 if (err != 0) 1190 1191 goto out_unregister_protosw; 1191 - dccp_v6_ctl_sk = socket->sk; 1192 1192 out: 1193 1193 return err; 1194 1194 out_unregister_protosw:
+7 -5
net/ipv4/af_inet.c
··· 1250 1250 return segs; 1251 1251 } 1252 1252 1253 - int inet_ctl_sock_create(struct socket **sock, unsigned short family, 1253 + int inet_ctl_sock_create(struct sock **sk, unsigned short family, 1254 1254 unsigned short type, unsigned char protocol) 1255 1255 { 1256 - int rc = sock_create_kern(family, type, protocol, sock); 1256 + struct socket *sock; 1257 + int rc = sock_create_kern(family, type, protocol, &sock); 1257 1258 1258 1259 if (rc == 0) { 1259 - (*sock)->sk->sk_allocation = GFP_ATOMIC; 1260 - inet_sk((*sock)->sk)->uc_ttl = -1; 1260 + *sk = sock->sk; 1261 + (*sk)->sk_allocation = GFP_ATOMIC; 1262 + inet_sk(*sk)->uc_ttl = -1; 1261 1263 /* 1262 1264 * Unhash it so that IP input processing does not even see it, 1263 1265 * we do not wish this socket to see incoming packets. 1264 1266 */ 1265 - (*sock)->sk->sk_prot->unhash((*sock)->sk); 1267 + (*sk)->sk_prot->unhash(*sk); 1266 1268 } 1267 1269 return rc; 1268 1270 }
+1 -3
net/ipv4/tcp_ipv4.c
··· 2490 2490 2491 2491 void __init tcp_v4_init(void) 2492 2492 { 2493 - struct socket *__tcp_socket; 2494 - if (inet_ctl_sock_create(&__tcp_socket, PF_INET, SOCK_RAW, 2493 + if (inet_ctl_sock_create(&tcp_sock, PF_INET, SOCK_RAW, 2495 2494 IPPROTO_TCP) < 0) 2496 2495 panic("Failed to create the TCP control socket.\n"); 2497 - tcp_sock = __tcp_socket->sk; 2498 2496 } 2499 2497 2500 2498 EXPORT_SYMBOL(ipv4_specific);
+2 -3
net/ipv6/tcp_ipv6.c
··· 2200 2200 static int tcpv6_net_init(struct net *net) 2201 2201 { 2202 2202 int err; 2203 - struct socket *sock; 2204 2203 struct sock *sk; 2205 2204 2206 - err = inet_ctl_sock_create(&sock, PF_INET6, SOCK_RAW, IPPROTO_TCP); 2205 + err = inet_ctl_sock_create(&sk, PF_INET6, SOCK_RAW, IPPROTO_TCP); 2207 2206 if (err) 2208 2207 return err; 2209 2208 2210 - net->ipv6.tcp_sk = sk = sock->sk; 2209 + net->ipv6.tcp_sk = sk; 2211 2210 sk_change_net(sk, net); 2212 2211 return err; 2213 2212 }
+1 -3
net/sctp/protocol.c
··· 674 674 { 675 675 int err; 676 676 sa_family_t family; 677 - struct socket *socket; 678 677 679 678 if (sctp_get_pf_specific(PF_INET6)) 680 679 family = PF_INET6; 681 680 else 682 681 family = PF_INET; 683 682 684 - err = inet_ctl_sock_create(&socket, family, 683 + err = inet_ctl_sock_create(&sctp_ctl_sock, family, 685 684 SOCK_SEQPACKET, IPPROTO_SCTP); 686 685 if (err < 0) { 687 686 printk(KERN_ERR 688 687 "SCTP: Failed to create the SCTP control socket.\n"); 689 688 return err; 690 689 } 691 - sctp_ctl_sock = socket->sk; 692 690 return 0; 693 691 } 694 692