Skip to content

Commit

Permalink
net: Add a struct net parameter to sock_create_kern
Browse files Browse the repository at this point in the history
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" <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ebiederm authored and davem330 committed May 11, 2015
1 parent 140e807 commit eeb1bd5
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions drivers/block/drbd/drbd_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ static struct socket *drbd_try_connect(struct drbd_connection *connection)
memcpy(&peer_in6, &connection->peer_addr, peer_addr_len);

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);
if (err < 0) {
sock = NULL;
Expand Down Expand Up @@ -693,7 +693,7 @@ static int prepare_listen_socket(struct drbd_connection *connection, struct acce
memcpy(&my_addr, &connection->my_addr, my_addr_len);

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);
if (err) {
s_listen = NULL;
Expand Down
2 changes: 1 addition & 1 deletion fs/afs/rxrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int afs_open_socket(void)
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) {
destroy_workqueue(afs_async_calls);
_leave(" = %d [socket]", ret);
Expand Down
16 changes: 8 additions & 8 deletions fs/dlm/lowcomms.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,8 +921,8 @@ static int tcp_accept_from_sock(struct connection *con)
mutex_unlock(&connections_lock);

memset(&peeraddr, 0, sizeof(peeraddr));
result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_STREAM,
IPPROTO_TCP, &newsock);
result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
SOCK_STREAM, IPPROTO_TCP, &newsock);
if (result < 0)
return -ENOMEM;

Expand Down Expand Up @@ -1173,8 +1173,8 @@ static void tcp_connect_to_sock(struct connection *con)
goto out;

/* Create a socket to communicate with */
result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_STREAM,
IPPROTO_TCP, &sock);
result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
SOCK_STREAM, IPPROTO_TCP, &sock);
if (result < 0)
goto out_err;

Expand Down Expand Up @@ -1258,8 +1258,8 @@ static struct socket *tcp_create_listen_sock(struct connection *con,
addr_len = sizeof(struct sockaddr_in6);

/* Create a socket to communicate with */
result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_STREAM,
IPPROTO_TCP, &sock);
result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
SOCK_STREAM, IPPROTO_TCP, &sock);
if (result < 0) {
log_print("Can't create listening comms socket");
goto create_out;
Expand Down Expand Up @@ -1365,8 +1365,8 @@ static int sctp_listen_for_all(void)

log_print("Using SCTP for communications");

result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_SEQPACKET,
IPPROTO_SCTP, &sock);
result = sock_create_kern(&init_net, dlm_local_addr[0]->ss_family,
SOCK_SEQPACKET, IPPROTO_SCTP, &sock);
if (result < 0) {
log_print("Can't create comms socket, check SCTP is loaded");
goto out;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void sock_unregister(int family);
int __sock_create(struct net *net, int family, int type, int proto,
struct socket **res, int kern);
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);
void sock_release(struct socket *sock);
int sock_sendmsg(struct socket *sock, struct msghdr *msg);
Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/rfcomm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static int rfcomm_l2sock_create(struct socket **sock)

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) {
struct sock *sk = (*sock)->sk;
sk->sk_data_ready = rfcomm_l2data_ready;
Expand Down
4 changes: 2 additions & 2 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ static int ceph_tcp_connect(struct ceph_connection *con)
int ret;

BUG_ON(con->sock);
ret = sock_create_kern(con->peer_addr.in_addr.ss_family, SOCK_STREAM,
IPPROTO_TCP, &sock);
ret = sock_create_kern(&init_net, con->peer_addr.in_addr.ss_family,
SOCK_STREAM, IPPROTO_TCP, &sock);
if (ret)
return ret;
sock->sk->sk_allocation = GFP_NOFS;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/af_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ int inet_ctl_sock_create(struct sock **sk, unsigned short family,
struct net *net)
{
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) {
*sk = sock->sk;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/udp_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int udp_sock_create4(struct net *net, struct udp_port_cfg *cfg,
struct socket *sock = NULL;
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)
goto error;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/ip6_udp_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
int err;
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)
goto error;

Expand Down
4 changes: 2 additions & 2 deletions net/l2tp/l2tp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ static int l2tp_tunnel_sock_create(struct net *net,
if (cfg->local_ip6 && cfg->peer_ip6) {
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);
if (err < 0)
goto out;
Expand Down Expand Up @@ -1429,7 +1429,7 @@ static int l2tp_tunnel_sock_create(struct net *net,
{
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);
if (err < 0)
goto out;
Expand Down
4 changes: 2 additions & 2 deletions net/netfilter/ipvs/ip_vs_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ static struct socket *make_send_sock(struct net *net, int id)
int result;

/* 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) {
pr_err("Error during creation of socket; terminating\n");
return ERR_PTR(result);
Expand Down Expand Up @@ -1518,7 +1518,7 @@ static struct socket *make_receive_sock(struct net *net, int id)
int result;

/* 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) {
pr_err("Error during creation of socket; terminating\n");
return ERR_PTR(result);
Expand Down
4 changes: 2 additions & 2 deletions net/rxrpc/ar-local.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ static int rxrpc_create_local(struct rxrpc_local *local)
_enter("%p{%d}", local, local->srx.transport_type);

/* create a socket to represent the local endpoint */
ret = sock_create_kern(PF_INET, local->srx.transport_type, IPPROTO_UDP,
&local->socket);
ret = sock_create_kern(&init_net, PF_INET, local->srx.transport_type,
IPPROTO_UDP, &local->socket);
if (ret < 0) {
_leave(" = %d [socket]", ret);
return ret;
Expand Down
4 changes: 2 additions & 2 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,9 +1210,9 @@ int sock_create(int family, int type, int protocol, struct socket **res)
}
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);

Expand Down

0 comments on commit eeb1bd5

Please sign in to comment.