From 0cbb3d4230db324b69385bae88949fd4d7518cdd Mon Sep 17 00:00:00 2001 From: Motomu Utsumi Date: Wed, 7 Feb 2018 17:38:02 +0900 Subject: [PATCH] lkl: fix vnet header flag handling with the LKL_VIRTIO_NET_F_GUEST_CSUM LKL with the LKL_VIRTIO_NET_F_GUEST_CSUM offload overwrites the vnet header flag of the received packet with LKL_VIRTIO_NET_HDR_F_DATA_VALID. So if LKL receives a packet which has the LKL_VIRTIO_NET_HDR_F_NEEDS_CSUM flag, LKL overwrites and loses the LKL_VIRTIO_NET_HDR_F_NEEDS_CSUM flag. If the destination of the packet is LKL, this is not a problem. But, if LKL forwards the packet, this behavior leads issue. If LKL with the LKL_VIRTIO_NET_F_GUEST_CSUM offload receives a packet which has the LKL_VIRTIO_NET_HDR_F_NEEDS_CSUM flag and the incorrect checksum, LKL forwards and transmits the packet which has the incorrect checksum and no flag. This commit fixes this issue by OR operation instead of overwriting. This commit changes the behavior as follows. If LKL with the LKL_VIRTIO_NET_F_GUEST_CSUM offload receives a packet which has the LKL_VIRTIO_NET_HDR_F_NEEDS_CSUM flag and the incorrect checksum, LKL forwards and transmits the packet which has the incorrect checksum and "the LKL_VIRTIO_NET_HDR_F_NEEDS_CSUM flag". Signed-off-by: Motomu Utsumi --- tools/lkl/lib/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lkl/lib/virtio_net.c b/tools/lkl/lib/virtio_net.c index a06c2135ad2c62..9f9ff5b5a88ceb 100644 --- a/tools/lkl/lib/virtio_net.c +++ b/tools/lkl/lib/virtio_net.c @@ -117,7 +117,7 @@ static int net_enqueue(struct virtio_dev *dev, int q, struct virtio_req *req) header->num_buffers = i; if (dev->device_features & BIT(LKL_VIRTIO_NET_F_GUEST_CSUM)) - header->flags = LKL_VIRTIO_NET_HDR_F_DATA_VALID; + header->flags |= LKL_VIRTIO_NET_HDR_F_DATA_VALID; } else { bad_request("tried to push on non-existent queue"); return -1;