Skip to contentSkip to conversation

virtio-net: Ignore num_buffers when unused

PATCH In review Akihiko Odaki 3 participants 3 messages May 26, 2025 – May 29, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 virtio-net: Ignore num_buffers when unused

If VIRTIO_NET_F_MRG_RXBUF has not been negotiated, vhost_net of Linux prior to 6.14 and QEMU prior to 10.0.0 leave num_buffers uninitialized while the specification tells to set it to one.

Let drivers ignore this field to make them compatible with old vhost_net/QEMU, similar to the hdr_len field, which is also marked as unreliable due to implementation bugs.

---
Changes in v4:
- Noted that the mentioned bugs are fixed with newer implementation versions in the patch message.
- Noted that the bugs are of devices. (Parav Pandit)
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- s/MUST/SHOULD/ (Michael S. Tsirkin)
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Corrected the change description to tell vhost_net and QEMU leaves num_buffers uninitialized where it used to tell they set it to zero.
- Restored statements that require devices to set num_buffers to one.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 device-types/net/description.tex | 6 ++++++
 1 file changed, 6 insertions(+)
device-types/net/description.tex +6 -0
index 76585b0..4a2df5a 100644
@@ -863,6 +863,12 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
 This is due to various bugs in implementations.
 \end{note}
 
+If VIRTIO_NET_F_MRG_RXBUF has not been negotiated, the driver SHOULD ignore
+\field{num_buffers}.
+\begin{note}
+This is due to bugs in device implementations.
+\end{note}
+
 If neither VIRTIO_NET_HDR_F_NEEDS_CSUM nor
 VIRTIO_NET_HDR_F_DATA_VALID is set, the driver MUST NOT
 rely on the packet checksum being correct.

---
base-commit: b495841a8e80d12c1130f8868f4128866291142d
change-id: 20241226-reserved-d5960f173223

Best regards,

Signature · 1 line
Akihiko Odaki <[email protected]>
Reviewed-by on v4 1/1
#1 lore raw
Quoted 5 lines · Akihiko Odaki

If VIRTIO_NET_F_MRG_RXBUF has not been negotiated, vhost_net of Linux prior to 6.14 and QEMU prior to 10.0.0 leave num_buffers uninitialized while the specification tells to set it to one.

Quoted 7 lines

Let drivers ignore this field to make them compatible with old vhost_net/QEMU, similar to the hdr_len field, which is also marked as unreliable due to implementation bugs.

---

Thanks

Acked-by on v4 1/1
#2 lore raw
In reply to Akihiko Odaki
Quoted 37 lines · Akihiko Odaki

If VIRTIO_NET_F_MRG_RXBUF has not been negotiated, vhost_net of Linux prior to 6.14 and QEMU prior to 10.0.0 leave num_buffers uninitialized while the specification tells to set it to one.

Let drivers ignore this field to make them compatible with old vhost_net/QEMU, similar to the hdr_len field, which is also marked as unreliable due to implementation bugs.

---
Changes in v4:
- Noted that the mentioned bugs are fixed with newer implementation versions in the patch message.
- Noted that the bugs are of devices. (Parav Pandit)
- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- s/MUST/SHOULD/ (Michael S. Tsirkin)
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Corrected the change description to tell vhost_net and QEMU leaves num_buffers uninitialized where it used to tell they set it to zero.
- Restored statements that require devices to set num_buffers to one.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 device-types/net/description.tex | 6 ++++++
 1 file changed, 6 insertions(+)
device-types/net/description.tex +0 -0
index 76585b0..4a2df5a 100644
@@ -863,6 +863,12 @@ \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network
 This is due to various bugs in implementations.
 \end{note}

device-types/net/description.tex \subsubsection{Processing of Incoming Packets}\label{sec:Device Types / Network · line 874

Quoted 10 lines
device-types/net/description.tex +6 -0
 
+If VIRTIO_NET_F_MRG_RXBUF has not been negotiated, the driver SHOULD ignore
+\field{num_buffers}.
+\begin{note}
+This is due to bugs in device implementations.
+\end{note}
+
 If neither VIRTIO_NET_HDR_F_NEEDS_CSUM nor
 VIRTIO_NET_HDR_F_DATA_VALID is set, the driver MUST NOT
 rely on the packet checksum being correct.
Quoted 7 lines

---
base-commit: b495841a8e80d12c1130f8868f4128866291142d
change-id: 20241226-reserved-d5960f173223

Best regards,

Signature · 1 line
Akihiko Odaki <[email protected]>