Skip to contentSkip to conversation

net/smc: Keep smc_close_final rc during active close

PATCH RESEND Applied Tony Lu 2 participants 2 messages Dec 1, 2021 – Dec 2, 2021

Subsystems (3)
lore
Share & tools
lore

Tony Lu

author reviewer
#0 lore raw

PATCH RESEND 1/1 net/smc: Keep smc_close_final rc during active close

When smc_close_final() returns error, the return code overwrites by kernel_sock_shutdown() in smc_close_active(). The return code of smc_close_final() is more important than kernel_sock_shutdown(), and it will pass to userspace directly.

Fix it by keeping both return codes, if smc_close_final() raises an error, return it or kernel_sock_shutdown()'s.

Fixes 606a63c9783a ("net/smc: Ensure the active closing peer first closes clcsock")
---
 net/smc/smc_close.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/smc/smc_close.c +6 -2
index 3715d2f5ad55..292e4d904ab6 100644
@@ -195,6 +195,7 @@ int smc_close_active(struct smc_sock *smc)
 	int old_state;
 	long timeout;
 	int rc = 0;
+	int rc1 = 0;
 
 	timeout = current->flags & PF_EXITING ?
 		  0 : sock_flag(sk, SOCK_LINGER) ?
@@ -232,8 +233,11 @@ int smc_close_active(struct smc_sock *smc)
 			/* actively shutdown clcsock before peer close it,
 			 * prevent peer from entering TIME_WAIT state.
 			 */
-			if (smc->clcsock && smc->clcsock->sk)
-				rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR);
+			if (smc->clcsock && smc->clcsock->sk) {
+				rc1 = kernel_sock_shutdown(smc->clcsock,
+							   SHUT_RDWR);
+				rc = rc ? rc : rc1;
+			}
 		} else {
 			/* peer event has changed the state */
 			goto again;
Signature · 1 line
2.32.0.3.g01195cf9f
#1 lore raw
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:

Quoted 9 lines · On Wed, 1 Dec 2021 14:42:16 +0800 you wrote:

When smc_close_final() returns error, the return code overwrites by kernel_sock_shutdown() in smc_close_active(). The return code of smc_close_final() is more important than kernel_sock_shutdown(), and it will pass to userspace directly.

Fix it by keeping both return codes, if smc_close_final() raises an error, return it or kernel_sock_shutdown()'s.

[...]

Here is the summary with links:
- [RESEND,net] net/smc: Keep smc_close_final rc during active close

    https://git.kernel.org/netdev/net/c/00e158fb91df

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html