Skip to content

Commit

Permalink
net/smc: Fix loop in smc_listen
Browse files Browse the repository at this point in the history
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.

Fixes: a60a2b1 ("net/smc: reduce active tcp_listen workers")
Signed-off-by: Guo DaXing <guodaxing@huawei.com>
Acked-by: Tony Lu <tonylu@linux.alibaba.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Guo DaXing authored and Jakub Kicinski committed Nov 25, 2021
1 parent 587acad commit 9ebb0c4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/smc/af_smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2134,8 +2134,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;
Expand Down

0 comments on commit 9ebb0c4

Please sign in to comment.