Skip to contentSkip to conversation

vhost: fix net control virtqueue used length

PATCH Applied Eugenio Pérez 2 participants 3 messages Jun 5, 2025 – Jun 13, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: fix net control virtqueue used length

By the standard this is the number of bytes written.

Fixes 474f4d7840ad ("vhost: add control virtqueue")
---
 lib/vhost/virtio_net_ctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/vhost/virtio_net_ctrl.c +1 -1
index 63c0a06b4f..603a8db728 100644
@@ -229,7 +229,7 @@ virtio_net_ctrl_push(struct virtio_net *dev, struct virtio_net_ctrl_elem *ctrl_e
 
 	used_elem = &cvq->used->ring[cvq->last_used_idx & (cvq->size - 1)];
 	used_elem->id = ctrl_elem->head_idx;
-	used_elem->len = ctrl_elem->n_descs;
+	used_elem->len = sizeof(*ctrl_elem->desc_ack);
 
 	cvq->last_used_idx++;
 
Signature · 1 line
2.49.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Eugenio Pérez

By the standard this is the number of bytes written.

Fixes 474f4d7840ad ("vhost: add control virtqueue")
---
  lib/vhost/virtio_net_ctrl.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/vhost/virtio_net_ctrl.c +0 -0
index 63c0a06b4f..603a8db728 100644

lib/vhost/virtio_net_ctrl.c virtio_net_ctrl_push(struct virtio_net *dev, struct virtio_net_ctrl_elem *ctrl_e · line 235

Quoted 8 lines
lib/vhost/virtio_net_ctrl.c +1 -1
@@ -229,7 +229,7 @@ virtio_net_ctrl_push(struct virtio_net *dev, struct virtio_net_ctrl_elem *ctrl_e
 
  	used_elem = &cvq->used->ring[cvq->last_used_idx & (cvq->size - 1)];
  	used_elem->id = ctrl_elem->head_idx;
-	used_elem->len = ctrl_elem->n_descs;
+	used_elem->len = sizeof(*ctrl_elem->desc_ack);
 
  	cvq->last_used_idx++;
 

Thanks,
Maxime

#2 lore raw
In reply to Eugenio Pérez
Quoted 15 lines · Eugenio Pérez

By the standard this is the number of bytes written.

Fixes 474f4d7840ad ("vhost: add control virtqueue")
---
  lib/vhost/virtio_net_ctrl.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/vhost/virtio_net_ctrl.c +0 -0
index 63c0a06b4f..603a8db728 100644

lib/vhost/virtio_net_ctrl.c virtio_net_ctrl_push(struct virtio_net *dev, struct virtio_net_ctrl_elem *ctrl_e · line 235

Quoted 8 lines
lib/vhost/virtio_net_ctrl.c +1 -1
@@ -229,7 +229,7 @@ virtio_net_ctrl_push(struct virtio_net *dev, struct virtio_net_ctrl_elem *ctrl_e
 
  	used_elem = &cvq->used->ring[cvq->last_used_idx & (cvq->size - 1)];
  	used_elem->id = ctrl_elem->head_idx;
-	used_elem->len = ctrl_elem->n_descs;
+	used_elem->len = sizeof(*ctrl_elem->desc_ack);
 
  	cvq->last_used_idx++;
 

Applied to next-virtio/for-net-next.

Thanks,
Maxime