From 7461143194e1367869ae05dde72f1f531c1d980f Mon Sep 17 00:00:00 2001 From: CMGS Date: Tue, 31 Mar 2026 14:30:31 +0000 Subject: [PATCH] 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 --- net_util/src/ctrl_queue.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net_util/src/ctrl_queue.rs b/net_util/src/ctrl_queue.rs index f449d5527..e42b4c0ca 100644 --- a/net_util/src/ctrl_queue.rs +++ b/net_util/src/ctrl_queue.rs @@ -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)