Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8771805rwr; Thu, 11 May 2023 06:08:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7H+X9fDx2ftI/dpKVV1c+zcAQ1NRr9J+9OwmryRefwKJjAVqQ+Oy2HD9xoRO3yp6/ZIZQJ X-Received: by 2002:a17:90a:3841:b0:24e:14a4:9b93 with SMTP id l1-20020a17090a384100b0024e14a49b93mr21576344pjf.43.1683810506000; Thu, 11 May 2023 06:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683810505; cv=none; d=google.com; s=arc-20160816; b=saryFXQ/p+OCrBe8GcdEQL1v5BJNynFjoaXHHVBFgSoGf4WfDfiqgJzrhPR72rwHip MruD10dh1/6cm9REik74NAviyEmvhPYG1uk2OlHCKLMF5w/P308yOZ3MZ5WCmEfu6ReE cEujRTowbiUaajei2xvSg0fzLtTvYycJflUuC06dw/dkmmRCs74Ad6ofSDlE+3CmPJT7 c04YGuRDN2s/MdXiLbAsVxqBzR06HntCWQV7O2oYiYNlB5D17ETMJq994zsI7Y1OhCNc e7noU0rlg0j17d5kAvFieYclUWIfWbYv++66wZJqbyaBuQZJS4nh6JjxzaX7sdS5c8yX LSNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1YNgJu9g4hsRAs0h9Bi/9rkG5y7jrDdpJUfTR0KD1Tg=; b=VO94DLVTAFScoeCzWaXZFNtbajh+4FrdLm0dnqSvx/XHh2ogvm+nZBfNDaC3YVmTYu RqissneL+Tb0qW8O5rA1eLPpZsav7f8FbRupxs9kff+Pwg5/LSQU5BIYFaVpMRZBrmJ2 FnCLLDrE9pXzs6OKE5GgVR2ROuvTOlWjWEABV/nUjPtN/cF3ohC+4sQ3oGKICZk5ltdy sm7JD9L6o94P6xNo2oOybeiIIGnHrJXYDtJMJoY6muD0UWCE6t5gE4shXZvYE8szBQew laQ//H0ILltuo2TcM8VN6OQp/UBfnTUknpPuU6S1hySGyDBQZ2vMWV5/d7f0BHcFk/kz yxBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MFuv4tzH; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iq22-20020a17090afb5600b0024e0153398bsi25759852pjb.1.2023.05.11.06.08.11; Thu, 11 May 2023 06:08:25 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MFuv4tzH; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236152AbjEKNBz (ORCPT + 99 others); Thu, 11 May 2023 09:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237628AbjEKNBx (ORCPT ); Thu, 11 May 2023 09:01:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA4696193 for ; Thu, 11 May 2023 06:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683810029; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1YNgJu9g4hsRAs0h9Bi/9rkG5y7jrDdpJUfTR0KD1Tg=; b=MFuv4tzHyMoUJDKq2BoIp2XmufbDzJCZRNRnO1CACAd/m9Vw0Qtzy4+DPm6KKnrHLc0RFb zuqikoyuLRwd4xgXbQiqc3UIkI3IqDzr23QPjbKxas/WJr4Mf5wtKDWqcmwT5zatebag2U Pl/cTwMGeU9BAi+aRKHo2zhC3Og417o= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-216-u4i_vyS9P3yW4jl_E9czuw-1; Thu, 11 May 2023 09:00:27 -0400 X-MC-Unique: u4i_vyS9P3yW4jl_E9czuw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-306286b3573so5247982f8f.2 for ; Thu, 11 May 2023 06:00:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683810027; x=1686402027; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1YNgJu9g4hsRAs0h9Bi/9rkG5y7jrDdpJUfTR0KD1Tg=; b=TXBiIycegUq6KK063peDdVYzKnus9+558NtUzM3h7B02EAmcsuH9thRHxQrhxq3+io qjwovuBdJfnnGaTznmBeY+kHS1phQuGVp99zRoYtIBV0f/6V+HC/nCHc35uymaLZ77vR Wek4eOST8jzaiCfWur6qzYKyuSWuy1ENObnRNDG5HVPcwDA30DnzaQeci/Iacp5G1dhE jNQOGezk8hPwaG1lDwq/5xumZOu0ssP3jilNo5wGp6Lm1ChG8Lj5KcVr8DZFBketE4uo Uw8wmFTVHFMUVltQ2vQMbvZ80WLamolEPmanWJ7Q41gXd5XOyisbQ3vyiphcyDuzRgW0 PMgg== X-Gm-Message-State: AC+VfDxXRLYlU/kwkpQcdFJl2MVLEn0iOO9ulVPf/q+jthv8ufqNR67K IOpmnCVpuo9MkPgpWWH9pNckXdBEAUITb5XgOf1yPORglRmBnObcnc8mlt9dqu6zsz8jzGssgFj 0eHJKC+/gxeL1HeyHH/JegwTW X-Received: by 2002:a5d:55cf:0:b0:304:b967:956f with SMTP id i15-20020a5d55cf000000b00304b967956fmr16336614wrw.8.1683810026738; Thu, 11 May 2023 06:00:26 -0700 (PDT) X-Received: by 2002:a5d:55cf:0:b0:304:b967:956f with SMTP id i15-20020a5d55cf000000b00304b967956fmr16336585wrw.8.1683810026412; Thu, 11 May 2023 06:00:26 -0700 (PDT) Received: from sgarzare-redhat ([5.77.69.175]) by smtp.gmail.com with ESMTPSA id w14-20020a5d680e000000b003079693eff2sm12447627wru.41.2023.05.11.06.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 06:00:25 -0700 (PDT) Date: Thu, 11 May 2023 15:00:20 +0200 From: Stefano Garzarella To: Zhuang Shengen Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, arei.gonglei@huawei.com, longpeng2@huawei.com, jianjay.zhou@huawei.com Subject: Re: [PATCH net v2] vsock: avoid to close connected socket after the timeout Message-ID: References: <20230511113430.646292-1-zhuangshengen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230511113430.646292-1-zhuangshengen@huawei.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 On Thu, May 11, 2023 at 07:34:30PM +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. It will not notify the server when the port >is released, causing the server port remain. >when client's vsock_connect timeout,it should check sk state is >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. > >Fixes: d021c344051a ("VSOCK: Introduce VM Sockets") >Signed-off-by: Zhuang Shengen >--- > net/vmw_vsock/af_vsock.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) The patch LGTM: Reviewed-by: Stefano Garzarella I noticed that the net maintainers are not in cc, if this patch isn't queued in the next days, please resend it by cc'ing all the maintainers [1]: $ ./scripts/get_maintainer.pl \ 20230510_zhuangshengen_vsock_bugfix_port_residue_in_server.mbx Stefano Garzarella (maintainer:VM SOCKETS (AF_VSOCK)) "David S. Miller" (maintainer:NETWORKING [GENERAL]) Eric Dumazet (maintainer:NETWORKING [GENERAL]) Jakub Kicinski (maintainer:NETWORKING [GENERAL]) Paolo Abeni (maintainer:NETWORKING [GENERAL]) virtualization@lists.linux-foundation.org (open list:VM SOCKETS (AF_VSOCK)) netdev@vger.kernel.org (open list:VM SOCKETS (AF_VSOCK)) linux-kernel@vger.kernel.org (open list) Thanks, Stefano [1] https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#select-the-recipients-for-your-patch > >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 >