From 24c2b67aa45e47b225d430b263d9a34e311bad8b Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Tue, 21 Apr 2020 17:34:41 +0200 Subject: [PATCH] vm-virtio: Improve virtio-net rx queue processing The frame buffer must be updated depending on the amount read from it, which depends on the number and depth of descriptors available at the time of the processing. This patch handles this buffer update, and allow for large buffers to be correctly processed in multiple rounds. Signed-off-by: Sebastien Boeuf --- vm-virtio/src/net_util.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vm-virtio/src/net_util.rs b/vm-virtio/src/net_util.rs index 43e0f3dd9..00394b381 100644 --- a/vm-virtio/src/net_util.rs +++ b/vm-virtio/src/net_util.rs @@ -430,7 +430,15 @@ impl RxVirtio { // Mark that we have at least one pending packet and we need to interrupt the guest. self.deferred_irqs = true; - write_count >= self.bytes_read + // Update the frame_buf buffer. + if write_count < self.bytes_read { + self.frame_buf.copy_within(write_count..self.bytes_read, 0); + self.bytes_read -= write_count; + false + } else { + self.bytes_read = 0; + true + } } }