From: liuyacan Date: Thu, 21 Apr 2022 09:40:27 +0000 (+0800) Subject: net/smc: sync err code when tcp connection was refused X-Git-Tag: baikal/mips/sdk5.9~3573 X-Git-Url: https://git.baikalelectronics.ru/?a=commitdiff_plain;h=55aa2b42ae0f7b96e6d41e3bcb96e21ef62f7ee6;p=kernel.git net/smc: sync err code when tcp connection was refused [ Upstream commit cfb14da644f2082192c28f398682dd4ff4e8c579 ] In the current implementation, when TCP initiates a connection to an unavailable [ip,port], ECONNREFUSED will be stored in the TCP socket, but SMC will not. However, some apps (like curl) use getsockopt(,,SO_ERROR,,) to get the error information, which makes them miss the error message and behave strangely. Fixes: e38c366065f1 ("net/smc: nonblocking connect rework") Signed-off-by: liuyacan Reviewed-by: Tony Lu Acked-by: Karsten Graul Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 499058248bdb8..fb801c249d923 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1223,6 +1223,8 @@ static void smc_connect_work(struct work_struct *work) smc->sk.sk_state = SMC_CLOSED; if (rc == -EPIPE || rc == -EAGAIN) smc->sk.sk_err = EPIPE; + else if (rc == -ECONNREFUSED) + smc->sk.sk_err = ECONNREFUSED; else if (signal_pending(current)) smc->sk.sk_err = -sock_intr_errno(timeo); sock_put(&smc->sk); /* passive closing */