net/smc: avoid fallback in case of non-blocking connect
PATCH 1/1 net/smc: avoid fallback in case of non-blocking connect
From: Ursula Braun <[email protected]>
FASTOPEN is not possible with SMC. sendmsg() with msg_flag MSG_FASTOPEN triggers a fallback to TCP if the socket is in state SMC_INIT. But if a nonblocking connect is already started, fallback to TCP is no longer possible, even though the socket may still be in state SMC_INIT.
And if a nonblocking connect is already started, a listen() call does not make sense.
--- net/smc/af_smc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/smc/af_smc.c +4 -3
@@ -263,7 +263,7 @@ static int smc_bind(struct socket *sock, struct sockaddr *uaddr,/* Check if socket is already active */ rc = -EINVAL ; -if (sk->sk_state !=SMC_INIT ) +if (sk->sk_state !=SMC_INIT || smc->connect_nonblock) goto out_rel; smc->clcsock->sk->sk_reuse = sk->sk_reuse;
@@ -1390,7 +1390,8 @@ static int smc_listen(struct socket *sock, int backlog)lock_sock (sk); rc = -EINVAL ; -if ((sk->sk_state !=SMC_INIT ) && (sk->sk_state !=SMC_LISTEN )) +if ((sk->sk_state !=SMC_INIT && sk->sk_state !=SMC_LISTEN ) || + smc->connect_nonblock) goto out; rc =0 ;
@@ -1518,7 +1519,7 @@ static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) goto out;if (msg->msg_flags &MSG_FASTOPEN ) { -if (sk->sk_state ==SMC_INIT ) { +if (sk->sk_state ==SMC_INIT && !smc->connect_nonblock) {smc_switch_to_fallback (smc); smc->fallback_rsn =SMC_CLC_DECL_OPTUNSUPP ; }else {
Signature · 1 line
2.21.0
David Miller
maintainerFrom: Karsten Graul <[email protected]>
Date: Fri, 2 Aug 2019 10:47:50 +0200
Quoted 10 lines
From: Ursula Braun <[email protected]>
FASTOPEN is not possible with SMC.
sendmsg()withmsg_flagMSG_FASTOPENtriggers a fallback to TCP if the socket is in stateSMC_INIT. But if a nonblocking connect is already started, fallback to TCP is no longer possible, even though the socket may still be in stateSMC_INIT.
And if a nonblocking connect is already started, alisten()call does not make sense.
Quoted 4 lines
Reported-by [email protected]Fixes 50717a37db032 ("net/smc: nonblocking connect rework")Signed-off-by Ursula Braun <[email protected]>Signed-off-by Karsten Graul <[email protected]>
Applied and queued up for -stable.