net: Add sk_set_socket() helper.
In order to more easily grep for all things that set sk->sk_socket, add sk_set_socket() helper inline function. Suggested (although only half-seriously) by Evgeniy Polyakov. Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
5bbc1722d5
Коммит
972692e0db
|
@ -990,6 +990,11 @@ static inline void sock_put(struct sock *sk)
|
||||||
extern int sk_receive_skb(struct sock *sk, struct sk_buff *skb,
|
extern int sk_receive_skb(struct sock *sk, struct sk_buff *skb,
|
||||||
const int nested);
|
const int nested);
|
||||||
|
|
||||||
|
static inline void sk_set_socket(struct sock *sk, struct socket *sock)
|
||||||
|
{
|
||||||
|
sk->sk_socket = sock;
|
||||||
|
}
|
||||||
|
|
||||||
/* Detach socket from process context.
|
/* Detach socket from process context.
|
||||||
* Announce socket dead, detach it from wait queue and inode.
|
* Announce socket dead, detach it from wait queue and inode.
|
||||||
* Note that parent inode held reference count on this struct sock,
|
* Note that parent inode held reference count on this struct sock,
|
||||||
|
@ -1001,7 +1006,7 @@ static inline void sock_orphan(struct sock *sk)
|
||||||
{
|
{
|
||||||
write_lock_bh(&sk->sk_callback_lock);
|
write_lock_bh(&sk->sk_callback_lock);
|
||||||
sock_set_flag(sk, SOCK_DEAD);
|
sock_set_flag(sk, SOCK_DEAD);
|
||||||
sk->sk_socket = NULL;
|
sk_set_socket(sk, NULL);
|
||||||
sk->sk_sleep = NULL;
|
sk->sk_sleep = NULL;
|
||||||
write_unlock_bh(&sk->sk_callback_lock);
|
write_unlock_bh(&sk->sk_callback_lock);
|
||||||
}
|
}
|
||||||
|
@ -1011,7 +1016,7 @@ static inline void sock_graft(struct sock *sk, struct socket *parent)
|
||||||
write_lock_bh(&sk->sk_callback_lock);
|
write_lock_bh(&sk->sk_callback_lock);
|
||||||
sk->sk_sleep = &parent->wait;
|
sk->sk_sleep = &parent->wait;
|
||||||
parent->sk = sk;
|
parent->sk = sk;
|
||||||
sk->sk_socket = parent;
|
sk_set_socket(sk, parent);
|
||||||
security_sock_graft(sk, parent);
|
security_sock_graft(sk, parent);
|
||||||
write_unlock_bh(&sk->sk_callback_lock);
|
write_unlock_bh(&sk->sk_callback_lock);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1066,7 +1066,7 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
|
||||||
* to be taken into account in all callers. -acme
|
* to be taken into account in all callers. -acme
|
||||||
*/
|
*/
|
||||||
sk_refcnt_debug_inc(newsk);
|
sk_refcnt_debug_inc(newsk);
|
||||||
newsk->sk_socket = NULL;
|
sk_set_socket(newsk, NULL);
|
||||||
newsk->sk_sleep = NULL;
|
newsk->sk_sleep = NULL;
|
||||||
|
|
||||||
if (newsk->sk_prot->sockets_allocated)
|
if (newsk->sk_prot->sockets_allocated)
|
||||||
|
@ -1702,7 +1702,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
|
||||||
sk->sk_rcvbuf = sysctl_rmem_default;
|
sk->sk_rcvbuf = sysctl_rmem_default;
|
||||||
sk->sk_sndbuf = sysctl_wmem_default;
|
sk->sk_sndbuf = sysctl_wmem_default;
|
||||||
sk->sk_state = TCP_CLOSE;
|
sk->sk_state = TCP_CLOSE;
|
||||||
sk->sk_socket = sock;
|
sk_set_socket(sk, sock);
|
||||||
|
|
||||||
sock_set_flag(sk, SOCK_ZAPPED);
|
sock_set_flag(sk, SOCK_ZAPPED);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче