mirror of
https://github.com/torvalds/linux.git
synced 2025-08-17 23:22:18 +02:00
af_unix: Save listener for embryo socket.
This is a prep patch for the following change, where we need to fetch the listening socket from the successor embryo socket during GC. We add a new field to struct unix_sock to save a pointer to a listening socket. We set it when connect() creates a new socket, and clear it when accept() is called. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Acked-by: Paolo Abeni <pabeni@redhat.com> Link: https://lore.kernel.org/r/20240325202425.60930-8-kuniyu@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
3484f06317
commit
aed6ecef55
2 changed files with 5 additions and 1 deletions
|
@ -83,6 +83,7 @@ struct unix_sock {
|
||||||
struct path path;
|
struct path path;
|
||||||
struct mutex iolock, bindlock;
|
struct mutex iolock, bindlock;
|
||||||
struct sock *peer;
|
struct sock *peer;
|
||||||
|
struct sock *listener;
|
||||||
struct unix_vertex *vertex;
|
struct unix_vertex *vertex;
|
||||||
struct list_head link;
|
struct list_head link;
|
||||||
unsigned long inflight;
|
unsigned long inflight;
|
||||||
|
|
|
@ -979,6 +979,7 @@ static struct sock *unix_create1(struct net *net, struct socket *sock, int kern,
|
||||||
sk->sk_max_ack_backlog = net->unx.sysctl_max_dgram_qlen;
|
sk->sk_max_ack_backlog = net->unx.sysctl_max_dgram_qlen;
|
||||||
sk->sk_destruct = unix_sock_destructor;
|
sk->sk_destruct = unix_sock_destructor;
|
||||||
u = unix_sk(sk);
|
u = unix_sk(sk);
|
||||||
|
u->listener = NULL;
|
||||||
u->inflight = 0;
|
u->inflight = 0;
|
||||||
u->vertex = NULL;
|
u->vertex = NULL;
|
||||||
u->path.dentry = NULL;
|
u->path.dentry = NULL;
|
||||||
|
@ -1598,6 +1599,7 @@ restart:
|
||||||
newsk->sk_type = sk->sk_type;
|
newsk->sk_type = sk->sk_type;
|
||||||
init_peercred(newsk);
|
init_peercred(newsk);
|
||||||
newu = unix_sk(newsk);
|
newu = unix_sk(newsk);
|
||||||
|
newu->listener = other;
|
||||||
RCU_INIT_POINTER(newsk->sk_wq, &newu->peer_wq);
|
RCU_INIT_POINTER(newsk->sk_wq, &newu->peer_wq);
|
||||||
otheru = unix_sk(other);
|
otheru = unix_sk(other);
|
||||||
|
|
||||||
|
@ -1693,8 +1695,8 @@ static int unix_accept(struct socket *sock, struct socket *newsock, int flags,
|
||||||
bool kern)
|
bool kern)
|
||||||
{
|
{
|
||||||
struct sock *sk = sock->sk;
|
struct sock *sk = sock->sk;
|
||||||
struct sock *tsk;
|
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
struct sock *tsk;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = -EOPNOTSUPP;
|
err = -EOPNOTSUPP;
|
||||||
|
@ -1719,6 +1721,7 @@ static int unix_accept(struct socket *sock, struct socket *newsock, int flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
tsk = skb->sk;
|
tsk = skb->sk;
|
||||||
|
unix_sk(tsk)->listener = NULL;
|
||||||
skb_free_datagram(sk, skb);
|
skb_free_datagram(sk, skb);
|
||||||
wake_up_interruptible(&unix_sk(sk)->peer_wait);
|
wake_up_interruptible(&unix_sk(sk)->peer_wait);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue