From 6ea5c4744a132ca5f21b8cffab7676a386d6ebf5 Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Thu, 28 Oct 2021 10:50:47 +0200 Subject: fib: allow vnet rewrite max size to be smaller the pre_data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no reason to enforce vnet rewrite size to be equal to pre_data. Moreover, since vnet rewrite size is now saved as u8, this limits pre_data to 192 bytes. Type: fix Fixes: 7dbf9a1a4fff5c3b20ad972289e49e3f88e82f2d Change-Id: I3f848aa905ea4a794f3b4aa62c929a481261a3f1 Signed-off-by: Benoît Ganne --- src/vnet/adj/rewrite.h | 4 ++-- src/vnet/buffer.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vnet/adj/rewrite.h b/src/vnet/adj/rewrite.h index 4234986dc37..5cb90e47318 100644 --- a/src/vnet/adj/rewrite.h +++ b/src/vnet/adj/rewrite.h @@ -136,7 +136,7 @@ always_inline void vnet_rewrite_clear_data_internal (vnet_rewrite_header_t * rw, int max_size) { /* Sanity check values carefully for this clib_memset operation */ - ASSERT ((max_size > 0) && (max_size < VLIB_BUFFER_PRE_DATA_SIZE)); + ASSERT ((max_size > 0) && (max_size < VNET_REWRITE_TOTAL_BYTES)); rw->data_bytes = 0; clib_memset (rw->data, 0xfe, max_size); @@ -147,7 +147,7 @@ vnet_rewrite_set_data_internal (vnet_rewrite_header_t * rw, int max_size, void *data, int data_bytes) { /* Sanity check values carefully for this clib_memset operation */ - ASSERT ((max_size > 0) && (max_size < VLIB_BUFFER_PRE_DATA_SIZE)); + ASSERT ((max_size > 0) && (max_size < VNET_REWRITE_TOTAL_BYTES)); ASSERT ((data_bytes >= 0) && (data_bytes < max_size)); rw->data_bytes = data_bytes; diff --git a/src/vnet/buffer.h b/src/vnet/buffer.h index 2b3152fbcd6..09abedd5e74 100644 --- a/src/vnet/buffer.h +++ b/src/vnet/buffer.h @@ -417,7 +417,9 @@ typedef struct }; } vnet_buffer_opaque_t; -#define VNET_REWRITE_TOTAL_BYTES (VLIB_BUFFER_PRE_DATA_SIZE) +#define VNET_REWRITE_TOTAL_BYTES 128 +STATIC_ASSERT (VNET_REWRITE_TOTAL_BYTES <= VLIB_BUFFER_PRE_DATA_SIZE, + "VNET_REWRITE_TOTAL_BYTES too big"); STATIC_ASSERT (STRUCT_SIZE_OF (vnet_buffer_opaque_t, ip.save_rewrite_length) == STRUCT_SIZE_OF (vnet_buffer_opaque_t, -- cgit 1.2.3-korg