af_unix: Remove sock->state assignment.
Subsystems (3)
Kuniyuki Iwashima
maintainerPATCH 1/1 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.
--- net/unix/af_unix.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
net/unix/af_unix.c +1 -6
@@ -1142,8 +1142,6 @@ static int unix_create(struct net *net, struct socket *sock, int protocol,if (protocol && protocol !=PF_UNIX )return -EPROTONOSUPPORT ; - sock->state =SS_UNCONNECTED ; -switch (sock->type) {case SOCK_STREAM :set_bit (SOCK_CUSTOM_SOCKOPT , &sock->flags);
@@ -1775,7 +1773,6 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr_unsized *uad/* Set credentials */ copy_peercred (sk, other); - sock->state =SS_CONNECTED ;WRITE_ONCE (sk->sk_state,TCP_ESTABLISHED );sock_hold (newsk);
@@ -1831,8 +1828,7 @@ static int unix_socketpair(struct socket *socka, struct socket *sockb) ska->sk_state =TCP_ESTABLISHED ; skb->sk_state =TCP_ESTABLISHED ; - socka->state =SS_CONNECTED ; - sockb->state =SS_CONNECTED ; +return 0 ; }
@@ -1874,7 +1870,6 @@ static int unix_accept(struct socket *sock, struct socket *newsock,/* attach accepted sock to socket */ unix_state_lock (tsk);unix_update_edges (unix_sk (tsk)); - newsock->state =SS_CONNECTED ;sock_graft (tsk, newsock);unix_state_unlock (tsk);return 0 ;
Signature · 1 line
2.54.0.823.g6e5bcc1fc9-goog
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Fri, 29 May 2026 19:18:02 +0000 you wrote:
Both struct socket and struct sock have a variable to manage its state,
sock->stateandsk->sk_state.When both are used, the former typically manages syscall state and the latter manages the actual connection state.
AF_UNIXonly usessk->sk_state.[...]
Here is the summary with links:
- [v1,net-next] af_unix: Remove sock->state assignment.
https://git.kernel.org/netdev/net-next/c/ed9ea881746b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html