Commit eeb1bd5c authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

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: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 140e807d
...@@ -598,7 +598,7 @@ static struct socket *drbd_try_connect(struct drbd_connection *connection) ...@@ -598,7 +598,7 @@ static struct socket *drbd_try_connect(struct drbd_connection *connection)
memcpy(&peer_in6, &connection->peer_addr, peer_addr_len); memcpy(&peer_in6, &connection->peer_addr, peer_addr_len);
what = "sock_create_kern"; what = "sock_create_kern";
err = sock_create_kern(((struct sockaddr *)&src_in6)->sa_family, err = sock_create_kern(&init_net, ((struct sockaddr *)&src_in6)->sa_family,
SOCK_STREAM, IPPROTO_TCP, &sock); SOCK_STREAM, IPPROTO_TCP, &sock);
if (err < 0) { if (err < 0) {
sock = NULL; sock = NULL;
...@@ -693,7 +693,7 @@ static int prepare_listen_socket(struct drbd_connection *connection, struct acce ...@@ -693,7 +693,7 @@ static int prepare_listen_socket(struct drbd_connection *connection, struct acce
memcpy(&my_addr, &connection->my_addr, my_addr_len); memcpy(&my_addr, &connection->my_addr, my_addr_len);
what = "sock_create_kern"; what = "sock_create_kern";
err = sock_create_kern(((struct sockaddr *)&my_addr)->sa_family, err = sock_create_kern(&init_net, ((struct sockaddr *)&my_addr)->sa_family,
SOCK_STREAM, IPPROTO_TCP, &s_listen); SOCK_STREAM, IPPROTO_TCP, &s_listen);
if (err) { if (err) {
s_listen = NULL; s_listen = NULL;
......
...@@ -85,7 +85,7 @@ int afs_open_socket(void) ...@@ -85,7 +85,7 @@ int afs_open_socket(void)
return -ENOMEM; return -ENOMEM;
} }
ret = sock_create_kern(AF_RXRPC, SOCK_DGRAM, PF_INET, &socket); ret = sock_create_kern(&init_net, AF_RXRPC, SOCK_DGRAM, PF_INET, &socket);
if (ret < 0) { if (ret < 0) {
destroy_workqueue(afs_async_calls); destroy_workqueue(afs_async_calls);
_leave(" = %d [socket]", ret); _leave(" = %d [socket]", ret);
......
...@@ -921,8 +921,8 @@ static int tcp_accept_from_sock(struct connection *con) ...@@ -921,8 +921,8 @@ static int tcp_accept_from_sock(struct connection *con)
mutex_unlock(&connections_lock); mutex_unlock(&connections_lock);
memset(&peeraddr, 0, sizeof(peeraddr)); memset(&peeraddr, 0, sizeof(peeraddr));
result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_STREAM, result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
IPPROTO_TCP, &newsock); SOCK_STREAM, IPPROTO_TCP, &newsock);
if (result < 0) if (result < 0)
return -ENOMEM; return -ENOMEM;
...@@ -1173,8 +1173,8 @@ static void tcp_connect_to_sock(struct connection *con) ...@@ -1173,8 +1173,8 @@ static void tcp_connect_to_sock(struct connection *con)
goto out; goto out;
/* Create a socket to communicate with */ /* Create a socket to communicate with */
result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_STREAM, result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
IPPROTO_TCP, &sock); SOCK_STREAM, IPPROTO_TCP, &sock);
if (result < 0) if (result < 0)
goto out_err; goto out_err;
...@@ -1258,8 +1258,8 @@ static struct socket *tcp_create_listen_sock(struct connection *con, ...@@ -1258,8 +1258,8 @@ static struct socket *tcp_create_listen_sock(struct connection *con,
addr_len = sizeof(struct sockaddr_in6); addr_len = sizeof(struct sockaddr_in6);
/* Create a socket to communicate with */ /* Create a socket to communicate with */
result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_STREAM, result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
IPPROTO_TCP, &sock); SOCK_STREAM, IPPROTO_TCP, &sock);
if (result < 0) { if (result < 0) {
log_print("Can't create listening comms socket"); log_print("Can't create listening comms socket");
goto create_out; goto create_out;
...@@ -1365,8 +1365,8 @@ static int sctp_listen_for_all(void) ...@@ -1365,8 +1365,8 @@ static int sctp_listen_for_all(void)
log_print("Using SCTP for communications"); log_print("Using SCTP for communications");
result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_SEQPACKET, result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
IPPROTO_SCTP, &sock); SOCK_SEQPACKET, IPPROTO_SCTP, &sock);
if (result < 0) { if (result < 0) {
log_print("Can't create comms socket, check SCTP is loaded"); log_print("Can't create comms socket, check SCTP is loaded");
goto out; goto out;
......
...@@ -207,7 +207,7 @@ void sock_unregister(int family); ...@@ -207,7 +207,7 @@ void sock_unregister(int family);
int __sock_create(struct net *net, int family, int type, int proto, int __sock_create(struct net *net, int family, int type, int proto,
struct socket **res, int kern); struct socket **res, int kern);
int sock_create(int family, int type, int proto, struct socket **res); int sock_create(int family, int type, int proto, struct socket **res);
int sock_create_kern(int family, int type, int proto, struct socket **res); int sock_create_kern(struct net *net, int family, int type, int proto, struct socket **res);
int sock_create_lite(int family, int type, int proto, struct socket **res); int sock_create_lite(int family, int type, int proto, struct socket **res);
void sock_release(struct socket *sock); void sock_release(struct socket *sock);
int sock_sendmsg(struct socket *sock, struct msghdr *msg); int sock_sendmsg(struct socket *sock, struct msghdr *msg);
......
...@@ -200,7 +200,7 @@ static int rfcomm_l2sock_create(struct socket **sock) ...@@ -200,7 +200,7 @@ static int rfcomm_l2sock_create(struct socket **sock)
BT_DBG(""); BT_DBG("");
err = sock_create_kern(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP, sock); err = sock_create_kern(&init_net, PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP, sock);
if (!err) { if (!err) {
struct sock *sk = (*sock)->sk; struct sock *sk = (*sock)->sk;
sk->sk_data_ready = rfcomm_l2data_ready; sk->sk_data_ready = rfcomm_l2data_ready;
......
...@@ -480,8 +480,8 @@ static int ceph_tcp_connect(struct ceph_connection *con) ...@@ -480,8 +480,8 @@ static int ceph_tcp_connect(struct ceph_connection *con)
int ret; int ret;
BUG_ON(con->sock); BUG_ON(con->sock);
ret = sock_create_kern(con->peer_addr.in_addr.ss_family, SOCK_STREAM, ret = sock_create_kern(&init_net, con->peer_addr.in_addr.ss_family,
IPPROTO_TCP, &sock); SOCK_STREAM, IPPROTO_TCP, &sock);
if (ret) if (ret)
return ret; return ret;
sock->sk->sk_allocation = GFP_NOFS; sock->sk->sk_allocation = GFP_NOFS;
......
...@@ -1430,7 +1430,7 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family, ...@@ -1430,7 +1430,7 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family,
struct net *net) struct net *net)
{ {
struct socket *sock; struct socket *sock;
int rc = sock_create_kern(family, type, protocol, &sock); int rc = sock_create_kern(&init_net, family, type, protocol, &sock);
if (rc == 0) { if (rc == 0) {
*sk = sock->sk; *sk = sock->sk;
......
...@@ -15,7 +15,7 @@ int udp_sock_create4(struct net *net, struct udp_port_cfg *cfg, ...@@ -15,7 +15,7 @@ int udp_sock_create4(struct net *net, struct udp_port_cfg *cfg,
struct socket *sock = NULL; struct socket *sock = NULL;
struct sockaddr_in udp_addr; struct sockaddr_in udp_addr;
err = sock_create_kern(AF_INET, SOCK_DGRAM, 0, &sock); err = sock_create_kern(&init_net, AF_INET, SOCK_DGRAM, 0, &sock);
if (err < 0) if (err < 0)
goto error; goto error;
......
...@@ -19,7 +19,7 @@ int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg, ...@@ -19,7 +19,7 @@ int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
int err; int err;
struct socket *sock = NULL; struct socket *sock = NULL;
err = sock_create_kern(AF_INET6, SOCK_DGRAM, 0, &sock); err = sock_create_kern(&init_net, AF_INET6, SOCK_DGRAM, 0, &sock);
if (err < 0) if (err < 0)
goto error; goto error;
......
...@@ -1399,7 +1399,7 @@ static int l2tp_tunnel_sock_create(struct net *net, ...@@ -1399,7 +1399,7 @@ static int l2tp_tunnel_sock_create(struct net *net,
if (cfg->local_ip6 && cfg->peer_ip6) { if (cfg->local_ip6 && cfg->peer_ip6) {
struct sockaddr_l2tpip6 ip6_addr = {0}; struct sockaddr_l2tpip6 ip6_addr = {0};
err = sock_create_kern(AF_INET6, SOCK_DGRAM, err = sock_create_kern(&init_net, AF_INET6, SOCK_DGRAM,
IPPROTO_L2TP, &sock); IPPROTO_L2TP, &sock);
if (err < 0) if (err < 0)
goto out; goto out;
...@@ -1429,7 +1429,7 @@ static int l2tp_tunnel_sock_create(struct net *net, ...@@ -1429,7 +1429,7 @@ static int l2tp_tunnel_sock_create(struct net *net,
{ {
struct sockaddr_l2tpip ip_addr = {0}; struct sockaddr_l2tpip ip_addr = {0};
err = sock_create_kern(AF_INET, SOCK_DGRAM, err = sock_create_kern(&init_net, AF_INET, SOCK_DGRAM,
IPPROTO_L2TP, &sock); IPPROTO_L2TP, &sock);
if (err < 0) if (err < 0)
goto out; goto out;
......
...@@ -1458,7 +1458,7 @@ static struct socket *make_send_sock(struct net *net, int id) ...@@ -1458,7 +1458,7 @@ static struct socket *make_send_sock(struct net *net, int id)
int result; int result;
/* First create a socket move it to right name space later */ /* First create a socket move it to right name space later */
result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock); result = sock_create_kern(&init_net, PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock);
if (result < 0) { if (result < 0) {
pr_err("Error during creation of socket; terminating\n"); pr_err("Error during creation of socket; terminating\n");
return ERR_PTR(result); return ERR_PTR(result);
...@@ -1518,7 +1518,7 @@ static struct socket *make_receive_sock(struct net *net, int id) ...@@ -1518,7 +1518,7 @@ static struct socket *make_receive_sock(struct net *net, int id)
int result; int result;
/* First create a socket */ /* First create a socket */
result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock); result = sock_create_kern(&init_net, PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock);
if (result < 0) { if (result < 0) {
pr_err("Error during creation of socket; terminating\n"); pr_err("Error during creation of socket; terminating\n");
return ERR_PTR(result); return ERR_PTR(result);
......
...@@ -73,8 +73,8 @@ static int rxrpc_create_local(struct rxrpc_local *local) ...@@ -73,8 +73,8 @@ static int rxrpc_create_local(struct rxrpc_local *local)
_enter("%p{%d}", local, local->srx.transport_type); _enter("%p{%d}", local, local->srx.transport_type);
/* create a socket to represent the local endpoint */ /* create a socket to represent the local endpoint */
ret = sock_create_kern(PF_INET, local->srx.transport_type, IPPROTO_UDP, ret = sock_create_kern(&init_net, PF_INET, local->srx.transport_type,
&local->socket); IPPROTO_UDP, &local->socket);
if (ret < 0) { if (ret < 0) {
_leave(" = %d [socket]", ret); _leave(" = %d [socket]", ret);
return ret; return ret;
......
...@@ -1210,9 +1210,9 @@ int sock_create(int family, int type, int protocol, struct socket **res) ...@@ -1210,9 +1210,9 @@ int sock_create(int family, int type, int protocol, struct socket **res)
} }
EXPORT_SYMBOL(sock_create); EXPORT_SYMBOL(sock_create);
int sock_create_kern(int family, int type, int protocol, struct socket **res) int sock_create_kern(struct net *net, int family, int type, int protocol, struct socket **res)
{ {
return __sock_create(&init_net, family, type, protocol, res, 1); return __sock_create(net, family, type, protocol, res, 1);
} }
EXPORT_SYMBOL(sock_create_kern); EXPORT_SYMBOL(sock_create_kern);
......
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