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

net: Add a struct net parameter to sock_create_kern

This is long overdue, and is part of cleaning up how we allocate kernel
sockets that don't reference count struct net.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric W. Biederman and committed by
David S. Miller
eeb1bd5c 140e807d

+26 -26
+2 -2
drivers/block/drbd/drbd_receiver.c
··· 598 598 memcpy(&peer_in6, &connection->peer_addr, peer_addr_len); 599 599 600 600 what = "sock_create_kern"; 601 - err = sock_create_kern(((struct sockaddr *)&src_in6)->sa_family, 601 + err = sock_create_kern(&init_net, ((struct sockaddr *)&src_in6)->sa_family, 602 602 SOCK_STREAM, IPPROTO_TCP, &sock); 603 603 if (err < 0) { 604 604 sock = NULL; ··· 693 693 memcpy(&my_addr, &connection->my_addr, my_addr_len); 694 694 695 695 what = "sock_create_kern"; 696 - err = sock_create_kern(((struct sockaddr *)&my_addr)->sa_family, 696 + err = sock_create_kern(&init_net, ((struct sockaddr *)&my_addr)->sa_family, 697 697 SOCK_STREAM, IPPROTO_TCP, &s_listen); 698 698 if (err) { 699 699 s_listen = NULL;
+1 -1
fs/afs/rxrpc.c
··· 85 85 return -ENOMEM; 86 86 } 87 87 88 - ret = sock_create_kern(AF_RXRPC, SOCK_DGRAM, PF_INET, &socket); 88 + ret = sock_create_kern(&init_net, AF_RXRPC, SOCK_DGRAM, PF_INET, &socket); 89 89 if (ret < 0) { 90 90 destroy_workqueue(afs_async_calls); 91 91 _leave(" = %d [socket]", ret);
+8 -8
fs/dlm/lowcomms.c
··· 921 921 mutex_unlock(&connections_lock); 922 922 923 923 memset(&peeraddr, 0, sizeof(peeraddr)); 924 - result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_STREAM, 925 - IPPROTO_TCP, &newsock); 924 + result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family, 925 + SOCK_STREAM, IPPROTO_TCP, &newsock); 926 926 if (result < 0) 927 927 return -ENOMEM; 928 928 ··· 1173 1173 goto out; 1174 1174 1175 1175 /* Create a socket to communicate with */ 1176 - result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_STREAM, 1177 - IPPROTO_TCP, &sock); 1176 + result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family, 1177 + SOCK_STREAM, IPPROTO_TCP, &sock); 1178 1178 if (result < 0) 1179 1179 goto out_err; 1180 1180 ··· 1258 1258 addr_len = sizeof(struct sockaddr_in6); 1259 1259 1260 1260 /* Create a socket to communicate with */ 1261 - result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_STREAM, 1262 - IPPROTO_TCP, &sock); 1261 + result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family, 1262 + SOCK_STREAM, IPPROTO_TCP, &sock); 1263 1263 if (result < 0) { 1264 1264 log_print("Can't create listening comms socket"); 1265 1265 goto create_out; ··· 1365 1365 1366 1366 log_print("Using SCTP for communications"); 1367 1367 1368 - result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_SEQPACKET, 1369 - IPPROTO_SCTP, &sock); 1368 + result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family, 1369 + SOCK_SEQPACKET, IPPROTO_SCTP, &sock); 1370 1370 if (result < 0) { 1371 1371 log_print("Can't create comms socket, check SCTP is loaded"); 1372 1372 goto out;
+1 -1
include/linux/net.h
··· 207 207 int __sock_create(struct net *net, int family, int type, int proto, 208 208 struct socket **res, int kern); 209 209 int sock_create(int family, int type, int proto, struct socket **res); 210 - int sock_create_kern(int family, int type, int proto, struct socket **res); 210 + int sock_create_kern(struct net *net, int family, int type, int proto, struct socket **res); 211 211 int sock_create_lite(int family, int type, int proto, struct socket **res); 212 212 void sock_release(struct socket *sock); 213 213 int sock_sendmsg(struct socket *sock, struct msghdr *msg);
+1 -1
net/bluetooth/rfcomm/core.c
··· 200 200 201 201 BT_DBG(""); 202 202 203 - err = sock_create_kern(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP, sock); 203 + err = sock_create_kern(&init_net, PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP, sock); 204 204 if (!err) { 205 205 struct sock *sk = (*sock)->sk; 206 206 sk->sk_data_ready = rfcomm_l2data_ready;
+2 -2
net/ceph/messenger.c
··· 480 480 int ret; 481 481 482 482 BUG_ON(con->sock); 483 - ret = sock_create_kern(con->peer_addr.in_addr.ss_family, SOCK_STREAM, 484 - IPPROTO_TCP, &sock); 483 + ret = sock_create_kern(&init_net, con->peer_addr.in_addr.ss_family, 484 + SOCK_STREAM, IPPROTO_TCP, &sock); 485 485 if (ret) 486 486 return ret; 487 487 sock->sk->sk_allocation = GFP_NOFS;
+1 -1
net/ipv4/af_inet.c
··· 1430 1430 struct net *net) 1431 1431 { 1432 1432 struct socket *sock; 1433 - int rc = sock_create_kern(family, type, protocol, &sock); 1433 + int rc = sock_create_kern(&init_net, family, type, protocol, &sock); 1434 1434 1435 1435 if (rc == 0) { 1436 1436 *sk = sock->sk;
+1 -1
net/ipv4/udp_tunnel.c
··· 15 15 struct socket *sock = NULL; 16 16 struct sockaddr_in udp_addr; 17 17 18 - err = sock_create_kern(AF_INET, SOCK_DGRAM, 0, &sock); 18 + err = sock_create_kern(&init_net, AF_INET, SOCK_DGRAM, 0, &sock); 19 19 if (err < 0) 20 20 goto error; 21 21
+1 -1
net/ipv6/ip6_udp_tunnel.c
··· 19 19 int err; 20 20 struct socket *sock = NULL; 21 21 22 - err = sock_create_kern(AF_INET6, SOCK_DGRAM, 0, &sock); 22 + err = sock_create_kern(&init_net, AF_INET6, SOCK_DGRAM, 0, &sock); 23 23 if (err < 0) 24 24 goto error; 25 25
+2 -2
net/l2tp/l2tp_core.c
··· 1399 1399 if (cfg->local_ip6 && cfg->peer_ip6) { 1400 1400 struct sockaddr_l2tpip6 ip6_addr = {0}; 1401 1401 1402 - err = sock_create_kern(AF_INET6, SOCK_DGRAM, 1402 + err = sock_create_kern(&init_net, AF_INET6, SOCK_DGRAM, 1403 1403 IPPROTO_L2TP, &sock); 1404 1404 if (err < 0) 1405 1405 goto out; ··· 1429 1429 { 1430 1430 struct sockaddr_l2tpip ip_addr = {0}; 1431 1431 1432 - err = sock_create_kern(AF_INET, SOCK_DGRAM, 1432 + err = sock_create_kern(&init_net, AF_INET, SOCK_DGRAM, 1433 1433 IPPROTO_L2TP, &sock); 1434 1434 if (err < 0) 1435 1435 goto out;
+2 -2
net/netfilter/ipvs/ip_vs_sync.c
··· 1458 1458 int result; 1459 1459 1460 1460 /* First create a socket move it to right name space later */ 1461 - result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock); 1461 + result = sock_create_kern(&init_net, PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock); 1462 1462 if (result < 0) { 1463 1463 pr_err("Error during creation of socket; terminating\n"); 1464 1464 return ERR_PTR(result); ··· 1518 1518 int result; 1519 1519 1520 1520 /* First create a socket */ 1521 - result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock); 1521 + result = sock_create_kern(&init_net, PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock); 1522 1522 if (result < 0) { 1523 1523 pr_err("Error during creation of socket; terminating\n"); 1524 1524 return ERR_PTR(result);
+2 -2
net/rxrpc/ar-local.c
··· 73 73 _enter("%p{%d}", local, local->srx.transport_type); 74 74 75 75 /* create a socket to represent the local endpoint */ 76 - ret = sock_create_kern(PF_INET, local->srx.transport_type, IPPROTO_UDP, 77 - &local->socket); 76 + ret = sock_create_kern(&init_net, PF_INET, local->srx.transport_type, 77 + IPPROTO_UDP, &local->socket); 78 78 if (ret < 0) { 79 79 _leave(" = %d [socket]", ret); 80 80 return ret;
+2 -2
net/socket.c
··· 1210 1210 } 1211 1211 EXPORT_SYMBOL(sock_create); 1212 1212 1213 - int sock_create_kern(int family, int type, int protocol, struct socket **res) 1213 + int sock_create_kern(struct net *net, int family, int type, int protocol, struct socket **res) 1214 1214 { 1215 - return __sock_create(&init_net, family, type, protocol, res, 1); 1215 + return __sock_create(net, family, type, protocol, res, 1); 1216 1216 } 1217 1217 EXPORT_SYMBOL(sock_create_kern); 1218 1218