From 918b5fba7b34ce9faefa6c445898b6f09b8cb5d4 Mon Sep 17 00:00:00 2001 From: "D. Wythe" Date: Mon, 21 Jul 2025 14:49:14 +0800 Subject: [PATCH] anolis: net/smc: Align connection shutdown behavior with TCP When an SMC connection is terminated abnormally (e.g., one end crashes), the current implementation may only report EPOLLHUP or EPOLLERR to application, omitting the EPOLLIN event. This can cause applications that rely on standard TCP semantics to misbehave, with some even entering a 100% CPU busy-loop in poll(). For comparison, the TCP implementation handles this in its tcp_done() function, which explicitly sets: sk->sk_shutdown = SHUTDOWN_MASK; To align SMC's behavior with TCP's by setting the full SHUTDOWN_MASK on sk->sk_shutdown within smc_conn_free(). This ensures that a read shutdown is also signaled, which correctly triggers the expected EPOLLIN | EPOLLHUP event set and avoid the application-level issue. Signed-off-by: D. Wythe --- net/smc/smc_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index 12615a9794bc..2e12bbf99f9e 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -1354,6 +1354,7 @@ static void smc_buf_unuse(struct smc_connection *conn, /* remove a finished connection from its link group */ void smc_conn_free(struct smc_connection *conn) { + struct smc_sock *smc = container_of(conn, struct smc_sock, conn); struct smc_link_group *lgr = conn->lgr; if (!lgr || conn->freed) @@ -1363,6 +1364,7 @@ void smc_conn_free(struct smc_connection *conn) return; conn->freed = 1; + smc->sk.sk_shutdown = SHUTDOWN_MASK; if (!smc_conn_lgr_valid(conn)) /* Connection has already unregistered from * link group. -- Gitee