diff mbox series

[net-next] net/smc: return ETIMEDOUT when smc_connect_clc() timeout

Message ID 1644913490-21594-1-git-send-email-alibuda@linux.alibaba.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net/smc: return ETIMEDOUT when smc_connect_clc() timeout | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

D. Wythe Feb. 15, 2022, 8:24 a.m. UTC
From: "D. Wythe" <alibuda@linux.alibaba.com>

When smc_connect_clc() times out, it will return -EAGAIN(tcp_recvmsg
retuns -EAGAIN while timeout), then this value will passed to the
application, which is quite confusing to the applications, makes
inconsistency with TCP.

From the manual of connect, ETIMEDOUT is more suitable, and this patch
try convert EAGAIN to ETIMEDOUT in that case.

Signed-off-by: D. Wythe <alibuda@linux.alibaba.com>
---
 net/smc/af_smc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Karsten Graul Feb. 15, 2022, 1:02 p.m. UTC | #1
On 15/02/2022 09:24, D. Wythe wrote:
> From: "D. Wythe" <alibuda@linux.alibaba.com>
> 
> When smc_connect_clc() times out, it will return -EAGAIN(tcp_recvmsg
> retuns -EAGAIN while timeout), then this value will passed to the
> application, which is quite confusing to the applications, makes
> inconsistency with TCP.
> 
> From the manual of connect, ETIMEDOUT is more suitable, and this patch
> try convert EAGAIN to ETIMEDOUT in that case.

You say that the sock_recvmsg() in smc_clc_wait_msg() returns -EAGAIN?
Is there a reason why you translate it in __smc_connect() and not already in
smc_clc_wait_msg() after the call to sock_recvmsg()?
D. Wythe Feb. 16, 2022, 3:13 a.m. UTC | #2
On Tue, Feb 15, 2022 at 02:02:37PM +0100, Karsten Graul wrote:
> On 15/02/2022 09:24, D. Wythe wrote:
> > From: "D. Wythe" <alibuda@linux.alibaba.com>
> > 
> > When smc_connect_clc() times out, it will return -EAGAIN(tcp_recvmsg
> > retuns -EAGAIN while timeout), then this value will passed to the
> > application, which is quite confusing to the applications, makes
> > inconsistency with TCP.
> > 
> > From the manual of connect, ETIMEDOUT is more suitable, and this patch
> > try convert EAGAIN to ETIMEDOUT in that case.
> 
> You say that the sock_recvmsg() in smc_clc_wait_msg() returns -EAGAIN?
> Is there a reason why you translate it in __smc_connect() and not already in
> smc_clc_wait_msg() after the call to sock_recvmsg()?


Because other code that uses smc_clc_wait_msg() handles EAGAIN allready, 
and the only exception is smc_listen_work(), but it doesn't really matter for it. 

The most important thing is that this conversion needs to be determined according to 
the calling scene, convert in smc_clc_wait_msg() is not very suitable.

Thanks.
Karsten Graul Feb. 16, 2022, 10:23 a.m. UTC | #3
On 16/02/2022 04:13, D. Wythe wrote:
> On Tue, Feb 15, 2022 at 02:02:37PM +0100, Karsten Graul wrote:
>> On 15/02/2022 09:24, D. Wythe wrote:
>>> From: "D. Wythe" <alibuda@linux.alibaba.com>
>>>
>>> When smc_connect_clc() times out, it will return -EAGAIN(tcp_recvmsg
>>> retuns -EAGAIN while timeout), then this value will passed to the
>>> application, which is quite confusing to the applications, makes
>>> inconsistency with TCP.
>>>
>>> From the manual of connect, ETIMEDOUT is more suitable, and this patch
>>> try convert EAGAIN to ETIMEDOUT in that case.
>>
>> You say that the sock_recvmsg() in smc_clc_wait_msg() returns -EAGAIN?
>> Is there a reason why you translate it in __smc_connect() and not already in
>> smc_clc_wait_msg() after the call to sock_recvmsg()?
> 
> 
> Because other code that uses smc_clc_wait_msg() handles EAGAIN allready, 
> and the only exception is smc_listen_work(), but it doesn't really matter for it. 
> 
> The most important thing is that this conversion needs to be determined according to 
> the calling scene, convert in smc_clc_wait_msg() is not very suitable.

Okay I understand, thank you.

Reviewed-by: Karsten Graul <kgraul@linux.ibm.com>
Jakub Kicinski Feb. 17, 2022, 4:32 a.m. UTC | #4
On Wed, 16 Feb 2022 11:23:12 +0100 Karsten Graul wrote:
> On 16/02/2022 04:13, D. Wythe wrote:
> > Because other code that uses smc_clc_wait_msg() handles EAGAIN allready, 
> > and the only exception is smc_listen_work(), but it doesn't really matter for it. 
> > 
> > The most important thing is that this conversion needs to be determined according to 
> > the calling scene, convert in smc_clc_wait_msg() is not very suitable.  
> 
> Okay I understand, thank you.
> 
> Reviewed-by: Karsten Graul <kgraul@linux.ibm.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 246c874..38a4064 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1372,8 +1372,14 @@  static int __smc_connect(struct smc_sock *smc)
 
 	/* perform CLC handshake */
 	rc = smc_connect_clc(smc, aclc2, ini);
-	if (rc)
+	if (rc) {
+		/* -EAGAIN on timeout, see tcp_recvmsg() */
+		if (rc == -EAGAIN) {
+			rc = -ETIMEDOUT;
+			smc->sk.sk_err = ETIMEDOUT;
+		}
 		goto vlan_cleanup;
+	}
 
 	/* check if smc modes and versions of CLC proposal and accept match */
 	rc = smc_connect_check_aclc(ini, aclc);