Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Michael S. Tsirkin and committed by
David S. Miller
5201aa49 75300ad2

+3 -1
+3 -1
drivers/vhost/net.c
··· 650 650 break; 651 651 } 652 652 /* TODO: Should check and handle checksum. */ 653 + 654 + hdr.num_buffers = cpu_to_vhost16(vq, headcount); 653 655 if (likely(mergeable) && 654 - memcpy_toiovecend(nvq->hdr, (unsigned char *)&headcount, 656 + memcpy_toiovecend(nvq->hdr, (void *)&hdr.num_buffers, 655 657 offsetof(typeof(hdr), num_buffers), 656 658 sizeof hdr.num_buffers)) { 657 659 vq_err(vq, "Failed num_buffers write");