Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2879782lqp; Mon, 25 Mar 2024 11:48:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWk7vvrVccaRISWOXo3gPYvedwCPwUYeZ9JJs8/8QwmqTsioJjz5Qlk7PCZTXe4UETI22gTzB8G8hyoeLaEXwzte9ei3NUZNxlR3PLkmQ== X-Google-Smtp-Source: AGHT+IEz7tpEQjmzPtisAQAcSDzpOfGid32+7pfmPR2Q7Chpghfv7G8QfObu5NfiL0wFFO1GshAw X-Received: by 2002:a05:6a21:998f:b0:1a3:466d:d33 with SMTP id ve15-20020a056a21998f00b001a3466d0d33mr10917278pzb.9.1711392538174; Mon, 25 Mar 2024 11:48:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711392538; cv=pass; d=google.com; s=arc-20160816; b=s2m5VNsQea2N9JIXU7Pbvz3BKcYRhpVHv/+jfH+dF/UFyfaGfpuDpM3e4xTAQLXqZ6 KAdoxeFGwFkQAzUzobAl4WGRd1GV/eztc5npBUTrTzfpXx6+J+EiAY3eg/h61Cob8eR1 /dCgMqDQ1fNHGmlpbhiJ83S+8ym4Oj8pOLV4I3HqdMtbBciZzZiOnRq/gCCqyEXz/Qox E6DdenT0ZPocpzIwBwWqMNq2YGZGjcdD3PB0ucqP7UiXJRTHm24UfAJf3S3JqOZHxV1C pzsERSPtWEDseFcmhnIBMBmVbb5blXtNI6lmZdZ8h7loYiPwkwPf/ksr0n4GWVAxqaAA ISlQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=b8m7155r4ZtiZ6OJmssDUl1N2SECV45y4cCUPbb/2rA=; fh=fCCT4vfVf3RVZY7JrE91oqk4mHEKdcZh+ZfoAmt0O5M=; b=p2CSusMo6FPJp8JjYjQlAHj4ia+9yyS8aVYYpxwAmJJRbp18TbPyeIzAFJc1xM98Oq GctQ29MmuuqerM0DUrI//j9r7xnZKoQL1ymtyuYBtQEJYlj6SjIGSODb5Tt6HhL9NHNY 8zUw+mSzBcojsl67E3v8m1b9uZaSzIfmcuDOFUFhPz7OOYZtfHf7t6rPeeCmaUzYbQCX 3l0XDgyX/jSlZS9kTmWPN6FpvdvM9VHEjzpFw36TrmMrW5QlMcFyby4xRj0wEd/XPuHM Z6NkiVRY741id9GZLgbZ0zIdUZ+cKhkSN3fP5hB8U9DHiJyLyL/uLQnY5Uv50qrwyTAe vLSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MSajJ7uA; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-117700-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117700-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ca17-20020a056a02069100b005f059e58ea8si3058278pgb.466.2024.03.25.11.48.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 11:48:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117700-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MSajJ7uA; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-117700-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117700-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DB87229C251 for ; Mon, 25 Mar 2024 18:40:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8315283A0A; Mon, 25 Mar 2024 18:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MSajJ7uA" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 0ECB682D8D for ; Mon, 25 Mar 2024 18:24:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711391079; cv=none; b=bLNamXIr1WAt1gdOyYYylYAeDzcciRR178inBRrV65b6hUsknhfHYN0WuaCHjvV5jVxJYTD0AbW/4MZI89x95exEWH0vFjQU6cQ0h+wsLYyk5gwkWj9S2LfK7lbIBvetFZqX+2boRIwcBSzSEdreGv4U9w7fd0J3+ZQOZDVK67M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711391079; c=relaxed/simple; bh=1y7PY1oTFX7Axkh8dq81egggxtYVixKQqkHsEHIH+zs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JjZQpHq0Lxgkk19l3YbNLU2TenrotJ0vgs9zxd9oAoXgzPG8X/zqTiSzNJOVasLpHwoq2QEt2jgxRTlIBI3EhGbqNfaN30lkso3GfL3l4bvrpOlx7VFWhvfN7dDObMSmYBn/8j9hkslH9aoik7NpCrr0slkTmM6KrXPqpZbv4bY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=MSajJ7uA; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711391076; 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=b8m7155r4ZtiZ6OJmssDUl1N2SECV45y4cCUPbb/2rA=; b=MSajJ7uAIUdJRUVR3KlJffhH+KdJwwF3wdb+Qdpwqsef0WJIl//XPxvzDIM2+g3/1gH4kP 6lCf2zL+3qGfmjwfYnpBGH4uimhojtFR8zzUpkeUXDK3NUOI1p2oM1cFA/sL6kGNa/RG74 TJC3xRzgtVOU21fBRMzcISxxcX8ZNG4= 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-190-nOhCCe1FPLGdWnWQiqfT_w-1; Mon, 25 Mar 2024 14:24:35 -0400 X-MC-Unique: nOhCCe1FPLGdWnWQiqfT_w-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-33eca7270ccso1982896f8f.1 for ; Mon, 25 Mar 2024 11:24:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711391074; x=1711995874; h=in-reply-to: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=b8m7155r4ZtiZ6OJmssDUl1N2SECV45y4cCUPbb/2rA=; b=WXEgZ5RtD3CB2Lonr895B2vMw/zdyZnbUCJ/42/mzyXwqztgdPf3w+JlxuIOnLI021 7DwMSmyHVFcS8I9EXICRItyCSJt53yZpvdAOL46cjn4KpNijMl1dFtgcUfNqX6Gprg0o vRb1XV9KYgmxYoUxfQJQ2ETv45WCBrA5/Z117cl4g9prqDH6lZFIHE77eh6XOz9FzR9w cwi/60ndWQXGC1W7j+z6WuX4I5lMInhE+ca+llyVxW9pyjLc4tgKcU62qiz6MvzpjGNZ FkTMfZlkVUuj3CApPvt0Wzw52ejEZoIsw4VKa/hwcTHO2lZWMaxthjCIiw6CuU2ObZ8Y BbHQ== X-Forwarded-Encrypted: i=1; AJvYcCXxeXKy6fQL3SY+U9+od+0aL2xvMEjA/oEtH5K+xm6xQMViCK2fmHAej380S+45OHiUEAbp8Fn+x5U/XAIExqGCZL1Cm9nQGd3/GRQh X-Gm-Message-State: AOJu0Yx6+ltpxNTN6ygG4rnsKCwNCQGL/6d7J3wfseAZDFAWILMNa0No EL+K6VxK+gjixAxTdPXLn4xgrQ8sC42TWZ3pFBTZAvKFvFyp/RocubX5uG8Nol0lSghb9SISSCy j6R7lqZxvUlPsnZJj2bqUSGKi0ANbCKVyusz+KVCl9PzjQyKbAxvezj8Il3+x+A== X-Received: by 2002:adf:c04b:0:b0:33e:bed4:c418 with SMTP id c11-20020adfc04b000000b0033ebed4c418mr5928999wrf.3.1711391074127; Mon, 25 Mar 2024 11:24:34 -0700 (PDT) X-Received: by 2002:adf:c04b:0:b0:33e:bed4:c418 with SMTP id c11-20020adfc04b000000b0033ebed4c418mr5928981wrf.3.1711391073750; Mon, 25 Mar 2024 11:24:33 -0700 (PDT) Received: from sgarzare-redhat (host-87-12-25-33.business.telecomitalia.it. [87.12.25.33]) by smtp.gmail.com with ESMTPSA id z17-20020a056000111100b0033ecbfc6941sm10112932wrw.110.2024.03.25.11.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 11:24:33 -0700 (PDT) Date: Mon, 25 Mar 2024 19:24:28 +0100 From: Stefano Garzarella To: Marco Pinna Cc: stefanha@redhat.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ggarcia@deic.uab.cat, jhansen@vmware.com, kvm@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vsock/virtio: fix packet delivery to tap device Message-ID: <6vlaxnqqyhppbajmmwyco62b7gzasflgrxpgl4h3ippuk4jwme@qfne3i72eej4> References: <20240325171238.82511-1-marco.pinn95@gmail.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: <20240325171238.82511-1-marco.pinn95@gmail.com> On Mon, Mar 25, 2024 at 06:12:38PM +0100, Marco Pinna wrote: >Commit 82dfb540aeb2 ("VSOCK: Add virtio vsock vsockmon hooks") added >virtio_transport_deliver_tap_pkt() for handing packets to the >vsockmon device. However, in virtio_transport_send_pkt_work(), >the function is called before actually sending the packet (i.e. >before placing it in the virtqueue with virtqueue_add_sgs() and checking >whether it returned successfully). From here.. > This may cause timing issues since >the sending of the packet may fail, causing it to be re-queued >(possibly multiple times), while the tap device would show the >packet being sent correctly. to here... This a bit unclear, I would rephrase with something like this: Queuing the packet in the virtqueue can fail even multiple times. However, in virtio_transport_deliver_tap_pkt() we deliver the packet to the monitoring tap interface only the first time we call it. This certainly avoids seeing the same packet replicated multiple times in the monitoring interface, but it can show the packet sent with the wrong timestamp or even before we succeed to queue it in the virtqueue. > >Move virtio_transport_deliver_tap_pkt() after calling virtqueue_add_sgs() >and making sure it returned successfully. > >Fixes: 82dfb540aeb2 ("VSOCK: Add virtio vsock vsockmon hooks") >Signed-off-by: Marco Pinna >--- > net/vmw_vsock/virtio_transport.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > >diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c >index 1748268e0694..ee5d306a96d0 100644 >--- a/net/vmw_vsock/virtio_transport.c >+++ b/net/vmw_vsock/virtio_transport.c >@@ -120,7 +120,6 @@ virtio_transport_send_pkt_work(struct work_struct *work) > if (!skb) > break; > >- virtio_transport_deliver_tap_pkt(skb); > reply = virtio_vsock_skb_reply(skb); > sgs = vsock->out_sgs; > sg_init_one(sgs[out_sg], virtio_vsock_hdr(skb), >@@ -170,6 +169,8 @@ virtio_transport_send_pkt_work(struct work_struct *work) > break; > } > >+ virtio_transport_deliver_tap_pkt(skb); >+ I was just worried that consume_skb(), called in virtio_transport_tx_work() when the host sends an interrupt to the guest after it has consumed the packet, might be called before this point, but both run with `vsock->tx_lock` held, so we are protected from this case. So, the patch LGTM, I would just clarify the commit message. Thanks, Stefano > if (reply) { > struct virtqueue *rx_vq = vsock->vqs[VSOCK_VQ_RX]; > int val; >-- >2.44.0 >