Skip to content

Commit

Permalink
net/smc: Send out the remaining data in sndbuf before close
Browse files Browse the repository at this point in the history
The current autocork algorithms will delay the data transmission
in BH context to smc_release_cb() when sock_lock is hold by user.

So there is a possibility that when connection is being actively
closed (sock_lock is hold by user now), some corked data still
remains in sndbuf, waiting to be sent by smc_release_cb(). This
will cause:

- smc_close_stream_wait(), which is called under the sock_lock,
  has a high probability of timeout because data transmission is
  delayed until sock_lock is released.

- Unexpected data sends may happen after connction closed and use
  the rtoken which has been deleted by remote peer through
  LLC_DELETE_RKEY messages.

So this patch will try to send out the remaining corked data in
sndbuf before active close process, to ensure data integrity and
avoid unexpected data transmission after close.

Reported-by: Guangguan Wang <[email protected]>
Fixes: 6b88af8 ("net/smc: don't send in the BH context if sock_owned_by_user")
Signed-off-by: Wen Gu <[email protected]>
Acked-by: Karsten Graul <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Wen Gu authored and kuba-moo committed Mar 28, 2022
1 parent f32404a commit 906b3d6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/smc/smc_close.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ static void smc_close_stream_wait(struct smc_sock *smc, long timeout)
if (!smc_tx_prepared_sends(&smc->conn))
return;

/* Send out corked data remaining in sndbuf */
smc_tx_pending(&smc->conn);

smc->wait_close_tx_prepared = 1;
add_wait_queue(sk_sleep(sk), &wait);
while (!signal_pending(current) && timeout) {
Expand Down

0 comments on commit 906b3d6

Please sign in to comment.