From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FBD843CED6 for ; Fri, 15 May 2026 09:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778837622; cv=none; b=PC4uiapaLFTD+oQJ2T56UVqQvmmKuGHCqiC2yezXnYdzBB3r3pBqqivcYNBkLYXGyPmdxDscwdbAhv8UMuZf8iXhEcaLjBXoou0jg5CXu4gqhiz0vloM1zACSLvEjB6n7Lg5K2C4VK0ErroGMmq+6ZHfxLaSeUrbjqEoTwGHyjQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778837622; c=relaxed/simple; bh=HzcXf6Wv0llfWEbLwfcl50s7dD+w0VdR0+2YgR8e0cw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rwj1s5yMtHrkuZ+Eqi7NrF89w15w954o2QF+L1+3GW3f8RFvLKkH4fcp6faxOzlGLrC5BM2Z6gA+sYf9rLcHXagJi0kDNeLLzuGpVbIuxpryV+wmxgddd/ga9M0p3s8JJ+4rSN5DVINxyzMWywkqPBcbPdWDTy3CwmSZBMiIMM4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JprKPrdI; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=ICnBetIE; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JprKPrdI"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="ICnBetIE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778837619; 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: in-reply-to:in-reply-to:references:references; bh=hZ42ILoPPEodEg6ZEuswA8B5A9RnneHFtROSVsVKJFY=; b=JprKPrdI/EqzNS0ZT+/pc7IqUlYuReltXPj23IGXzOWf9xCI+CHJ8zFVVkUZp4U0pKzBj8 N9Siu/FyW1FZCbwiBnKVLpobx4FhSryhjboKZLiRRbn2M4IBbAdN872XEnx7kXibHmef1C diXU0jgFwiSM78n+OUd/4K0RcbadL+0= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-96FRc6L1MeWV5ytgb9JcSg-1; Fri, 15 May 2026 05:33:38 -0400 X-MC-Unique: 96FRc6L1MeWV5ytgb9JcSg-1 X-Mimecast-MFC-AGG-ID: 96FRc6L1MeWV5ytgb9JcSg_1778837617 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-45e2f74da10so1631994f8f.2 for ; Fri, 15 May 2026 02:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778837617; x=1779442417; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hZ42ILoPPEodEg6ZEuswA8B5A9RnneHFtROSVsVKJFY=; b=ICnBetIEcsdH3ztEsUar6b0l4Qf/HCIccRrik2R+qjZtiKe7sQUo/l1/HzqtprsPFp AEZ7CoZD7mxKrk4mHHN4xux5MOecNMn8wkZkB+IkCozFohG1QytK6zfq6/SNNr0UlZYQ Pa1vG2GBmhX/yIuWVdOlWljJjAMD3W1xJGoScq6yaBCPthOjDC/3ZI5nIjMM79d7PeuS XugF5T912i/caFWq3PfHNzoJNs6bLhAR8syRHJ1iKYESMDaKHBreg+OdcFtO8UwxMxmM aMrzCZt7X7xcEooWSqyKeLyGJEkozi8fsR+F5AbtLPQM0x91V6W2eyIcYihoktRUnYog PBfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778837617; x=1779442417; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hZ42ILoPPEodEg6ZEuswA8B5A9RnneHFtROSVsVKJFY=; b=sEYLnPiPSg9N38X+hbfXSk4hrS1/kH9lzWmZQc1HskvduuBMhple4X9Qg8+RmEvhXg MEl489fhY+rdjVIYQJzBIZW1+eexHlSfA7bko00iDT1B5+htkq9DifegqqMU4CXtcNXM 93OBnVCYR6ELSSfVJBcRHlNhEUzdyE+hqj7UL4C2pgK60z7FnJgVFNA1nuldlDvMElgm 75kvI4xTpgo3uD3rbWL8dgEZ7uO3ChtT4WHH7S0JXh7zXPrIPYQAahRRlOQlpalRIO9t 1BFJXUyND6nThgIbI0mBAf/nWON94CkErTL2mysHD6ijZ2W8qZ+NetivLog24daDkue9 CQjQ== X-Gm-Message-State: AOJu0YyoOkFEwmfE4nLSMXRXD8cDiIgIde9Quee+b12SL8sv4/9rNWjG rBVm8NtDdylwHGh6fvKhSV9qQ8BDUsnsR6CGWW0IBFIewdvHZ8mX0nHAtjuBNSeJCalQkRLuxRT bh2fV3PkxkBeXSAOHAeGG9R6k0smab/Tjyn4AMTfoHB4YZWpwVtYKXPGjkk8dA7thYw== X-Gm-Gg: Acq92OH3d7zXCS7sehWS3RSFAP/YMcFPCkJ0nmSKite9SMGcc4Rv2U9xOB1iHxtmsnN 9tm2Q3ii5TCcTyn5K58yr2Hi1t0mf+09Gp9d/T/qVIFxeMcUbl2Q765J75HrUsvO5PjtqsR0hEV nYCKv0n7IqW/UiMTCJhx0r5UQRZxLz0d785Uy2oiTsuMIXFvP7ecCk5+aRhMHE8FC5pv43B/Qve Q4bLhWwFRKMA7BC1V840v+MFUUOid01O8C3uMWKMBvMvV4ox5RwIJlzHIIk5eAukrBQHfaitgq7 gzSiDhEGVwo/xQvG/n1BYNYyYGHrsqJxAyaGJFRflHfd4GlH4iNWMC/ZpIrDdpeW9xBIlOum0X2 HeeL6bp9bhcsBuAIU+cDiU+doyweDreB85VA6BDPGLwyPv11bfVqiuhdboKqMj4wfNQo++LlSeQ == X-Received: by 2002:a05:6000:2288:b0:45d:4532:5d98 with SMTP id ffacd0b85a97d-45e5c57d2f2mr3913461f8f.8.1778837616872; Fri, 15 May 2026 02:33:36 -0700 (PDT) X-Received: by 2002:a05:6000:2288:b0:45d:4532:5d98 with SMTP id ffacd0b85a97d-45e5c57d2f2mr3913404f8f.8.1778837616358; Fri, 15 May 2026 02:33:36 -0700 (PDT) Received: from sgarzare-redhat (host-87-16-204-231.retail.telecomitalia.it. [87.16.204.231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45d9e768bcesm14392867f8f.4.2026.05.15.02.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2026 02:33:35 -0700 (PDT) Date: Fri, 15 May 2026 11:33:31 +0200 From: Stefano Garzarella To: Polina Vishneva , mst@redhat.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org, Eugenio =?utf-8?B?UMOpcmV6?= , Jason Wang , "Michael S. Tsirkin" , Stefan Hajnoczi , "Denis V . Lunev" Subject: Re: [PATCH v2] vhost/vsock: Refuse the connection immediately when guest isn't ready Message-ID: References: <20260513145842.809404-1-polina.vishneva@virtuozzo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20260513145842.809404-1-polina.vishneva@virtuozzo.com> On Wed, May 13, 2026 at 04:50:04PM +0200, Polina Vishneva wrote: >From: "Denis V. Lunev" > >When the host initiates an AF_VSOCK connect() to a guest that has not >yet loaded the virtio-vsock transport (i.e. still booting), the caller >blocks for VSOCK_DEFAULT_CONNECT_TIMEOUT. > >A caller that wants to know if the guest is up yet instead of waiting >could theoretically tune SO_VM_SOCKETS_CONNECT_TIMEOUT, but it's tricky >to find the right timeout, if not impossible: there's no way to >distinguish "guest won't reply because it's not up yet" vs "guest is up >and tried to reply, but was too slow". > >Furthermore, this delay is pointless: >- If the guest doesn't initialize within this timeout, connect() > returns ETIMEDOUT. >- If the guest **does** initialize, it'll reply with RST immediately, > because there won't be a listener on the port yet; connect() returns > ECONNRESET. > >That's also inconsistent with the behavior at other initialization >stages: if a connection is attempted when the guest driver is already >loaded, but nothing is listening yet, we return ECONNRESET immediately >without waiting. > >Fix this by checking the RX virtqueue backend in >vhost_transport_send_pkt() before queuing. If it's NULL, return >-EHOSTUNREACH immediately. > >Callers that used to get ETIMEDOUT will now usually get EHOSTUNREACH. > >Signed-off-by: Denis V. Lunev >Co-developed-by: Polina Vishneva >Signed-off-by: Polina Vishneva >--- >v2: >- ECONNREFUSED -> EHOSTUNREACH. >- Use vhost_transport_do_send_pkt() instead of raw .private_data access. >- Removed READ_ONCE(). >- Wrapped the condition with unlikely(). >- Updated the comment and the commit message. > >v1: https://lore.kernel.org/netdev/20260511145610.413210-1-polina.vishneva@virtuozzo.com > > drivers/vhost/vsock.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) Reviewed-by: Stefano Garzarella @Michael I think this can go with your tree, right? (I don't see it in https://patchwork.kernel.org/project/netdevbpf/list/) Thanks, Stefano