aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/devices/af_packet/device.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/vnet/devices/af_packet/device.c b/src/vnet/devices/af_packet/device.c
index 74bc1c8c42c..1d14c9b8dcf 100644
--- a/src/vnet/devices/af_packet/device.c
+++ b/src/vnet/devices/af_packet/device.c
@@ -235,29 +235,37 @@ static_always_inline void
fill_gso_offload (vlib_buffer_t *b0, vnet_virtio_net_hdr_t *vnet_hdr)
{
vnet_buffer_oflags_t oflags = vnet_buffer (b0)->oflags;
+ i16 l4_hdr_offset =
+ vnet_buffer (b0)->l4_hdr_offset - vnet_buffer (b0)->l2_hdr_offset;
if (b0->flags & VNET_BUFFER_F_IS_IP4)
{
ip4_header_t *ip4;
vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
vnet_hdr->gso_size = vnet_buffer2 (b0)->gso_size;
- vnet_hdr->hdr_len =
- vnet_buffer (b0)->l4_hdr_offset + vnet_buffer2 (b0)->gso_l4_hdr_sz;
+ vnet_hdr->hdr_len = l4_hdr_offset + vnet_buffer2 (b0)->gso_l4_hdr_sz;
vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
- vnet_hdr->csum_start = vnet_buffer (b0)->l4_hdr_offset; // 0x22;
+ vnet_hdr->csum_start = l4_hdr_offset; // 0x22;
vnet_hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum);
ip4 = (ip4_header_t *) (b0->data + vnet_buffer (b0)->l3_hdr_offset);
if (oflags & VNET_BUFFER_OFFLOAD_F_IP_CKSUM)
ip4->checksum = ip4_header_checksum (ip4);
+ tcp_header_t *tcp =
+ (tcp_header_t *) (b0->data + vnet_buffer (b0)->l4_hdr_offset);
+ tcp->checksum = ip4_pseudo_header_cksum (ip4);
}
else if (b0->flags & VNET_BUFFER_F_IS_IP6)
{
+ ip6_header_t *ip6;
vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
vnet_hdr->gso_size = vnet_buffer2 (b0)->gso_size;
- vnet_hdr->hdr_len =
- vnet_buffer (b0)->l4_hdr_offset + vnet_buffer2 (b0)->gso_l4_hdr_sz;
+ vnet_hdr->hdr_len = l4_hdr_offset + vnet_buffer2 (b0)->gso_l4_hdr_sz;
vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
- vnet_hdr->csum_start = vnet_buffer (b0)->l4_hdr_offset; // 0x36;
+ vnet_hdr->csum_start = l4_hdr_offset; // 0x36;
vnet_hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum);
+ ip6 = (ip6_header_t *) (b0->data + vnet_buffer (b0)->l3_hdr_offset);
+ tcp_header_t *tcp =
+ (tcp_header_t *) (b0->data + vnet_buffer (b0)->l4_hdr_offset);
+ tcp->checksum = ip6_pseudo_header_cksum (ip6);
}
}
@@ -265,6 +273,8 @@ static_always_inline void
fill_cksum_offload (vlib_buffer_t *b0, vnet_virtio_net_hdr_t *vnet_hdr)
{
vnet_buffer_oflags_t oflags = vnet_buffer (b0)->oflags;
+ i16 l4_hdr_offset =
+ vnet_buffer (b0)->l4_hdr_offset - vnet_buffer (b0)->l2_hdr_offset;
if (b0->flags & VNET_BUFFER_F_IS_IP4)
{
ip4_header_t *ip4;
@@ -272,7 +282,7 @@ fill_cksum_offload (vlib_buffer_t *b0, vnet_virtio_net_hdr_t *vnet_hdr)
if (oflags & VNET_BUFFER_OFFLOAD_F_IP_CKSUM)
ip4->checksum = ip4_header_checksum (ip4);
vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
- vnet_hdr->csum_start = 0x22;
+ vnet_hdr->csum_start = l4_hdr_offset;
if (oflags & VNET_BUFFER_OFFLOAD_F_TCP_CKSUM)
{
tcp_header_t *tcp =
@@ -292,7 +302,7 @@ fill_cksum_offload (vlib_buffer_t *b0, vnet_virtio_net_hdr_t *vnet_hdr)
{
ip6_header_t *ip6;
vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
- vnet_hdr->csum_start = 0x36;
+ vnet_hdr->csum_start = l4_hdr_offset;
ip6 = (ip6_header_t *) (b0->data + vnet_buffer (b0)->l3_hdr_offset);
if (oflags & VNET_BUFFER_OFFLOAD_F_TCP_CKSUM)
{