Skip to content

Commit 9032f76

Browse files
D-Wythekuba-moo
authored andcommitted
net/smc: fix missing sk_err when TCP handshake fails
In smc_connect_work(), when the underlying TCP handshake fails, the error code (rc) must be propagated to sk_err to ensure userspace can correctly retrieve the error status via SO_ERROR. Currently, the code only handles a restricted set of error codes (e.g., EPIPE, ECONNREFUSED). If other errors occurs, such as EHOSTUNREACH, sk_err remains unset (zero). This affects applications that rely on SO_ERROR to determine connect outcome. For example, higher versions of Go's netpoller treats SO_ERROR == 0 combined with a failed getpeername() as a spurious wakeup and re-enters epoll_wait(). Under ET mode, no further edge will be generated since the socket is already in a terminal state, causing the connect to hang indefinitely or until a user-specified timeout, if one is set. Fixes: 50717a3 ("net/smc: nonblocking connect rework") Signed-off-by: D. Wythe <alibuda@linux.alibaba.com> Reviewed-by: Dust Li <dust.li@linux.alibaba.com> Link: https://patch.msgid.link/20260506014105.27093-1-alibuda@linux.alibaba.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d119775 commit 9032f76

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

net/smc/af_smc.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,12 +1628,8 @@ static void smc_connect_work(struct work_struct *work)
16281628
lock_sock(&smc->sk);
16291629
if (rc != 0 || smc->sk.sk_err) {
16301630
smc->sk.sk_state = SMC_CLOSED;
1631-
if (rc == -EPIPE || rc == -EAGAIN)
1632-
smc->sk.sk_err = EPIPE;
1633-
else if (rc == -ECONNREFUSED)
1634-
smc->sk.sk_err = ECONNREFUSED;
1635-
else if (signal_pending(current))
1636-
smc->sk.sk_err = -sock_intr_errno(timeo);
1631+
if (!smc->sk.sk_err)
1632+
smc->sk.sk_err = (rc == -EAGAIN) ? EPIPE : -rc;
16371633
sock_put(&smc->sk); /* passive closing */
16381634
goto out;
16391635
}

0 commit comments

Comments
 (0)