diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2015-02-03 04:07:06 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-04 16:59:31 -0500 |
commit | 5201aa49b0fc12d9bf911090744ca04066bad4a7 (patch) | |
tree | a7fab4ac90b4f820531e639a390998255b4fb2b1 /drivers/vhost | |
parent | 75300ad2d91fac50852dc4123977d55e64c874cc (diff) |
vhost/net: fix up num_buffers endian-ness
In virtio 1.0 mode, when mergeable buffers are enabled on a big-endian
host, num_buffers wasn't byte-swapped correctly, so large incoming
packets got corrupted.
To fix, fill it in within hdr - this also makes sure it gets
the correct type.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/vhost')
-rw-r--r-- | drivers/vhost/net.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index d415d69dc237..9484d5652ca5 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c | |||
@@ -650,8 +650,10 @@ static void handle_rx(struct vhost_net *net) | |||
650 | break; | 650 | break; |
651 | } | 651 | } |
652 | /* TODO: Should check and handle checksum. */ | 652 | /* TODO: Should check and handle checksum. */ |
653 | |||
654 | hdr.num_buffers = cpu_to_vhost16(vq, headcount); | ||
653 | if (likely(mergeable) && | 655 | if (likely(mergeable) && |
654 | memcpy_toiovecend(nvq->hdr, (unsigned char *)&headcount, | 656 | memcpy_toiovecend(nvq->hdr, (void *)&hdr.num_buffers, |
655 | offsetof(typeof(hdr), num_buffers), | 657 | offsetof(typeof(hdr), num_buffers), |
656 | sizeof hdr.num_buffers)) { | 658 | sizeof hdr.num_buffers)) { |
657 | vq_err(vq, "Failed num_buffers write"); | 659 | vq_err(vq, "Failed num_buffers write"); |