Thread (6 messages) flat view 6 messages, 2 authors, 2021-11-25

Re: [PATCH net 2/2] net/smc: Don't call clcsock shutdown twice when smc shutdown

From: Tony Lu <tonylu@linux.alibaba.com>
Date: 2021-11-25 12:43:56
Also in: linux-rdma, linux-s390

On Thu, Nov 25, 2021 at 12:02:06PM +0100, Karsten Graul wrote:
On 25/11/2021 07:19, Tony Lu wrote:
quoted
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 4b62c925a13e..7b04cb4d15f4 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -2373,6 +2373,7 @@ static int smc_shutdown(struct socket *sock, int how)
 	struct smc_sock *smc;
 	int rc = -EINVAL;
 	int rc1 = 0;
+	int old_state;
Reverse Christmas tree formatting, please.
Sorry for that, I will fix it in the next patch.
quoted
 
 	smc = smc_sk(sk);
 
@@ -2398,7 +2399,12 @@ static int smc_shutdown(struct socket *sock, int how)
 	}
 	switch (how) {
 	case SHUT_RDWR:		/* shutdown in both directions */
+		old_state = sk->sk_state;
 		rc = smc_close_active(smc);
+		if (old_state == SMC_ACTIVE &&
+		    sk->sk_state == SMC_PEERCLOSEWAIT1)
+			goto out_no_shutdown;
+
I would prefer a new "bool do_shutdown" instead of a goto for this skip
of the shutdown. What do you think?
I agree with you, I'd like bool condition rather than goto, which will
disturb the continuity of reading code.

I will fix it soon. Thank you.

Tony Lu
quoted
 		break;
 	case SHUT_WR:
 		rc = smc_close_shutdown_write(smc);
@@ -2410,6 +2416,8 @@ static int smc_shutdown(struct socket *sock, int how)
 	}
 	if (smc->clcsock)
 		rc1 = kernel_sock_shutdown(smc->clcsock, how);
+
+out_no_shutdown:
 	/* map sock_shutdown_cmd constants to sk_shutdown value range */
 	sk->sk_shutdown |= how + 1;
 
-- 
Karsten
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help