]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
vsock: Allow retrying on connect() failure
authorMichal Luczaj <mhal@rbox.co>
Tue, 28 Jan 2025 13:15:28 +0000 (14:15 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 11:46:58 +0000 (12:46 +0100)
[ 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: d021c344051a ("VSOCK: Introduce VM Sockets")
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Luigi Leonardi <leonardi@redhat.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://patch.msgid.link/20250128-vsock-transport-vs-autobind-v3-2-1cf57065b770@rbox.co
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/vmw_vsock/af_vsock.c

index 53a9c0a73489bad5d4d9de1d0299b7b850462204..473ba765a4356a39f3afc3c7c2902008d3f3523b 100644 (file)
@@ -1340,6 +1340,11 @@ static int vsock_stream_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.
                 */