Subject: Re: [PATCH v2 7/8] net/rds: rds_tcp_conn_path_shutdown must not discard messages

From: Simon Horman <[email-masked]>
Date: Thu, 17 Apr 2025 10:47:08 +0100

On Fri, Apr 11, 2025 at 11:02:06AM -0700, [email-masked] wrote:

...

> diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c
> index 30146204dc6c..a9596440a456 100644
> --- a/net/rds/tcp_listen.c
> +++ b/net/rds/tcp_listen.c
> @@ -299,6 +299,20 @@ int rds_tcp_accept_one(struct rds_tcp_net *rtn)
>  		rds_tcp_set_callbacks(new_sock, cp);
>  		rds_connect_path_complete(cp, RDS_CONN_CONNECTING);
>  	}
> +
> +	/* Since "rds_tcp_set_callbacks" happens this late
> +	 * the connection may already have been closed without
> +	 * "rds_tcp_state_change" doing its due dilligence.

nit: diligence

checkpatch.pl --codespell is your friend :)

> +	 *
> +	 * If that's the case, we simply drop the path,
> +	 * knowing that "rds_tcp_conn_path_shutdown" will
> +	 * dequeue pending messages.
> +	 */
> +	if (new_sock->sk->sk_state == TCP_CLOSE_WAIT ||
> +	    new_sock->sk->sk_state == TCP_LAST_ACK ||
> +	    new_sock->sk->sk_state == TCP_CLOSE)
> +		rds_conn_path_drop(cp, 0);
> +
>  	new_sock = NULL;
>  	ret = 0;
>  	if (conn->c_npaths == 0)