Skip to content

Commit ed9ea88

Browse files
q2venkuba-moo
authored andcommitted
af_unix: Remove sock->state assignment.
Both struct socket and struct sock have a variable to manage its state, sock->state and sk->sk_state. When both are used, the former typically manages syscall state and the latter manages the actual connection state. AF_UNIX only uses sk->sk_state. Let's remove unnecessary assignemnts for sock->state. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260529191829.3864438-1-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent ae4ef72 commit ed9ea88

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

net/unix/af_unix.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,6 @@ static int unix_create(struct net *net, struct socket *sock, int protocol,
11421142
if (protocol && protocol != PF_UNIX)
11431143
return -EPROTONOSUPPORT;
11441144

1145-
sock->state = SS_UNCONNECTED;
1146-
11471145
switch (sock->type) {
11481146
case SOCK_STREAM:
11491147
set_bit(SOCK_CUSTOM_SOCKOPT, &sock->flags);
@@ -1775,7 +1773,6 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr_unsized *uad
17751773
/* Set credentials */
17761774
copy_peercred(sk, other);
17771775

1778-
sock->state = SS_CONNECTED;
17791776
WRITE_ONCE(sk->sk_state, TCP_ESTABLISHED);
17801777
sock_hold(newsk);
17811778

@@ -1831,8 +1828,7 @@ static int unix_socketpair(struct socket *socka, struct socket *sockb)
18311828

18321829
ska->sk_state = TCP_ESTABLISHED;
18331830
skb->sk_state = TCP_ESTABLISHED;
1834-
socka->state = SS_CONNECTED;
1835-
sockb->state = SS_CONNECTED;
1831+
18361832
return 0;
18371833
}
18381834

@@ -1874,7 +1870,6 @@ static int unix_accept(struct socket *sock, struct socket *newsock,
18741870
/* attach accepted sock to socket */
18751871
unix_state_lock(tsk);
18761872
unix_update_edges(unix_sk(tsk));
1877-
newsock->state = SS_CONNECTED;
18781873
sock_graft(tsk, newsock);
18791874
unix_state_unlock(tsk);
18801875
return 0;

0 commit comments

Comments
 (0)