Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8399002rwr; Thu, 11 May 2023 00:12:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5oxnw+iDhUP8mOp7u+eCiLlz8rpVY/tBSi1lSbfAvYAEWo3Cf5u4G8cvwydRN/tz6aUt8J X-Received: by 2002:a17:902:9897:b0:1ab:253e:6906 with SMTP id s23-20020a170902989700b001ab253e6906mr18501085plp.67.1683789164308; Thu, 11 May 2023 00:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683789164; cv=none; d=google.com; s=arc-20160816; b=mA9nXwdc0VB84RQV2e05m7N86VJMRv3yrm036330+ZUlS4jb7twv7q+/2rQU/iqIKn eTcC++cUglnN5TiFs1kilGpijQDiLOT3sVTzlO25p8bQc5pa+BE411pNAP/z1kFGtN4u wOTbzHFuxBNV5yw0kYrwaTBZRzI+jUAz/o+9c+g2YA9zGsiFrqfRSWbBTgwTvtxnXcLf Nu5qczZdwhpCOQRsnHjImBQJaPo0TWQZaEv1cZwzdtl6ulArSmtNCNv3jXaxZjSc9ORJ g4GkY8CBKJXn9gx5KZXRUUAJi2G4Zd6vyiDkALluGN99HavzgAXxm4nriqxCeclPaPrh w+Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:cc:to:subject:from :user-agent:mime-version:date:message-id; bh=pgHk+VYBW2WkIaodpfhe1xYTp3fI9gCE9zBReG4kpWQ=; b=xbSsyGezaeIdZTGEpDJrVKU4/RKZjsUpiLgFBKqxrVH4aKwBnBIvzyGMzY5/jtDzLe wgrKyrqf8yFoOpvat3J48kWqiwQHe/W682rh4KhszSuo8Crc52/Vaw8IQk/7yhif8NNi RQCuElQEgVHv45NEZgGuWyOdmihxuHe9q0jgH53LwpHy/V/MpHi0liPr34HxCrkRbJC3 6OlIiL6zwQWqlOwDvcVaEnPU5tag1CtcCZzv5QKQLDixq3Lwr3ZCDy3ykBp8kg/y/3f+ lP7y5X0V/vu/gnSl+vcCxGC51aAKo/ZuBUmu24b2wP8U9N0sw2B0UZRjIK3ckdwRc4gJ SGKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v3-20020a170902b7c300b001a9b29b6758si5818771plz.511.2023.05.11.00.12.31; Thu, 11 May 2023 00:12:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237262AbjEKHEc (ORCPT + 99 others); Thu, 11 May 2023 03:04:32 -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 X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 a2V0IGFmdGVyIHRoZSB0aW1lb3V0Ck1JTUUtVmVyc2lvbjogMS4wCkNvbnRlbnQtVHlwZTog dGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA4 Yml0CgpXaGVuIGNsaWVudCBhbmQgc2VydmVyIGVzdGFibGlzaCBhIGNvbm5lY3Rpb24gdGhy b3VnaCB2c29jaywKdGhlIGNsaWVudCBzZW5kIGEgcmVxdWVzdCB0byB0aGUgc2VydmVyIHRv IGluaXRpYXRlIHRoZSBjb25uZWN0aW9uLAp0aGVuIHN0YXJ0IGEgdGltZXIgdG8gd2FpdCBm b3IgdGhlIHNlcnZlcidzIHJlc3BvbnNlLiBXaGVuIHRoZSBzZXJ2ZXIncwpSRVNQT05TRSBt ZXNzYWdlIGFycml2ZXMsIHRoZSB0aW1lciBhbHNvIHRpbWVzIG91dCBhbmQgZXhpdHMuIFRo ZQpzZ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