From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7380CC7EE22 for ; Thu, 11 May 2023 07:04:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237275AbjEKHEd (ORCPT ); Thu, 11 May 2023 03:04:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237261AbjEKHEH (ORCPT ); Thu, 11 May 2023 03:04:07 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F9186A79; Thu, 11 May 2023 00:03:42 -0700 (PDT) Received: from dggpemm100016.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QH2r40mQ6zsRBN; Thu, 11 May 2023 15:01:40 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm100016.china.huawei.com (7.185.36.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 11 May 2023 15:03:33 +0800 Received: from [10.174.150.180] (10.174.150.180) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 11 May 2023 15:03:33 +0800 Content-Type: multipart/mixed; boundary="------------SHVJ7X6OJBJvh5hGfukHDv1g" Message-ID: Date: Thu, 11 May 2023 15:03:24 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 From: Zhuang Shengen Subject: Re: [PATCH] vsock: bugfix port residue in server To: Stefano Garzarella CC: , , , , , , References: <20230510142502.2293109-1-zhuangshengen@huawei.com> In-Reply-To: X-Originating-IP: [10.174.150.180] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --------------SHVJ7X6OJBJvh5hGfukHDv1g Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit Hi Stefano: 在 2023/5/10 23:23, Stefano Garzarella 写道: > Hi, > thanks for the patch, the change LGTM, but I have the following > suggestions: > > Please avoid "bugfix" in the subject, "fix" should be enough: > https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#describe-your-changes > > > Anyway, I suggest to change the subject in > "vsock: avoid to close connected socket after the timeout" > thanks for your suggestion, I will change the subject > On Wed, May 10, 2023 at 10:25:02PM +0800, Zhuang Shengen wrote: >> When client and server establish a connection through vsock, >> the client send a request to the server to initiate the connection, >> then start a timer to wait for the server's response. When the server's >> RESPONSE message arrives, the timer also times out and exits. The >> server's RESPONSE message is processed first, and the connection is >> established. However, the client's timer also times out, the original >> processing logic of the client is to directly set the state of this >> vsock >> to CLOSE and return ETIMEDOUT, User will release the port. It will not > > What to you mean with "User" here? > The User means Client, I will delete the statement "User will release the por", it indeed difficult to understand >> notify the server when the port is released, causing the server port >> remain >> > > Can we remove this blank line? > OK >> when client's vsock_conqnect timeout,it should check sk state is > > The remote peer can't trust the other peer, indeed it will receive an > error after sending the first message and it will remove the connection, > right? > If this situation happend, the server will response a RST? Anyway the connection will not established before timeout, The sk state wont be ESTABLISHED. >> ESTABLISHED or not. if sk state is ESTABLISHED, it means the connection >> is established, the client should not set the sk state to CLOSE >> >> Note: I encountered this issue on kernel-4.18, which can be fixed by >> this patch. Then I checked the latest code in the community >> and found similar issue. >> > > In order to backport it to the stable kernels, we should add a Fixes tag: > https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#describe-your-changes > > OK, I add a Fixes: d021c344051a ("VSOCK: Introduce VM Sockets") in the new patch. I put the new patch with v2 title in the attachment, please check. Thanks, Shengen > Thanks, > Stefano > >> Signed-off-by: Zhuang Shengen >> --- >> net/vmw_vsock/af_vsock.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c >> index 413407bb646c..efb8a0937a13 100644 >> --- a/net/vmw_vsock/af_vsock.c >> +++ b/net/vmw_vsock/af_vsock.c >> @@ -1462,7 +1462,7 @@ static int vsock_connect(struct socket *sock, >> struct sockaddr *addr, >>             vsock_transport_cancel_pkt(vsk); >>             vsock_remove_connected(vsk); >>             goto out_wait; >> -        } else if (timeout == 0) { >> +        } else if ((sk->sk_state != TCP_ESTABLISHED) && (timeout == >> 0)) { >>             err = -ETIMEDOUT; >>             sk->sk_state = TCP_CLOSE; >>             sock->state = SS_UNCONNECTED; >> -- >> 2.27.0 >> > --------------SHVJ7X6OJBJvh5hGfukHDv1g Content-Type: text/plain; charset="UTF-8"; name="0001-vsock-avoid-to-close-connected-socket-after-the-time.patch" Content-Disposition: attachment; filename*0="0001-vsock-avoid-to-close-connected-socket-after-the-time.pa"; filename*1="tch" Content-Transfer-Encoding: base64 RnJvbSBiYTk4MjZjNTAxZDQ1Y2I0Njg4ZWI2NzkyNGFjNmRjODZjMTYwODhlIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBaaHVhbmcgU2hlbmdlbiA8emh1YW5nc2hlbmdlbkBo dWF3ZWkuY29tPgpEYXRlOiBXZWQsIDEwIE1heSAyMDIzIDIxOjM2OjQ2ICswODAwClN1Ympl Y3Q6IFtQQVRDSCBuZXQgdjJdIHZzb2NrOiBhdm9pZCB0byBjbG9zZSBjb25uZWN0ZWQgc29j a2V0IGFmdGVyIHRoZSB0aW1lb3V0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