Skip to content

Commit 7461143

Browse files
CMGSrbradford
authored andcommitted
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>
1 parent c601682 commit 7461143

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

net_util/src/ctrl_queue.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ impl CtrlQueue {
171171
.translate_gva(access_platform, status_desc.len() as usize),
172172
)
173173
.map_err(Error::GuestMemory)?;
174-
let len = ctrl_desc.len() + data_desc.len() + status_desc.len();
174+
// Per virtio spec 2.6.8, used_len is the number of bytes written
175+
// to device-writable descriptors. Only the status byte is written.
176+
let len = status_desc.len();
175177

176178
queue
177179
.add_used(desc_chain.memory(), desc_chain.head_index(), len)

0 commit comments

Comments
 (0)