Skip to content

Commit 5201aa4

Browse files
mstsirkindavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 75300ad commit 5201aa4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/vhost/net.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,10 @@ static void handle_rx(struct vhost_net *net)
650650
break;
651651
}
652652
/* TODO: Should check and handle checksum. */
653+
654+
hdr.num_buffers = cpu_to_vhost16(vq, headcount);
653655
if (likely(mergeable) &&
654-
memcpy_toiovecend(nvq->hdr, (unsigned char *)&headcount,
656+
memcpy_toiovecend(nvq->hdr, (void *)&hdr.num_buffers,
655657
offsetof(typeof(hdr), num_buffers),
656658
sizeof hdr.num_buffers)) {
657659
vq_err(vq, "Failed num_buffers write");

0 commit comments

Comments
 (0)