mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25:20 +00:00
vm-virtio: net: Fix out-of-range slice panic when under load
The numbr of bytes read was being incorrectly increased by the potential length of the end of the sliced data rather than the number of bytes that was in the range. This caused a panic when the the network was under load by using iperf. It's important to note that in the Firecracker code base the function that read_slice() returns the number of bytes read which is used to increment this counter. The VM memory version however only returns the empty unit "()". Fixes: #166 Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
b608671031
commit
6c06420a11
@ -268,7 +268,8 @@ impl NetEpollHandler {
|
|||||||
);
|
);
|
||||||
match read_result {
|
match read_result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
read_count += limit;
|
// Increment by number of bytes actually read
|
||||||
|
read_count += limit - read_count;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to read slice: {:?}", e);
|
error!("Failed to read slice: {:?}", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user