aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio/device.c
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2020-04-07 16:42:57 +0200
committerDamjan Marion <dmarion@me.com>2020-04-08 14:40:33 +0000
commit7d697185437722ffce23a2d0b8838fc390cc6c84 (patch)
tree0e16ffcfcc3c333a7ffbe488dc5c6bcfa244be54 /src/vnet/devices/virtio/device.c
parent88cecfad98d2e8b32e68b90538c2c4cb906eb204 (diff)
virtio: fix the tcp/udp checksum offloads
Some vhost-backend calculates the wrong checksum in case of tcp/udp offload when driver resets tcp/udp checksum field to '0'. Type: fix Change-Id: I1d2a9b95b3d5cc1decac38027104a04df2af4680 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vnet/devices/virtio/device.c')
-rw-r--r--src/vnet/devices/virtio/device.c26
1 files changed, 0 insertions, 26 deletions
diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c
index 76f85588ec8..e812b373a89 100644
--- a/src/vnet/devices/virtio/device.c
+++ b/src/vnet/devices/virtio/device.c
@@ -159,18 +159,10 @@ set_checksum_offsets (vlib_main_t * vm, virtio_if_t * vif, vlib_buffer_t * b,
hdr->csum_start = gho.l4_hdr_offset; // 0x22;
if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
{
- tcp_header_t *tcp =
- (tcp_header_t *) (vlib_buffer_get_current (b) +
- gho.l4_hdr_offset);
- tcp->checksum = 0;
hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum);
}
else if (b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM)
{
- udp_header_t *udp =
- (udp_header_t *) (vlib_buffer_get_current (b) +
- gho.l4_hdr_offset);
- udp->checksum = 0;
hdr->csum_offset = STRUCT_OFFSET_OF (udp_header_t, checksum);
}
@@ -190,18 +182,10 @@ set_checksum_offsets (vlib_main_t * vm, virtio_if_t * vif, vlib_buffer_t * b,
hdr->csum_start = gho.l4_hdr_offset; // 0x36;
if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
{
- tcp_header_t *tcp =
- (tcp_header_t *) (vlib_buffer_get_current (b) +
- gho.l4_hdr_offset);
- tcp->checksum = 0;
hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum);
}
else if (b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM)
{
- udp_header_t *udp =
- (udp_header_t *) (vlib_buffer_get_current (b) +
- gho.l4_hdr_offset);
- udp->checksum = 0;
hdr->csum_offset = STRUCT_OFFSET_OF (udp_header_t, checksum);
}
}
@@ -226,15 +210,10 @@ add_buffer_to_slot (vlib_main_t * vm, virtio_if_t * vif,
if (b->flags & VNET_BUFFER_F_IS_IP4)
{
ip4_header_t *ip4;
- tcp_header_t *tcp;
gso_header_offset_t gho = vnet_gso_header_offset_parser (b, 0);
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
hdr->gso_size = vnet_buffer2 (b)->gso_size;
hdr->hdr_len = gho.l4_hdr_offset + gho.l4_hdr_sz;
- tcp =
- (tcp_header_t *) (vlib_buffer_get_current (b) +
- gho.l4_hdr_offset);
- tcp->checksum = 0;
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset; // 0x22;
hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum);
@@ -250,16 +229,11 @@ add_buffer_to_slot (vlib_main_t * vm, virtio_if_t * vif,
}
else if (b->flags & VNET_BUFFER_F_IS_IP6)
{
- tcp_header_t *tcp;
gso_header_offset_t gho = vnet_gso_header_offset_parser (b, 1);
hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
hdr->gso_size = vnet_buffer2 (b)->gso_size;
hdr->hdr_len = gho.l4_hdr_offset + gho.l4_hdr_sz;
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
- tcp =
- (tcp_header_t *) (vlib_buffer_get_current (b) +
- gho.l4_hdr_offset);
- tcp->checksum = 0;
hdr->csum_start = gho.l4_hdr_offset; // 0x36;
hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum);
}