Skip to content

Commit

Permalink
net: Pass kern from net_proto_family.create to sk_alloc
Browse files Browse the repository at this point in the history
In preparation for changing how struct net is refcounted
on kernel sockets pass the knowledge that we are creating
a kernel socket from sock_create_kern through to sk_alloc.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
ebiederm authored and davem330 committed May 11, 2015
1 parent eeb1bd5 commit 11aa9c2
Show file tree
Hide file tree
Showing 59 changed files with 109 additions and 108 deletions.
4 changes: 2 additions & 2 deletions crypto/af_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)
if (!type)
goto unlock;

sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto);
sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, 0);
err = -ENOMEM;
if (!sk2)
goto unlock;
Expand Down Expand Up @@ -324,7 +324,7 @@ static int alg_create(struct net *net, struct socket *sock, int protocol,
return -EPROTONOSUPPORT;

err = -ENOMEM;
sk = sk_alloc(net, PF_ALG, GFP_KERNEL, &alg_proto);
sk = sk_alloc(net, PF_ALG, GFP_KERNEL, &alg_proto, kern);
if (!sk)
goto out;

Expand Down
12 changes: 6 additions & 6 deletions drivers/isdn/mISDN/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,14 @@ static const struct proto_ops data_sock_ops = {
};

static int
data_sock_create(struct net *net, struct socket *sock, int protocol)
data_sock_create(struct net *net, struct socket *sock, int protocol, int kern)
{
struct sock *sk;

if (sock->type != SOCK_DGRAM)
return -ESOCKTNOSUPPORT;

sk = sk_alloc(net, PF_ISDN, GFP_KERNEL, &mISDN_proto);
sk = sk_alloc(net, PF_ISDN, GFP_KERNEL, &mISDN_proto, kern);
if (!sk)
return -ENOMEM;

Expand Down Expand Up @@ -756,14 +756,14 @@ static const struct proto_ops base_sock_ops = {


static int
base_sock_create(struct net *net, struct socket *sock, int protocol)
base_sock_create(struct net *net, struct socket *sock, int protocol, int kern)
{
struct sock *sk;

if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;

sk = sk_alloc(net, PF_ISDN, GFP_KERNEL, &mISDN_proto);
sk = sk_alloc(net, PF_ISDN, GFP_KERNEL, &mISDN_proto, kern);
if (!sk)
return -ENOMEM;

Expand All @@ -785,7 +785,7 @@ mISDN_sock_create(struct net *net, struct socket *sock, int proto, int kern)

switch (proto) {
case ISDN_P_BASE:
err = base_sock_create(net, sock, proto);
err = base_sock_create(net, sock, proto, kern);
break;
case ISDN_P_TE_S0:
case ISDN_P_NT_S0:
Expand All @@ -799,7 +799,7 @@ mISDN_sock_create(struct net *net, struct socket *sock, int proto, int kern)
case ISDN_P_B_L2DTMF:
case ISDN_P_B_L2DSP:
case ISDN_P_B_L2DSPHDLC:
err = data_sock_create(net, sock, proto);
err = data_sock_create(net, sock, proto, kern);
break;
default:
return err;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/macvtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ static int macvtap_open(struct inode *inode, struct file *file)

err = -ENOMEM;
q = (struct macvtap_queue *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
&macvtap_proto);
&macvtap_proto, 0);
if (!q)
goto out;

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ppp/pppoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,11 @@ static struct proto pppoe_sk_proto __read_mostly = {
* Initialize a new struct sock.
*
**********************************************************************/
static int pppoe_create(struct net *net, struct socket *sock)
static int pppoe_create(struct net *net, struct socket *sock, int kern)
{
struct sock *sk;

sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppoe_sk_proto);
sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pppoe_sk_proto, kern);
if (!sk)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ppp/pppox.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static int pppox_create(struct net *net, struct socket *sock, int protocol,
!try_module_get(pppox_protos[protocol]->owner))
goto out;

rc = pppox_protos[protocol]->create(net, sock);
rc = pppox_protos[protocol]->create(net, sock, kern);

module_put(pppox_protos[protocol]->owner);
out:
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ppp/pptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,14 +561,14 @@ static void pptp_sock_destruct(struct sock *sk)
skb_queue_purge(&sk->sk_receive_queue);
}

static int pptp_create(struct net *net, struct socket *sock)
static int pptp_create(struct net *net, struct socket *sock, int kern)
{
int error = -ENOMEM;
struct sock *sk;
struct pppox_sock *po;
struct pptp_opt *opt;

sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pptp_sk_proto);
sk = sk_alloc(net, PF_PPPOX, GFP_KERNEL, &pptp_sk_proto, kern);
if (!sk)
goto out;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -2148,7 +2148,7 @@ static int tun_chr_open(struct inode *inode, struct file * file)
DBG1(KERN_INFO, "tunX: tun_chr_open\n");

tfile = (struct tun_file *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
&tun_proto);
&tun_proto, 0);
if (!tfile)
return -ENOMEM;
RCU_INIT_POINTER(tfile->tun, NULL);
Expand Down
2 changes: 1 addition & 1 deletion include/linux/if_pppox.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static inline struct sock *sk_pppox(struct pppox_sock *po)
struct module;

struct pppox_proto {
int (*create)(struct net *net, struct socket *sock);
int (*create)(struct net *net, struct socket *sock, int kern);
int (*ioctl)(struct socket *sock, unsigned int cmd,
unsigned long arg);
struct module *owner;
Expand Down
2 changes: 1 addition & 1 deletion include/net/af_vsock.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void vsock_pending_work(struct work_struct *work);
struct sock *__vsock_create(struct net *net,
struct socket *sock,
struct sock *parent,
gfp_t priority, unsigned short type);
gfp_t priority, unsigned short type, int kern);

/**** TRANSPORT ****/

Expand Down
2 changes: 1 addition & 1 deletion include/net/llc_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static __inline__ char llc_backlog_type(struct sk_buff *skb)
}

struct sock *llc_sk_alloc(struct net *net, int family, gfp_t priority,
struct proto *prot);
struct proto *prot, int kern);
void llc_sk_free(struct sock *sk);

void llc_sk_reset(struct sock *sk);
Expand Down
2 changes: 1 addition & 1 deletion include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ static inline void unlock_sock_fast(struct sock *sk, bool slow)


struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
struct proto *prot);
struct proto *prot, int kern);
void sk_free(struct sock *sk);
void sk_release_kernel(struct sock *sk);
struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority);
Expand Down
2 changes: 1 addition & 1 deletion net/appletalk/ddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ static int atalk_create(struct net *net, struct socket *sock, int protocol,
if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
goto out;
rc = -ENOMEM;
sk = sk_alloc(net, PF_APPLETALK, GFP_KERNEL, &ddp_proto);
sk = sk_alloc(net, PF_APPLETALK, GFP_KERNEL, &ddp_proto, kern);
if (!sk)
goto out;
rc = 0;
Expand Down
4 changes: 2 additions & 2 deletions net/atm/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ static struct proto vcc_proto = {
.release_cb = vcc_release_cb,
};

int vcc_create(struct net *net, struct socket *sock, int protocol, int family)
int vcc_create(struct net *net, struct socket *sock, int protocol, int family, int kern)
{
struct sock *sk;
struct atm_vcc *vcc;

sock->sk = NULL;
if (sock->type == SOCK_STREAM)
return -EINVAL;
sk = sk_alloc(net, family, GFP_KERNEL, &vcc_proto);
sk = sk_alloc(net, family, GFP_KERNEL, &vcc_proto, kern);
if (!sk)
return -ENOMEM;
sock_init_data(sock, sk);
Expand Down
2 changes: 1 addition & 1 deletion net/atm/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <linux/poll.h> /* for poll_table */


int vcc_create(struct net *net, struct socket *sock, int protocol, int family);
int vcc_create(struct net *net, struct socket *sock, int protocol, int family, int kern);
int vcc_release(struct socket *sock);
int vcc_connect(struct socket *sock, int itf, short vpi, int vci);
int vcc_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
Expand Down
2 changes: 1 addition & 1 deletion net/atm/pvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static int pvc_create(struct net *net, struct socket *sock, int protocol,
return -EAFNOSUPPORT;

sock->ops = &pvc_proto_ops;
return vcc_create(net, sock, protocol, PF_ATMPVC);
return vcc_create(net, sock, protocol, PF_ATMPVC, kern);
}

static const struct net_proto_family pvc_family_ops = {
Expand Down
2 changes: 1 addition & 1 deletion net/atm/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ static int svc_create(struct net *net, struct socket *sock, int protocol,
return -EAFNOSUPPORT;

sock->ops = &svc_proto_ops;
error = vcc_create(net, sock, protocol, AF_ATMSVC);
error = vcc_create(net, sock, protocol, AF_ATMSVC, kern);
if (error)
return error;
ATM_SD(sock)->local.sas_family = AF_ATMSVC;
Expand Down
4 changes: 2 additions & 2 deletions net/ax25/af_ax25.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol,
return -ESOCKTNOSUPPORT;
}

sk = sk_alloc(net, PF_AX25, GFP_ATOMIC, &ax25_proto);
sk = sk_alloc(net, PF_AX25, GFP_ATOMIC, &ax25_proto, kern);
if (sk == NULL)
return -ENOMEM;

Expand All @@ -881,7 +881,7 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
struct sock *sk;
ax25_cb *ax25, *oax25;

sk = sk_alloc(sock_net(osk), PF_AX25, GFP_ATOMIC, osk->sk_prot);
sk = sk_alloc(sock_net(osk), PF_AX25, GFP_ATOMIC, osk->sk_prot, 0);
if (sk == NULL)
return NULL;

Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/bnep/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static int bnep_sock_create(struct net *net, struct socket *sock, int protocol,
if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;

sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto);
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &bnep_proto, kern);
if (!sk)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/cmtp/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol,
if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;

sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto);
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &cmtp_proto, kern);
if (!sk)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/hci_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ static int hci_sock_create(struct net *net, struct socket *sock, int protocol,

sock->ops = &hci_sock_ops;

sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto);
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hci_sk_proto, kern);
if (!sk)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/hidp/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol,
if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;

sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto);
sk = sk_alloc(net, PF_BLUETOOTH, GFP_ATOMIC, &hidp_proto, kern);
if (!sk)
return -ENOMEM;

Expand Down
10 changes: 5 additions & 5 deletions net/bluetooth/l2cap_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static struct bt_sock_list l2cap_sk_list = {
static const struct proto_ops l2cap_sock_ops;
static void l2cap_sock_init(struct sock *sk, struct sock *parent);
static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
int proto, gfp_t prio);
int proto, gfp_t prio, int kern);

bool l2cap_is_socket(struct socket *sock)
{
Expand Down Expand Up @@ -1193,7 +1193,7 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(struct l2cap_chan *chan)
}

sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP,
GFP_ATOMIC);
GFP_ATOMIC, 0);
if (!sk) {
release_sock(parent);
return NULL;
Expand Down Expand Up @@ -1523,12 +1523,12 @@ static struct proto l2cap_proto = {
};

static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
int proto, gfp_t prio)
int proto, gfp_t prio, int kern)
{
struct sock *sk;
struct l2cap_chan *chan;

sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto);
sk = sk_alloc(net, PF_BLUETOOTH, prio, &l2cap_proto, kern);
if (!sk)
return NULL;

Expand Down Expand Up @@ -1574,7 +1574,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol,

sock->ops = &l2cap_sock_ops;

sk = l2cap_sock_alloc(net, sock, protocol, GFP_ATOMIC);
sk = l2cap_sock_alloc(net, sock, protocol, GFP_ATOMIC, kern);
if (!sk)
return -ENOMEM;

Expand Down
8 changes: 4 additions & 4 deletions net/bluetooth/rfcomm/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ static struct proto rfcomm_proto = {
.obj_size = sizeof(struct rfcomm_pinfo)
};

static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio)
static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio, int kern)
{
struct rfcomm_dlc *d;
struct sock *sk;

sk = sk_alloc(net, PF_BLUETOOTH, prio, &rfcomm_proto);
sk = sk_alloc(net, PF_BLUETOOTH, prio, &rfcomm_proto, kern);
if (!sk)
return NULL;

Expand Down Expand Up @@ -324,7 +324,7 @@ static int rfcomm_sock_create(struct net *net, struct socket *sock,

sock->ops = &rfcomm_sock_ops;

sk = rfcomm_sock_alloc(net, sock, protocol, GFP_ATOMIC);
sk = rfcomm_sock_alloc(net, sock, protocol, GFP_ATOMIC, kern);
if (!sk)
return -ENOMEM;

Expand Down Expand Up @@ -969,7 +969,7 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc *
goto done;
}

sk = rfcomm_sock_alloc(sock_net(parent), NULL, BTPROTO_RFCOMM, GFP_ATOMIC);
sk = rfcomm_sock_alloc(sock_net(parent), NULL, BTPROTO_RFCOMM, GFP_ATOMIC, 0);
if (!sk)
goto done;

Expand Down
8 changes: 4 additions & 4 deletions net/bluetooth/sco.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,11 @@ static struct proto sco_proto = {
.obj_size = sizeof(struct sco_pinfo)
};

static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio)
static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int proto, gfp_t prio, int kern)
{
struct sock *sk;

sk = sk_alloc(net, PF_BLUETOOTH, prio, &sco_proto);
sk = sk_alloc(net, PF_BLUETOOTH, prio, &sco_proto, kern);
if (!sk)
return NULL;

Expand Down Expand Up @@ -501,7 +501,7 @@ static int sco_sock_create(struct net *net, struct socket *sock, int protocol,

sock->ops = &sco_sock_ops;

sk = sco_sock_alloc(net, sock, protocol, GFP_ATOMIC);
sk = sco_sock_alloc(net, sock, protocol, GFP_ATOMIC, kern);
if (!sk)
return -ENOMEM;

Expand Down Expand Up @@ -1026,7 +1026,7 @@ static void sco_conn_ready(struct sco_conn *conn)
bh_lock_sock(parent);

sk = sco_sock_alloc(sock_net(parent), NULL,
BTPROTO_SCO, GFP_ATOMIC);
BTPROTO_SCO, GFP_ATOMIC, 0);
if (!sk) {
bh_unlock_sock(parent);
sco_conn_unlock(conn);
Expand Down
2 changes: 1 addition & 1 deletion net/caif/caif_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ static int caif_create(struct net *net, struct socket *sock, int protocol,
* is really not used at all in the net/core or socket.c but the
* initialization makes sure that sock->state is not uninitialized.
*/
sk = sk_alloc(net, PF_CAIF, GFP_KERNEL, &prot);
sk = sk_alloc(net, PF_CAIF, GFP_KERNEL, &prot, kern);
if (!sk)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion net/can/af_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,

sock->ops = cp->ops;

sk = sk_alloc(net, PF_CAN, GFP_KERNEL, cp->prot);
sk = sk_alloc(net, PF_CAN, GFP_KERNEL, cp->prot, kern);
if (!sk) {
err = -ENOMEM;
goto errout;
Expand Down
Loading

0 comments on commit 11aa9c2

Please sign in to comment.