netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/smc: loop in smc_listen
@ 2021-11-20  7:54 Daxing Guo
  2021-11-22  3:19 ` Tony Lu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Daxing Guo @ 2021-11-20  7:54 UTC (permalink / raw)
  To: netdev; +Cc: chenzhe, linux-s390, greg, Guo DaXing

From: Guo DaXing <guodaxing@huawei.com>

The kernel_listen function in smc_listen will fail when all the available
ports are occupied.  At this point smc->clcsock->sk->sk_data_ready has 
been changed to smc_clcsock_data_ready.  When we call smc_listen again, 
now both smc->clcsock->sk->sk_data_ready and smc->clcsk_data_ready point 
to the smc_clcsock_data_ready function.

The smc_clcsock_data_ready() function calls lsmc->clcsk_data_ready which 
now points to itself resulting in an infinite loop.

This patch restores smc->clcsock->sk->sk_data_ready with the old value.

Signed-off-by: Guo DaXing <guodaxing@huawei.com>
---
 net/smc/af_smc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 59284da9116d..078f5edf6d4d 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -2120,8 +2120,10 @@ static int smc_listen(struct socket *sock, int backlog)
 	smc->clcsock->sk->sk_user_data =
 		(void *)((uintptr_t)smc | SK_USER_DATA_NOCOPY);
 	rc = kernel_listen(smc->clcsock, backlog);
-	if (rc)
+	if (rc) {
+		smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready;
 		goto out;
+	}
 	sk->sk_max_ack_backlog = backlog;
 	sk->sk_ack_backlog = 0;
 	sk->sk_state = SMC_LISTEN;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-22  8:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <aec0a1e1964b4696b8636ce3945e6551@huawei.com>
2021-11-19  7:09 ` [PATCH] net/smc: loop in smc_listen greg
2021-11-19  9:22   ` 答复: " guodaxing
2021-11-20  7:54 Daxing Guo
2021-11-22  3:19 ` Tony Lu
2021-11-22  7:28 ` Karsten Graul
2021-11-22  8:37 ` Tony Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).