Commit 436e9f89 authored by Michal Luczaj's avatar Michal Luczaj Committed by Wentao Guan
Browse files

vsock: Allow retrying on connect() failure

stable inclusion
from stable-v6.6.76
commit 77ad90dd18aec27700a69239938eda597ef7d8e7
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBW08Q

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=77ad90dd18aec27700a69239938eda597ef7d8e7



--------------------------------

[ Upstream commit aa388c72113b7458127b709bdd7d3628af26e9b4 ]

sk_err is set when a (connectible) connect() fails. Effectively, this makes
an otherwise still healthy SS_UNCONNECTED socket impossible to use for any
subsequent connection attempts.

Clear sk_err upon trying to establish a connection.

Fixes: d021c344 ("VSOCK: Introduce VM Sockets")
Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Reviewed-by: default avatarLuigi Leonardi <leonardi@redhat.com>
Signed-off-by: default avatarMichal Luczaj <mhal@rbox.co>
Link: https://patch.msgid.link/20250128-vsock-transport-vs-autobind-v3-2-1cf57065b770@rbox.co


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
(cherry picked from commit 77ad90dd18aec27700a69239938eda597ef7d8e7)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent c69e3f6e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1453,6 +1453,11 @@ static int vsock_connect(struct socket *sock, struct sockaddr *addr,
		if (err < 0)
			goto out;

		/* sk_err might have been set as a result of an earlier
		 * (failed) connect attempt.
		 */
		sk->sk_err = 0;

		/* Mark sock as connecting and set the error code to in
		 * progress in case this is a non-blocking connect.
		 */