summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/virtio/device.c42
-rw-r--r--src/vnet/devices/virtio/vhost_user_output.c6
-rw-r--r--src/vnet/gso/gso.h2
3 files changed, 44 insertions, 6 deletions
diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c
index 856e5f275e3..76f85588ec8 100644
--- a/src/vnet/devices/virtio/device.c
+++ b/src/vnet/devices/virtio/device.c
@@ -158,9 +158,21 @@ set_checksum_offsets (vlib_main_t * vm, virtio_if_t * vif, vlib_buffer_t * b,
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset; // 0x22;
if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
- hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum);
+ {
+ 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)
- hdr->csum_offset = STRUCT_OFFSET_OF (udp_header_t, checksum);
+ {
+ 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);
+ }
/*
* virtio devices do not support IP4 checksum offload. So driver takes care
@@ -177,9 +189,21 @@ set_checksum_offsets (vlib_main_t * vm, virtio_if_t * vif, vlib_buffer_t * b,
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset; // 0x36;
if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
- hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum);
+ {
+ 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)
- hdr->csum_offset = STRUCT_OFFSET_OF (udp_header_t, checksum);
+ {
+ 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);
+ }
}
}
@@ -202,10 +226,15 @@ 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);
@@ -221,11 +250,16 @@ 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);
}
diff --git a/src/vnet/devices/virtio/vhost_user_output.c b/src/vnet/devices/virtio/vhost_user_output.c
index c1b8fe1a92a..e1f42ce1559 100644
--- a/src/vnet/devices/virtio/vhost_user_output.c
+++ b/src/vnet/devices/virtio/vhost_user_output.c
@@ -253,12 +253,18 @@ vhost_user_handle_tx_offload (vhost_user_intf_t * vui, vlib_buffer_t * b,
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset;
hdr->csum_offset = offsetof (udp_header_t, checksum);
+ udp_header_t *udp =
+ (udp_header_t *) (vlib_buffer_get_current (b) + gho.l4_hdr_offset);
+ udp->checksum = 0;
}
else if (b->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
{
hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
hdr->csum_start = gho.l4_hdr_offset;
hdr->csum_offset = offsetof (tcp_header_t, checksum);
+ tcp_header_t *tcp =
+ (tcp_header_t *) (vlib_buffer_get_current (b) + gho.l4_hdr_offset);
+ tcp->checksum = 0;
}
/* GSO offload */
diff --git a/src/vnet/gso/gso.h b/src/vnet/gso/gso.h
index 79869c2644b..0e46c36f74d 100644
--- a/src/vnet/gso/gso.h
+++ b/src/vnet/gso/gso.h
@@ -106,14 +106,12 @@ vnet_gso_header_offset_parser (vlib_buffer_t * b0, int is_ip6)
tcp_header_t *tcp = (tcp_header_t *) (vlib_buffer_get_current (b0) +
gho.l4_hdr_offset);
l4_hdr_sz = tcp_header_bytes (tcp);
- tcp->checksum = 0;
}
else if (l4_proto == IP_PROTOCOL_UDP)
{
udp_header_t *udp = (udp_header_t *) (vlib_buffer_get_current (b0) +
gho.l4_hdr_offset);
l4_hdr_sz = sizeof (*udp);
- udp->checksum = 0;
}
if (b0->flags & (VNET_BUFFER_F_IS_IP4 | VNET_BUFFER_F_IS_IP6))