From 4eb21b61325b8c2c255fa3390d46d1a0675f36f0 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Sat, 28 May 2016 18:23:42 +0000 Subject: [PATCH] virtio/net_device: Fix bug with mergeable rx buffers Snabb could over-report the size of jumbo packets delivered to the VM under certain circumstances. --- src/lib/virtio/net_device.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/virtio/net_device.lua b/src/lib/virtio/net_device.lua index 9c93e66fbb..be06069833 100644 --- a/src/lib/virtio/net_device.lua +++ b/src/lib/virtio/net_device.lua @@ -306,7 +306,16 @@ function VirtioNetDevice:tx_buffer_add_mrg_rxbuf(tx_p, addr, len) self.tx.finished = true end - return to_copy + -- XXX The "adjust" is needed to counter-balance an adjustment made + -- in virtq_device. If we don't make this adjustment then we break + -- chaining together multiple buffers in that we report the size of + -- each buffer (except for the first) to be 12 bytes more than it + -- really is. This causes the VM to see an inflated ethernet packet + -- size which may or may not be noticed by an application. + -- + -- This formulation is not optimal and it would be nice to make + -- this code more transparent. -luke + return to_copy - adjust end function VirtioNetDevice:tx_packet_end_mrg_rxbuf(header_id, total_size, tx_p)