Patchwork [PATCHv2,07/14] virtio-net: first s/g is always at start of buf

login
register
mail settings
Submitter Michael S. Tsirkin
Date Sept. 25, 2012, 11:12 a.m.
Message ID <bd012b98905ceaf18f54b033d1cc618a242bd348.1348571185.git.mst@redhat.com>
Download mbox | patch
Permalink /patch/186789/
State New
Headers show

Comments

Michael S. Tsirkin - Sept. 25, 2012, 11:12 a.m.
We know offset is 0, assert that.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio-net.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index fde2322..b9a8be4 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -631,6 +631,7 @@  static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t
         }
 
         if (i == 0) {
+            assert(offset == 0);
             if (n->mergeable_rx_bufs) {
                 mhdr_cnt = iov_copy(mhdr_sg, ARRAY_SIZE(mhdr_sg),
                                     sg, elem.in_num,
@@ -638,8 +639,8 @@  static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t
                                     sizeof(mhdr.num_buffers));
             }
 
-            receive_header(n, sg, elem.in_num, buf + offset, size - offset);
-            offset += n->host_hdr_len;
+            receive_header(n, sg, elem.in_num, buf, size);
+            offset = n->host_hdr_len;
             total += n->guest_hdr_len;
             guest_offset = n->guest_hdr_len;
         } else {