Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2852891lqp; Mon, 25 Mar 2024 11:03:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVzcq6mP9INeZpuP2c8oWFMUv94t1bw7MjhvaEn+Wyx+Crk2INetg2rXRETRNDcOMHrKiIVZJDSDRY3CSXyfzqBtV7LT/EwayvEFovArg== X-Google-Smtp-Source: AGHT+IFUqEMlDWonbWnC8tLS3ero6I0O64sYpfieJ5Q6Djvg43wSYnTypZXTJntXCse59rf0hyLX X-Received: by 2002:a2e:1f01:0:b0:2d6:c72a:21d9 with SMTP id f1-20020a2e1f01000000b002d6c72a21d9mr4402511ljf.21.1711389780689; Mon, 25 Mar 2024 11:03:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711389780; cv=pass; d=google.com; s=arc-20160816; b=SeqfjbkjY6TvZzbtuo9T6N6xj40IbHqjeE8gLBfXNA8PcmXpx2n+AIIzC/qsOf3MVg al5S97aVXEL8ECGLUxTwUH2V2uEa5DH7A6mKhzpIXo7DR/A3Sdg4y2j9XtVK0Kq0cqph h1EPfI1Ei3SokXo6+ah4+i0NAW2/sr2Io6q+8b6OFWer8oVKavUg1VJVEbiR35u2Fclc sHY+bCt5gD9pr9BLT+PiJ0cmjBkHUD8j9Bgknq8pq+UQ5UOnYJyh/B4rVIzKnfLmDJmL zL3DRObTgqV9CCZ+zsa4uRNWCmfxVoQ6/tkuApxP44XyOHV8n344EzAa87E1/f8w5xVe qPHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=6X1NNxLlcRJ0g+9m4U+W77i//Qg7iE4ilrLW92aE7CM=; fh=P5R3SsENxjMSqWPVxtq4tQeEIzMufwrkuL675VG1NeI=; b=ZvZln0h1mRhA0+wYX5DLb01CmcUqeu1deTeYdi4/xhGUivEV1Jtcf3DhZ8UUSdOPFG kD1fwAWWGPzl2UoxX2zrxqpMGttq5EbmiKLcF8Xer7sUKAdOsa8dARgN4XLbgMjM0mrM zYcEin7mNCD2tXy85YO4zJRxXacV4o55moHhkx2yw/XUBU+4GQh/fQxWPfMWuiRPGtum qfZ8814m644oqNFwsDTNWM5Utq2s3GNgHNDhj36Og75Mw45RPIJMsEuQZNghNRgSG029 VMWsvUzAKnyu7nsFwjd7AzSSsRi8b7cEB3Ur3ShPvKdwSDmHJsAaIdwSMK8NguA8b5/i dtkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LF005WrV; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-117554-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117554-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id eh13-20020a0564020f8d00b0056bd92055e1si2872442edb.616.2024.03.25.11.03.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 11:03:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117554-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LF005WrV; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-117554-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117554-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id EF98F1FA3826 for ; Mon, 25 Mar 2024 17:54:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95EAF13D284; Mon, 25 Mar 2024 17:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LF005WrV" Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00C9813D265; Mon, 25 Mar 2024 17:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711386786; cv=none; b=sFn/VMBYuiAX0JiWkLagkTUvqs5WS4RhSBLlapvqErBVm6NxvxToMDxIHKgruhvYjImTeJwjE5fSc8zcMQ1rT6Sewilz54s6CVekvjZbpMXDj2xBufA7o7mceClXDXbCvLiPJN9U2KEQ5OZq+G1esaUIRuuZ1W6VVuEiyrs0qZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711386786; c=relaxed/simple; bh=0ZhgzFV5Xt/mswqGy6lswxgldIuR6Mr25B7wtDUTbrY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Pn/L3i4hsXEYj621Ey1ghptJToxff/voKayeDMXFrcG4ZolVq070f5Fs4Ln5fMqvQ1rfTwBa7nVu6mfAijB3I1igdjjPoX4jPvJ4nnjYW6XjMEiuBCIVA7a2SNVyQe01pAq0A/REGQYLZj+h57Cv7TdmQoDjtpoxXSPhhEuuIoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LF005WrV; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-513e10a4083so5134022e87.1; Mon, 25 Mar 2024 10:13:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711386783; x=1711991583; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6X1NNxLlcRJ0g+9m4U+W77i//Qg7iE4ilrLW92aE7CM=; b=LF005WrVVtFb1+wnCyhHJR/O4Tu17HjgWqWTjNAX22BHiDn8LRrJh7U9AGR0v2UPT+ RNZkfcSoa9fExJAurLDaQTF9eQGdynuaYoFLIwm7BRU1CZ+CEK+s9sFN3daTLWOozAJz WRUer+dAGX2mw601frqOixEB0qxFe72KeXZIbIRdR+92B81MpbtT3265wN46LGszp97L ge46B76q7VvWNywk3lvZJcJdr4bqgy3r5Q47QJw0Lm6sa2fjhsrCXGmfLJKumJL5RgL/ S9WtPt8sb6f8wnVwN/hCJY2fwfIVQYJ+zQ/UWIyALzFsAR09xiIf+ZWl2q+koT1LYf5G IVuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711386783; x=1711991583; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6X1NNxLlcRJ0g+9m4U+W77i//Qg7iE4ilrLW92aE7CM=; b=J7aC3JGBb/KMne3gSz9uQASHi+lxTGDKMHCc/t9EI3+sWKwnyU/q2Z2frUKpWUXCk7 IfF/+wsvE7dssh+en17MepfPqovMNcmPatoGhA0zlm6TuPZ1CpAsGrq21CFOleT9UZ8i XWmFU9c0kzoqW9Mi0XOO8JXjC5HPBvdg1QR9FK7Lj9XGOhSQVuujIPk24cno5QttK4Y2 Yr+v5Kib6RQScjrJ7Cn3CLKOJAJmWDoMXfe98Iq9sbgsG3kOzRir/tNGLcz0lAnp1XbI sxoeIeXYrZV8Ej5FNcrJv5jhcQ/cnz8+5sAf3Ukml1neHccCC4HHZrN2OXHCBFZIL9ln Bu8Q== X-Forwarded-Encrypted: i=1; AJvYcCVMCAtkZ0Sc4bH3p2CbebsVk8nJ0X+4wMgkQQI/z+gmbVnjag6gQQoAbI8D0AKUqMCMOlSjfU2+CpOta3w8V0bhXas5fxf+FCPRudJTtmn2weawXZMrPET6VBoZ4EYj5c1bdZjXT4Gcx78KXaGQ6cpa+oVtgTsWFyOa X-Gm-Message-State: AOJu0YxsfnWC9Yutq+0pim0Fdakca+3hPAsJmmadyN3ro5nfsYUZmgWV aT2J99TYVyqwyHWLZne5FJ9vXWAEbeEFbU7myzj5r+6gkwqKEiyd X-Received: by 2002:a19:6406:0:b0:515:a523:d38c with SMTP id y6-20020a196406000000b00515a523d38cmr4000791lfb.63.1711386782887; Mon, 25 Mar 2024 10:13:02 -0700 (PDT) Received: from localhost.localdomain ([82.84.234.137]) by smtp.gmail.com with ESMTPSA id h4-20020aa7c944000000b0056bdf694890sm3225666edt.43.2024.03.25.10.13.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:13:02 -0700 (PDT) From: Marco Pinna To: stefanha@redhat.com, sgarzare@redhat.com Cc: 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, Marco Pinna Subject: [PATCH] vsock/virtio: fix packet delivery to tap device Date: Mon, 25 Mar 2024 18:12:38 +0100 Message-ID: <20240325171238.82511-1-marco.pinn95@gmail.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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). 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. 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); + if (reply) { struct virtqueue *rx_vq = vsock->vqs[VSOCK_VQ_RX]; int val; -- 2.44.0