Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp89036lqz; Fri, 29 Mar 2024 09:22:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXobmcxFAo9pWB8+NA2fGquMiK162/SXxTX2XOIVRoKTBRqi9xzvu76IMqt9yiBVw9kxfwOh+nj9Vqvea9Rhh8jLh9ETq3253mixPYtlQ== X-Google-Smtp-Source: AGHT+IFRdGMFP+p6lQ0NsHqr9KtGN+hHOkY3f+KeeFJOKzbwbRpVCR8amGDX4NEvjkkaf3N2/hrF X-Received: by 2002:a05:6358:5409:b0:17f:6b3f:1b0a with SMTP id u9-20020a056358540900b0017f6b3f1b0amr3328874rwe.15.1711729341065; Fri, 29 Mar 2024 09:22:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711729341; cv=pass; d=google.com; s=arc-20160816; b=hkXsAgmNzz82Wh7D3gruFh6iRR6VJNpJYhUvvt6JiqsilSLMz7qIsRVQtaKQ01koAI ItruTL1wWzPun2sDS4C1y57VJQuLnhfKtmqTRgG8d66614+Od7XIZJ+CO4auvxL+MEJa SvmlhW6eTIXWOt7GiUX8OL7DSCXMydEgdBPRLZk+EW2AAFlp1yOwprxFEtcxr52GFDh4 W9CMuYlR2Prq2aCbFSLON4UHVFtRk/q1DFa4EDp1PgA7eRKNYa0fiLwhOhiSBah0g7++ i1GnMSb3qD68bDU6Z6rBfmxkfa2oxnSphj6FYxRCaX6aYtshNT01NXgh6BMQK8n/TsQB hGjQ== 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=fmEyRcPuEinvJiX6Dq129jlFJ6SCvYGxlVcOYHlmNDQ=; fh=ifwJsfICC+B/CXbMHjf04BWX5lfjzSV8DpD89etq81w=; b=GWB/chGaZgOgi03x9lLWLEkEM6Qt3KqMkkfZvxqxJUPkAptRhNSPHrZKwdjY+6MQ5b Ove7AGJmefvnYdku7t02vHMo+xd/he0jquufD2oTTW17mzIo4eDlbcBvrNH5Ldib2A5f 1g+pS+IWc/1EaKHwIwcl9lnpxWQE8+nu2S6DUOfpzduJPci5sMiJ2SLVsBhUaanWFWZa 4iRFsRbxA9uXPD00Wo7ojl++2bP8DTYsTjgTG6B9xL0uxOwyzCN2Nwa90z+bA3uFbCRz 9yQhhcNb805AivRr844KROSRSn4NXcb3V5fCDSv0belE6sOaLVvQJkNxrSPr8Zkl5Ut3 GGxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z5mYIRFy; 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-125167-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125167-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 z7-20020a63c047000000b005dbd5035dcdsi3883877pgi.192.2024.03.29.09.22.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 09:22:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125167-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=Z5mYIRFy; 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-125167-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125167-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 91853288E13 for ; Fri, 29 Mar 2024 16:22:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58AF2126F33; Fri, 29 Mar 2024 16:22:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Z5mYIRFy" 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 CC519482E9 for ; Fri, 29 Mar 2024 16:22:08 +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=1711729330; cv=none; b=P3Ayl4OjoERaRKMe3sHl9O2ZD9wvjvwmRjZDeoDaSutIWrE6h9kiYBNnAtr9CEX+RYAFyTliKCWKv9AR54kFkKiOZ+zM8sE9ZH+dsF3YLMh4L9vo+rytphZfRbBj2RGpiyr0nn43vUb/5RQqLl7o0DArgN0yZKhxzxRMlXIsxhM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711729330; c=relaxed/simple; bh=riODE1dPTaLbQpz/0beewzGEpd2nIe52VyxmuEiuHaY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZBa5v4Ve/Sqmi1YDVhfJ726IZjXGw2JE1nFxrnSFXleu9VoUU1ZOlE+TY2kxJW29WoaDfxzEMae5gXbMuhvIw7zw6K/B0Se9Y7qgyOnHjJ+nPh65OfUhQtygYehr1XAfDx/wyHb3ub0m1b6m2RxEQiQRr9Rh5yAPygxRfrC+faU= 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=Z5mYIRFy; 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=1711729327; 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=fmEyRcPuEinvJiX6Dq129jlFJ6SCvYGxlVcOYHlmNDQ=; b=Z5mYIRFysSKKhXSsiWcg2tj7AzXJCNCgb3TiuUYiVFy3QmUBQSiB63Nh8M/YEQoUTiCekF 6LIOVq/R9D/ebdKobrHe1mIn7zQRHwsDeKRg4A/WtkqUp/tu1A6ywlFUoAg/o6Pfx0/f8q Xyvk+mgkR35fTovgn1YY7JrrCOHK/ko= 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-546-GqS8nmMhMKqz7-XZzmeSsA-1; Fri, 29 Mar 2024 12:22:06 -0400 X-MC-Unique: GqS8nmMhMKqz7-XZzmeSsA-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-33ed44854ddso1044055f8f.2 for ; Fri, 29 Mar 2024 09:22:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711729325; x=1712334125; 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=fmEyRcPuEinvJiX6Dq129jlFJ6SCvYGxlVcOYHlmNDQ=; b=irhJ04vVahezwBuCXxuvg3gshtCSZkQ3j7OmtATCSR6Ai8vaMswiFG96qZUHA9i1M1 F7SELYw5jlIohSyaFyJOnsdw9Vsz4hgPe0VD0g0xqQhF7wS+cWBdAFFlNTu7RAGX6WfI O8gsh6qjR/VSDkAJigo8YJSFYQwPsv8kPnernaLceKXe3ocpgPYiAi/FGYf4Q5xXRGDu CD7Nuu1JdpTNcG7334KCM3cvEnrkxikf3uCOmRff1kffd3baUyyl054oEicLEXWLQJom a6IyDAQL9YIrkVAFR9i67cDsPXwwUJpUEEAo9gRo7Ws46o69u+VqQ9yi3xAvsqntgYe0 ovfg== X-Forwarded-Encrypted: i=1; AJvYcCW2fmKQVjVnmJpGf8yIYNcqYrEd7FQOEuYk//t0CKVcYTgTnuOEFUlLY1Bx+dtmrIXqO/Hv24bzFGNfX+GqH6PmhGNqLoJtGYZvbTgw X-Gm-Message-State: AOJu0YyjpdYa0gxaRtDSfd3NuriCCXvH+XIpyTDhp3dxfeagoa0wDg3J EsB8Pftpzlx55uOm9dx3SrwZb47cdt5HyXr69cNvzr3kXbJpvaM91h7zQj1NKKcC1UDyWAQ4eMD lNl1149YPVhRLuKsq4dHgbI8gA7GhkH+vhS5nGqbsQQ/ZYXXZY5bOB2z/2/WxBQ== X-Received: by 2002:adf:f810:0:b0:33e:7750:781d with SMTP id s16-20020adff810000000b0033e7750781dmr1813657wrp.56.1711729325171; Fri, 29 Mar 2024 09:22:05 -0700 (PDT) X-Received: by 2002:adf:f810:0:b0:33e:7750:781d with SMTP id s16-20020adff810000000b0033e7750781dmr1813641wrp.56.1711729324802; Fri, 29 Mar 2024 09:22:04 -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 u4-20020adff884000000b00341d9e8cc62sm4478654wrp.100.2024.03.29.09.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 09:22:04 -0700 (PDT) Date: Fri, 29 Mar 2024 17:22:00 +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, stable@vge.kernel.org Subject: Re: [PATCH net v2] vsock/virtio: fix packet delivery to tap device Message-ID: References: <20240329161259.411751-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: <20240329161259.411751-1-marco.pinn95@gmail.com> On Fri, Mar 29, 2024 at 05:12:59PM +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). >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") >Cc: stable@vge.kernel.org >Signed-off-by: Marco Pinna >--- > net/vmw_vsock/virtio_transport.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Reviewed-by: Stefano Garzarella > >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); >+ > if (reply) { > struct virtqueue *rx_vq = vsock->vqs[VSOCK_VQ_RX]; > int val; >-- >2.44.0 >