devices: fix the offset for af-packet 22/35922/2
authorMohsin Kazmi <sykazmi@cisco.com>
Fri, 8 Apr 2022 17:49:32 +0000 (17:49 +0000)
committerMohsin Kazmi <sykazmi@cisco.com>
Fri, 8 Apr 2022 17:52:31 +0000 (17:52 +0000)
Type: fix

Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Change-Id: I12b2e53ddb797cc809a2d742d17a1a60edde385d

src/vnet/devices/af_packet/device.c

index 822dcdc..4e4913a 100644 (file)
@@ -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);
        }