mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
net_util: queue_pair: Handle TX writev EINVAL gracefully
When writev to the TAP returns EINVAL the guest submitted a malformed packet. Drop it and continue instead of killing the worker thread. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
3402bc0762
commit
17fefa1e45
@@ -118,18 +118,22 @@ impl TxVirtio {
|
||||
retry_write = true;
|
||||
break;
|
||||
}
|
||||
error!("net: tx: failed writing to tap: {e}");
|
||||
return Err(NetQueuePairError::WriteTap(e));
|
||||
}
|
||||
|
||||
if (result as usize) < vnet_hdr_len() {
|
||||
if e.raw_os_error() == Some(libc::EINVAL) {
|
||||
error!("net: tx: dropping malformed packet: {e}");
|
||||
0
|
||||
} else {
|
||||
error!("net: tx: failed writing to tap: {e}");
|
||||
return Err(NetQueuePairError::WriteTap(e));
|
||||
}
|
||||
} else if (result as usize) < vnet_hdr_len() {
|
||||
return Err(NetQueuePairError::InvalidVirtioNetHeader);
|
||||
} else {
|
||||
self.counter_bytes += Wrapping(result as u64 - vnet_hdr_len() as u64);
|
||||
self.counter_frames += Wrapping(1);
|
||||
|
||||
result as u64
|
||||
}
|
||||
|
||||
self.counter_bytes += Wrapping(result as u64 - vnet_hdr_len() as u64);
|
||||
self.counter_frames += Wrapping(1);
|
||||
|
||||
result as u64
|
||||
};
|
||||
|
||||
// For the sake of simplicity (similar to the RX rate limiting), we always
|
||||
|
||||
Reference in New Issue
Block a user