ip: fix offload flags handling 02/32002/4
authorAloys Augustin <aloaugus@cisco.com>
Thu, 15 Apr 2021 16:12:51 +0000 (18:12 +0200)
committerBeno�t Ganne <bganne@cisco.com>
Mon, 19 Apr 2021 17:32:05 +0000 (17:32 +0000)
The per-protocol offload flags only make sense if F_OFFLOAD is set on
the vlib buffer main flags.
vnet_calc_checksums_inline is called from many places which should do
this check and don't, moving the check to this function is less error
prone and shouldn't have an impact on performance since the function
is always_inline.

Type: fix
Change-Id: I0297f109f31e409f07bfbaea3cd8b90c659658c4
Signed-off-by: Aloys Augustin <aloaugus@cisco.com>
src/vnet/interface_output.c
src/vnet/interface_output.h

index 2d220b7..7d058c2 100644 (file)
@@ -165,9 +165,8 @@ vnet_interface_output_trace (vlib_main_t * vm,
 static_always_inline void
 vnet_interface_output_handle_offload (vlib_main_t *vm, vlib_buffer_t *b)
 {
-  if (b->flags & VNET_BUFFER_F_OFFLOAD)
-    vnet_calc_checksums_inline (vm, b, b->flags & VNET_BUFFER_F_IS_IP4,
-                               b->flags & VNET_BUFFER_F_IS_IP6);
+  vnet_calc_checksums_inline (vm, b, b->flags & VNET_BUFFER_F_IS_IP4,
+                             b->flags & VNET_BUFFER_F_IS_IP6);
 }
 
 static_always_inline uword
index 6b766d3..bfd2066 100644 (file)
@@ -87,6 +87,9 @@ vnet_calc_checksums_inline (vlib_main_t * vm, vlib_buffer_t * b,
   udp_header_t *uh;
   u32 oflags = vnet_buffer2 (b)->oflags;
 
+  if (!(b->flags & VNET_BUFFER_F_OFFLOAD))
+    return;
+
   ASSERT (!(is_ip4 && is_ip6));
 
   ip4 = (ip4_header_t *) (b->data + vnet_buffer (b)->l3_hdr_offset);