All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] vsock/virtio: fix packet delivery to tap device
@ 2024-03-29 16:12 Marco Pinna
  2024-03-29 16:22 ` Stefano Garzarella
  2024-04-03  1:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Marco Pinna @ 2024-03-29 16:12 UTC (permalink / raw
  To: stefanha, sgarzare
  Cc: davem, edumazet, kuba, pabeni, ggarcia, jhansen, kvm,
	virtualization, netdev, linux-kernel, Marco Pinna, stable

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 <marco.pinn95@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] vsock/virtio: fix packet delivery to tap device
  2024-03-29 16:12 [PATCH net v2] vsock/virtio: fix packet delivery to tap device Marco Pinna
@ 2024-03-29 16:22 ` Stefano Garzarella
  2024-04-03  1:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Garzarella @ 2024-03-29 16:22 UTC (permalink / raw
  To: Marco Pinna
  Cc: stefanha, davem, edumazet, kuba, pabeni, ggarcia, jhansen, kvm,
	virtualization, netdev, linux-kernel, stable

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 <marco.pinn95@gmail.com>
>---
> net/vmw_vsock/virtio_transport.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>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
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] vsock/virtio: fix packet delivery to tap device
  2024-03-29 16:12 [PATCH net v2] vsock/virtio: fix packet delivery to tap device Marco Pinna
  2024-03-29 16:22 ` Stefano Garzarella
@ 2024-04-03  1:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-04-03  1:10 UTC (permalink / raw
  To: Marco Pinna
  Cc: stefanha, sgarzare, davem, edumazet, kuba, pabeni, ggarcia,
	jhansen, kvm, virtualization, netdev, linux-kernel, stable

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 29 Mar 2024 17:12:59 +0100 you 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.
> 
> [...]

Here is the summary with links:
  - [net,v2] vsock/virtio: fix packet delivery to tap device
    https://git.kernel.org/netdev/net/c/b32a09ea7c38

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-03  1:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-29 16:12 [PATCH net v2] vsock/virtio: fix packet delivery to tap device Marco Pinna
2024-03-29 16:22 ` Stefano Garzarella
2024-04-03  1:10 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.