mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
net_util: queue_pair: Handle RX short read gracefully
When readv returns fewer bytes than vnet_hdr_len the frame is truncated. Report the truncated length to the guest in the used ring instead of returning a fatal InvalidVirtioNetHeader error. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
c71a8ea8dd
commit
945e1f2654
@@ -293,7 +293,15 @@ impl RxVirtio {
|
||||
return Err(NetQueuePairError::ReadTap(e));
|
||||
}
|
||||
} else if (result as usize) < vnet_hdr_len() {
|
||||
return Err(NetQueuePairError::InvalidVirtioNetHeader);
|
||||
error!(
|
||||
"net: rx: buffer too short for virtio_net_hdr ({result} < {})",
|
||||
vnet_hdr_len()
|
||||
);
|
||||
desc_chain
|
||||
.memory()
|
||||
.write_obj(0u16, num_buffers_addr)
|
||||
.map_err(NetQueuePairError::GuestMemory)?;
|
||||
0
|
||||
} else {
|
||||
// Write num_buffers to guest memory. Always 1 because the
|
||||
// frame is never spread over more than one descriptor chain.
|
||||
|
||||
Reference in New Issue
Block a user