Skip to content

Commit b32a09e

Browse files
MPinnakuba-moo
authored andcommitted
vsock/virtio: fix packet delivery to tap device
Commit 82dfb54 ("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: 82dfb54 ("VSOCK: Add virtio vsock vsockmon hooks") Cc: [email protected] Signed-off-by: Marco Pinna <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fd819ad commit b32a09e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/vmw_vsock/virtio_transport.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ virtio_transport_send_pkt_work(struct work_struct *work)
120120
if (!skb)
121121
break;
122122

123-
virtio_transport_deliver_tap_pkt(skb);
124123
reply = virtio_vsock_skb_reply(skb);
125124
sgs = vsock->out_sgs;
126125
sg_init_one(sgs[out_sg], virtio_vsock_hdr(skb),
@@ -170,6 +169,8 @@ virtio_transport_send_pkt_work(struct work_struct *work)
170169
break;
171170
}
172171

172+
virtio_transport_deliver_tap_pkt(skb);
173+
173174
if (reply) {
174175
struct virtqueue *rx_vq = vsock->vqs[VSOCK_VQ_RX];
175176
int val;

0 commit comments

Comments
 (0)