summaryrefslogtreecommitdiffstats
path: root/src/vnet/buffer.h
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2019-11-21 10:31:03 +0000
committerDamjan Marion <dmarion@me.com>2019-11-26 09:54:29 +0000
commit7dbf9a1a4fff5c3b20ad972289e49e3f88e82f2d (patch)
treefbe9a1362abd78baa612da2c7d8a055c6f60c12f /src/vnet/buffer.h
parent981a690b7d25c96ea56f95ece693377f95b93fc1 (diff)
fib: reduce save_rewrite_length to u8
This is a preparation step for migrating NAT to use SVR (shallow virtual reassembly) to conserve space in vnet_buffer. Since max rewrite length is currently pre-data size (128), u8 is sufficient to hold that value. Type: refactor Change-Id: I5374bb396e178245b870cb0bbf1370d2a54230bc Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/vnet/buffer.h')
-rw-r--r--src/vnet/buffer.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/vnet/buffer.h b/src/vnet/buffer.h
index aed72c5031a..59a8256b902 100644
--- a/src/vnet/buffer.h
+++ b/src/vnet/buffer.h
@@ -168,7 +168,7 @@ typedef struct
};
/* Rewrite length */
- u32 save_rewrite_length;
+ u8 save_rewrite_length;
/* MFIB RPF ID */
u32 rpf_id;
@@ -250,7 +250,7 @@ typedef struct
u8 pyld_proto:3; /* dpo_proto_t */
u8 rsvd:5;
/* Rewrite length */
- u32 save_rewrite_length;
+ u8 save_rewrite_length;
/* Save the mpls header length including all label stack */
u8 mpls_hdr_length;
/*
@@ -380,6 +380,16 @@ typedef struct
};
} vnet_buffer_opaque_t;
+#define VNET_REWRITE_TOTAL_BYTES (VLIB_BUFFER_PRE_DATA_SIZE)
+
+STATIC_ASSERT (STRUCT_SIZE_OF (vnet_buffer_opaque_t, ip.save_rewrite_length)
+ == STRUCT_SIZE_OF (vnet_buffer_opaque_t,
+ mpls.save_rewrite_length)
+ && STRUCT_SIZE_OF (vnet_buffer_opaque_t,
+ mpls.save_rewrite_length) == 1
+ && VNET_REWRITE_TOTAL_BYTES < UINT8_MAX,
+ "save_rewrite_length member must be able to hold the max value of rewrite length");
+
/*
* The opaque field of the vlib_buffer_t is interpreted as a
* vnet_buffer_opaque_t. Hence it should be big enough to accommodate one.