net_util: fix ctrl_queue used_len to only count written bytes

The control queue handler passed the total length of all
descriptors (header + data + status) as used_len to add_used.
Per virtio spec section 2.6.8, used_len must only count bytes
written to device-writable descriptors. The device only writes
the 1-byte status/ack field.

Windows NetKVM >= 0.1.285 strictly checks this value and calls
NdisMRemoveMiniport when len != sizeof(virtio_net_ctrl_ack),
removing the network adapter immediately after activation.

Signed-off-by: CMGS <ilskdw@gmail.com>
This commit is contained in:
CMGS
2026-03-31 14:30:31 +00:00
committed by Rob Bradford
parent c60168256a
commit 7461143194

View File

@@ -171,7 +171,9 @@ impl CtrlQueue {
.translate_gva(access_platform, status_desc.len() as usize),
)
.map_err(Error::GuestMemory)?;
let len = ctrl_desc.len() + data_desc.len() + status_desc.len();
// Per virtio spec 2.6.8, used_len is the number of bytes written
// to device-writable descriptors. Only the status byte is written.
let len = status_desc.len();
queue
.add_used(desc_chain.memory(), desc_chain.head_index(), len)