diff options
Diffstat (limited to 'src/vnet/devices/virtio/device.c')
-rw-r--r-- | src/vnet/devices/virtio/device.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c index 3482336b2ad..fb996d551fa 100644 --- a/src/vnet/devices/virtio/device.c +++ b/src/vnet/devices/virtio/device.c @@ -282,6 +282,8 @@ static_always_inline void set_checksum_offsets (vlib_buffer_t * b, virtio_net_hdr_v1_t * hdr, const int is_l2) { + u32 oflags = vnet_buffer2 (b)->oflags; + if (b->flags & VNET_BUFFER_F_IS_IP4) { ip4_header_t *ip4; @@ -290,11 +292,11 @@ set_checksum_offsets (vlib_buffer_t * b, virtio_net_hdr_v1_t * hdr, 0 /* ip6 */ ); 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) + if (oflags & VNET_BUFFER_OFFLOAD_F_TCP_CKSUM) { hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum); } - else if (b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM) + else if (oflags & VNET_BUFFER_OFFLOAD_F_UDP_CKSUM) { hdr->csum_offset = STRUCT_OFFSET_OF (udp_header_t, checksum); } @@ -305,7 +307,7 @@ set_checksum_offsets (vlib_buffer_t * b, virtio_net_hdr_v1_t * hdr, */ ip4 = (ip4_header_t *) (vlib_buffer_get_current (b) + gho.l3_hdr_offset); - if (b->flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM) + if (oflags & VNET_BUFFER_OFFLOAD_F_IP_CKSUM) ip4->checksum = ip4_header_checksum (ip4); } else if (b->flags & VNET_BUFFER_F_IS_IP6) @@ -315,11 +317,11 @@ set_checksum_offsets (vlib_buffer_t * b, virtio_net_hdr_v1_t * hdr, 1 /* ip6 */ ); 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) + if (oflags & VNET_BUFFER_OFFLOAD_F_TCP_CKSUM) { hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum); } - else if (b->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM) + else if (oflags & VNET_BUFFER_OFFLOAD_F_UDP_CKSUM) { hdr->csum_offset = STRUCT_OFFSET_OF (udp_header_t, checksum); } @@ -330,6 +332,8 @@ static_always_inline void set_gso_offsets (vlib_buffer_t * b, virtio_net_hdr_v1_t * hdr, const int is_l2) { + u32 oflags = vnet_buffer2 (b)->oflags; + if (b->flags & VNET_BUFFER_F_IS_IP4) { ip4_header_t *ip4; @@ -348,7 +352,7 @@ set_gso_offsets (vlib_buffer_t * b, virtio_net_hdr_v1_t * hdr, * virtio devices do not support IP4 checksum offload. So driver takes care * of it while doing tx. */ - if (b->flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM) + if (oflags & VNET_BUFFER_OFFLOAD_F_IP_CKSUM) ip4->checksum = ip4_header_checksum (ip4); } else if (b->flags & VNET_BUFFER_F_IS_IP6) @@ -392,8 +396,7 @@ add_buffer_to_slot (vlib_main_t * vm, vlib_node_runtime_t * node, goto done; } } - else if (b->flags & (VNET_BUFFER_F_OFFLOAD_TCP_CKSUM | - VNET_BUFFER_F_OFFLOAD_UDP_CKSUM)) + else if (b->flags & VNET_BUFFER_F_OFFLOAD) { if (csum_offload) set_checksum_offsets (b, hdr, is_l2); @@ -584,8 +587,7 @@ add_buffer_to_slot_packed (vlib_main_t * vm, vlib_node_runtime_t * node, goto done; } } - else if (b->flags & (VNET_BUFFER_F_OFFLOAD_TCP_CKSUM | - VNET_BUFFER_F_OFFLOAD_UDP_CKSUM)) + else if (b->flags & VNET_BUFFER_F_OFFLOAD) { if (csum_offload) set_checksum_offsets (b, hdr, is_l2); |