Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e56c57d0 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net: rename sk_clone to sk_clone_lock



Make clear that sk_clone() and inet_csk_clone() return a locked socket.

Add _lock() prefix and kerneldoc.

Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9ecd04bc
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ static inline void *inet_csk_ca(const struct sock *sk)
	return (void *)inet_csk(sk)->icsk_ca_priv;
}

extern struct sock *inet_csk_clone(struct sock *sk,
extern struct sock *inet_csk_clone_lock(const struct sock *sk,
					const struct request_sock *req,
					const gfp_t priority);

+2 −2
Original line number Diff line number Diff line
@@ -1089,7 +1089,7 @@ extern struct sock *sk_alloc(struct net *net, int family,
					  struct proto *prot);
extern void			sk_free(struct sock *sk);
extern void			sk_release_kernel(struct sock *sk);
extern struct sock		*sk_clone(const struct sock *sk,
extern struct sock		*sk_clone_lock(const struct sock *sk,
					       const gfp_t priority);

extern struct sk_buff		*sock_wmalloc(struct sock *sk,
+9 −2
Original line number Diff line number Diff line
@@ -1204,7 +1204,14 @@ void sk_release_kernel(struct sock *sk)
}
EXPORT_SYMBOL(sk_release_kernel);

struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
/**
 *	sk_clone_lock - clone a socket, and lock its clone
 *	@sk: the socket to clone
 *	@priority: for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc)
 *
 *	Caller must unlock socket even in error path (bh_unlock_sock(newsk))
 */
struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
{
	struct sock *newsk;

@@ -1297,7 +1304,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
out:
	return newsk;
}
EXPORT_SYMBOL_GPL(sk_clone);
EXPORT_SYMBOL_GPL(sk_clone_lock);

void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
{
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
	 *   (* Generate a new socket and switch to that socket *)
	 *   Set S := new socket for this port pair
	 */
	struct sock *newsk = inet_csk_clone(sk, req, GFP_ATOMIC);
	struct sock *newsk = inet_csk_clone_lock(sk, req, GFP_ATOMIC);

	if (newsk != NULL) {
		struct dccp_request_sock *dreq = dccp_rsk(req);
+13 −4
Original line number Diff line number Diff line
@@ -588,10 +588,19 @@ void inet_csk_reqsk_queue_prune(struct sock *parent,
}
EXPORT_SYMBOL_GPL(inet_csk_reqsk_queue_prune);

struct sock *inet_csk_clone(struct sock *sk, const struct request_sock *req,
/**
 *	inet_csk_clone_lock - clone an inet socket, and lock its clone
 *	@sk: the socket to clone
 *	@req: request_sock
 *	@priority: for allocation (%GFP_KERNEL, %GFP_ATOMIC, etc)
 *
 *	Caller must unlock socket even in error path (bh_unlock_sock(newsk))
 */
struct sock *inet_csk_clone_lock(const struct sock *sk,
				 const struct request_sock *req,
				 const gfp_t priority)
{
	struct sock *newsk = sk_clone(sk, priority);
	struct sock *newsk = sk_clone_lock(sk, priority);

	if (newsk != NULL) {
		struct inet_connection_sock *newicsk = inet_csk(newsk);
@@ -615,7 +624,7 @@ struct sock *inet_csk_clone(struct sock *sk, const struct request_sock *req,
	}
	return newsk;
}
EXPORT_SYMBOL_GPL(inet_csk_clone);
EXPORT_SYMBOL_GPL(inet_csk_clone_lock);

/*
 * At this point, there should be no process reference to this
Loading