aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2022-04-08 17:49:32 +0000
committerMohsin Kazmi <sykazmi@cisco.com>2022-04-08 17:52:31 +0000
commit2f13076de7d3e6927a5df048999c6a46981b92fa (patch)
treee6833420feb60f0924f4aa50c2bce4d770872fa2 /src
parent6120441f9fbfd275e3993712b92eeb80da652767 (diff)
devices: fix the offset for af-packet
Type: fix Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com> Change-Id: I12b2e53ddb797cc809a2d742d17a1a60edde385d
Diffstat (limited to 'src')
-rw-r--r--src/vnet/devices/af_packet/device.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/vnet/devices/af_packet/device.c b/src/vnet/devices/af_packet/device.c
index 822dcdc7c22..4e4913a071a 100644
--- a/src/vnet/devices/af_packet/device.c
+++ b/src/vnet/devices/af_packet/device.c
@@ -243,8 +243,7 @@ fill_gso_offload (vlib_buffer_t *b0, vnet_virtio_net_hdr_t *vnet_hdr)
vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
vnet_hdr->csum_start = vnet_buffer (b0)->l4_hdr_offset; // 0x22;
vnet_hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum);
- ip4 = (ip4_header_t *) (vlib_buffer_get_current (b0) +
- vnet_buffer (b0)->l3_hdr_offset);
+ 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);
}
@@ -267,8 +266,7 @@ fill_cksum_offload (vlib_buffer_t *b0, vnet_virtio_net_hdr_t *vnet_hdr)
if (b0->flags & VNET_BUFFER_F_IS_IP4)
{
ip4_header_t *ip4;
- ip4 = (ip4_header_t *) (vlib_buffer_get_current (b0) +
- vnet_buffer (b0)->l3_hdr_offset);
+ 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);
vnet_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
@@ -276,16 +274,14 @@ fill_cksum_offload (vlib_buffer_t *b0, vnet_virtio_net_hdr_t *vnet_hdr)
if (oflags & VNET_BUFFER_OFFLOAD_F_TCP_CKSUM)
{
tcp_header_t *tcp =
- (tcp_header_t *) (vlib_buffer_get_current (b0) +
- vnet_buffer (b0)->l4_hdr_offset);
+ (tcp_header_t *) (b0->data + vnet_buffer (b0)->l4_hdr_offset);
tcp->checksum = ip4_pseudo_header_cksum (ip4);
vnet_hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum);
}
else if (oflags & VNET_BUFFER_OFFLOAD_F_UDP_CKSUM)
{
udp_header_t *udp =
- (udp_header_t *) (vlib_buffer_get_current (b0) +
- vnet_buffer (b0)->l4_hdr_offset);
+ (udp_header_t *) (b0->data + vnet_buffer (b0)->l4_hdr_offset);
udp->checksum = ip4_pseudo_header_cksum (ip4);
vnet_hdr->csum_offset = STRUCT_OFFSET_OF (udp_header_t, checksum);
}
@@ -295,21 +291,18 @@ 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;
- ip6 = (ip6_header_t *) (vlib_buffer_get_current (b0) +
- vnet_buffer (b0)->l3_hdr_offset);
+ ip6 = (ip6_header_t *) (b0->data + vnet_buffer (b0)->l3_hdr_offset);
if (oflags & VNET_BUFFER_OFFLOAD_F_TCP_CKSUM)
{
tcp_header_t *tcp =
- (tcp_header_t *) (vlib_buffer_get_current (b0) +
- vnet_buffer (b0)->l4_hdr_offset);
+ (tcp_header_t *) (b0->data + vnet_buffer (b0)->l4_hdr_offset);
tcp->checksum = ip6_pseudo_header_cksum (ip6);
vnet_hdr->csum_offset = STRUCT_OFFSET_OF (tcp_header_t, checksum);
}
else if (oflags & VNET_BUFFER_OFFLOAD_F_UDP_CKSUM)
{
udp_header_t *udp =
- (udp_header_t *) (vlib_buffer_get_current (b0) +
- vnet_buffer (b0)->l4_hdr_offset);
+ (udp_header_t *) (b0->data + vnet_buffer (b0)->l4_hdr_offset);
udp->checksum = ip6_pseudo_header_cksum (ip6);
vnet_hdr->csum_offset = STRUCT_OFFSET_OF (udp_header_t, checksum);
}