From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B142237AA82; Thu, 7 May 2026 15:03:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.118 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778166218; cv=none; b=T/5q/S5AYNFj//DvKjrUqTcUvZuqFK/Uvk4RJ3uFd3wCuuxodnLI4jGRawYbXMLKuGttrfgMcdEdw3Wqj4+sFmZqX7ICKocF7vtWPinURtDKUr8xmxBNe+CajLlhTGYr3AWyRxy2mxfINdQWcwbXT1BJjobNFxAuM2jAEl7y1Ag= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778166218; c=relaxed/simple; bh=RqqEmSAYe5uO5yFHnV/lHGnWfVJKUcwk0oQAySoPpuc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FoMOodpENxa2Jxgxed3PhTxEDCETxLzB6wG3mBW+dhffP1eCQ/Uko+GFc0qwwUQE3iuLrlVDuhqgiGWCzXbacWVMixAHB1wEQMsBWApkiuTYxeXwVdU1Q00qEEKqsrjjG60ENTM06u97RWeam5UphesW4dzVTi4hre4urJ3up5g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=B8vURC+N; arc=none smtp.client-ip=115.124.30.118 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="B8vURC+N" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1778166203; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; bh=gN0R7K+mFD2y2ohlTCIAYE5Mk6fJmoCLJCQhnJ8zqCc=; b=B8vURC+NgyV//UevGjIZ6Wn/v9i3r84zHtcypYdxhakVbMP6oidxv5F4rYfGbASJZS6GW2Nt7vIF6s8D47ysQhlpQ6z+PAuZOWiAiC9gwIMYMI735PlXt1IdeSISSRqMRwvcecDnclCAFm5kakrqcawjYJZ20YIvm7f+gA3FfK8= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045133197;MF=dust.li@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0X2Uqj2g_1778166201; Received: from localhost(mailfrom:dust.li@linux.alibaba.com fp:SMTPD_---0X2Uqj2g_1778166201 cluster:ay36) by smtp.aliyun-inc.com; Thu, 07 May 2026 23:03:22 +0800 Date: Thu, 7 May 2026 23:03:21 +0800 From: Dust Li To: "D. Wythe" , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sidraya Jayagond , Wenjia Zhang Cc: Karsten Graul , Mahanta Jambigi , Simon Horman , Tony Lu , Ursula Braun , Wen Gu , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org, netdev@vger.kernel.org, oliver.yang@linux.alibaba.com, pasic@linux.ibm.com Subject: Re: [PATCH net] net/smc: fix missing sk_err when TCP handshake fails Message-ID: Reply-To: dust.li@linux.alibaba.com References: <20260506014105.27093-1-alibuda@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260506014105.27093-1-alibuda@linux.alibaba.com> On 2026-05-06 09:41:05, D. Wythe wrote: >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: 50717a37db03 ("net/smc: nonblocking connect rework") >Signed-off-by: D. Wythe Reviewed-by: Dust Li Best regards, Dust >--- > net/smc/af_smc.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > >diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c >index 1a565095376a..185dbed7de5d 100644 >--- a/net/smc/af_smc.c >+++ b/net/smc/af_smc.c >@@ -1628,12 +1628,8 @@ static void smc_connect_work(struct work_struct *work) > lock_sock(&smc->sk); > if (rc != 0 || smc->sk.sk_err) { > 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); >+ if (!smc->sk.sk_err) >+ smc->sk.sk_err = (rc == -EAGAIN) ? EPIPE : -rc; > sock_put(&smc->sk); /* passive closing */ > goto out; > } >-- >2.45.0