vlib: fix offload flags value reset 37/31337/2
authorBenoît Ganne <bganne@cisco.com>
Thu, 18 Feb 2021 09:34:33 +0000 (10:34 +0100)
committerDamjan Marion <dmarion@me.com>
Tue, 23 Feb 2021 10:01:15 +0000 (10:01 +0000)
When a buffer is freed and re-allocated for a new packet, opaque2 is
not reset, so the offload flags can be set to a stale value.
Make sure the offload flags are reset to the current value on 1st set.

Type: fix
Fixes: 6809538e646bf86c000dc1faba60b0a4157ad898

Change-Id: I4048febedf25b9995dbd080a11495ee7dbe59153
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/vnet/buffer.h

index fb734d5..bd70ea2 100644 (file)
@@ -524,8 +524,17 @@ format_function_t format_vnet_buffer_offload;
 static_always_inline void
 vnet_buffer_offload_flags_set (vlib_buffer_t *b, u32 oflags)
 {
-  vnet_buffer2 (b)->oflags |= oflags;
-  b->flags |= VNET_BUFFER_F_OFFLOAD;
+  if (b->flags & VNET_BUFFER_F_OFFLOAD)
+    {
+      /* add a flag to existing offload */
+      vnet_buffer2 (b)->oflags |= oflags;
+    }
+  else
+    {
+      /* no offload yet: reset offload flags to new value */
+      vnet_buffer2 (b)->oflags = oflags;
+      b->flags |= VNET_BUFFER_F_OFFLOAD;
+    }
 }
 
 static_always_inline void