devices: fix the l2 hdr offset in af_packet transmit side 19/37519/1
authorMohsin Kazmi <sykazmi@cisco.com>
Tue, 25 Oct 2022 19:23:51 +0000 (19:23 +0000)
committerMohsin Kazmi <sykazmi@cisco.com>
Tue, 25 Oct 2022 19:29:30 +0000 (19:29 +0000)
Type: fix

af_packet transmit node uses header offsets to set the
appropriate metadata for packet with offload. But
l2_hdr_offset is not correctly set by previous node.
This patch makes use of curren_data field as l2_hdr_offset.

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

src/vnet/devices/af_packet/device.c

index 2e9b7a4..17291f7 100644 (file)
@@ -291,8 +291,7 @@ 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;
+  i16 l4_hdr_offset = vnet_buffer (b0)->l4_hdr_offset - b0->current_data;
   if (b0->flags & VNET_BUFFER_F_IS_IP4)
     {
       ip4_header_t *ip4;
@@ -329,8 +328,7 @@ 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;
+  i16 l4_hdr_offset = vnet_buffer (b0)->l4_hdr_offset - b0->current_data;
   if (b0->flags & VNET_BUFFER_F_IS_IP4)
     {
       ip4_header_t *ip4;