@@ -28,7 +28,8 @@ static int nfc_sock_create(struct net *net, struct socket *sock, int proto,
read_lock(&proto_tab_lock);
if (proto_tab[proto] && try_module_get(proto_tab[proto]->owner)) {
- rc = proto_tab[proto]->create(net, sock, proto_tab[proto], kern);
+ rc = proto_tab[proto]->create(net, sock, proto_tab[proto],
+ kern, hold_net);
module_put(proto_tab[proto]->owner);
}
read_unlock(&proto_tab_lock);
@@ -211,7 +211,8 @@ void nfc_llcp_send_to_raw_sock(struct nfc_llcp_local *local,
struct sk_buff *skb, u8 direction);
/* Sock API */
-struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp, int kern);
+struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp,
+ bool kern, bool hold_net);
void nfc_llcp_sock_free(struct nfc_llcp_sock *sock);
void nfc_llcp_accept_unlink(struct sock *sk);
void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk);
@@ -965,7 +965,8 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local,
sock->ssap = ssap;
}
- new_sk = nfc_llcp_sock_alloc(NULL, parent->sk_type, GFP_ATOMIC, 0);
+ new_sk = nfc_llcp_sock_alloc(NULL, parent->sk_type, GFP_ATOMIC,
+ false, true);
if (new_sk == NULL) {
reason = LLCP_DM_REJ;
release_sock(&sock->sk);
@@ -971,7 +971,8 @@ static void llcp_sock_destruct(struct sock *sk)
}
}
-struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp, int kern)
+struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp,
+ bool kern, bool hold_net)
{
struct sock *sk;
struct nfc_llcp_sock *llcp_sock;
@@ -1022,7 +1023,8 @@ void nfc_llcp_sock_free(struct nfc_llcp_sock *sock)
}
static int llcp_sock_create(struct net *net, struct socket *sock,
- const struct nfc_protocol *nfc_proto, int kern)
+ const struct nfc_protocol *nfc_proto,
+ bool kern, bool hold_net)
{
struct sock *sk;
@@ -1041,7 +1043,7 @@ static int llcp_sock_create(struct net *net, struct socket *sock,
sock->ops = &llcp_sock_ops;
}
- sk = nfc_llcp_sock_alloc(sock, sock->type, GFP_ATOMIC, kern);
+ sk = nfc_llcp_sock_alloc(sock, sock->type, GFP_ATOMIC, kern, hold_net);
if (sk == NULL)
return -ENOMEM;
@@ -21,7 +21,8 @@ struct nfc_protocol {
struct proto *proto;
struct module *owner;
int (*create)(struct net *net, struct socket *sock,
- const struct nfc_protocol *nfc_proto, int kern);
+ const struct nfc_protocol *nfc_proto,
+ bool kern, bool hold_net);
};
struct nfc_rawsock {
@@ -321,7 +321,8 @@ static void rawsock_destruct(struct sock *sk)
}
static int rawsock_create(struct net *net, struct socket *sock,
- const struct nfc_protocol *nfc_proto, int kern)
+ const struct nfc_protocol *nfc_proto,
+ bool kern, bool hold_net)
{
struct sock *sk;
We will introduce a new API to create a kernel socket with netns refcnt held. Then, sk_alloc() need the hold_net flag passed to nfc_sock_create(). Let's pass it down to struct nfc_protocol.create() and functions that call sk_alloc(). While at it, we convert the kern flag to boolean. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> --- net/nfc/af_nfc.c | 3 ++- net/nfc/llcp.h | 3 ++- net/nfc/llcp_core.c | 3 ++- net/nfc/llcp_sock.c | 8 +++++--- net/nfc/nfc.h | 3 ++- net/nfc/rawsock.c | 3 ++- 6 files changed, 15 insertions(+), 8 deletions(-)