summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vnet/adj/adj.h2
-rw-r--r--src/vnet/adj/rewrite.h14
-rw-r--r--src/vnet/buffer.h14
-rw-r--r--src/vnet/l2/l2_xcrw.h2
-rw-r--r--src/vnet/vxlan-gbp/vxlan_gbp.h2
-rw-r--r--src/vnet/vxlan/vxlan.h2
6 files changed, 24 insertions, 12 deletions
diff --git a/src/vnet/adj/adj.h b/src/vnet/adj/adj.h
index 37389c346a0..9d1577fe911 100644
--- a/src/vnet/adj/adj.h
+++ b/src/vnet/adj/adj.h
@@ -316,7 +316,7 @@ typedef struct ip_adjacency_t_
CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);
/* Rewrite in second/third cache lines */
- vnet_declare_rewrite (VLIB_BUFFER_PRE_DATA_SIZE);
+ VNET_DECLARE_REWRITE;
/**
* more control plane members that do not fit on the first cacheline
diff --git a/src/vnet/adj/rewrite.h b/src/vnet/adj/rewrite.h
index 9b83b5ac0db..c2084ea0a4a 100644
--- a/src/vnet/adj/rewrite.h
+++ b/src/vnet/adj/rewrite.h
@@ -105,12 +105,14 @@ STATIC_ASSERT (sizeof (vnet_rewrite_header_t) <= 16,
vnet_rewrite_declare(64 - 2*sizeof(int)) rw;
} my_adjacency_t;
*/
-#define vnet_declare_rewrite(total_bytes) \
-struct { \
- vnet_rewrite_header_t rewrite_header; \
- \
- u8 rewrite_data[(total_bytes) - sizeof (vnet_rewrite_header_t)]; \
-}
+#define VNET_DECLARE_REWRITE \
+ struct \
+ { \
+ vnet_rewrite_header_t rewrite_header; \
+ \
+ u8 rewrite_data[(VNET_REWRITE_TOTAL_BYTES) - \
+ sizeof (vnet_rewrite_header_t)]; \
+ }
always_inline void
vnet_rewrite_clear_data_internal (vnet_rewrite_header_t * rw, int max_size)
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.
diff --git a/src/vnet/l2/l2_xcrw.h b/src/vnet/l2/l2_xcrw.h
index e21c884c401..fbb2c8031ac 100644
--- a/src/vnet/l2/l2_xcrw.h
+++ b/src/vnet/l2/l2_xcrw.h
@@ -31,7 +31,7 @@ typedef struct
* Let: rewrite_header.sw_if_index = tx_fib_index or ~0.
* rewrite_header.next_index = L2_XCRW_NEXT_XXX
*/
- vnet_declare_rewrite (VLIB_BUFFER_PRE_DATA_SIZE);
+ VNET_DECLARE_REWRITE;
} l2_xcrw_adjacency_t;
typedef struct
diff --git a/src/vnet/vxlan-gbp/vxlan_gbp.h b/src/vnet/vxlan-gbp/vxlan_gbp.h
index af2e1809099..d17f75799d6 100644
--- a/src/vnet/vxlan-gbp/vxlan_gbp.h
+++ b/src/vnet/vxlan-gbp/vxlan_gbp.h
@@ -127,7 +127,7 @@ typedef struct
u32 dev_instance; /* Real device instance in tunnel vector */
u32 user_instance; /* Instance name being shown to user */
- vnet_declare_rewrite (VLIB_BUFFER_PRE_DATA_SIZE);
+ VNET_DECLARE_REWRITE;
} vxlan_gbp_tunnel_t;
#define foreach_vxlan_gbp_input_next \
diff --git a/src/vnet/vxlan/vxlan.h b/src/vnet/vxlan/vxlan.h
index 7ade7c009cd..e8fc15be3ce 100644
--- a/src/vnet/vxlan/vxlan.h
+++ b/src/vnet/vxlan/vxlan.h
@@ -129,7 +129,7 @@ typedef struct
u32 dev_instance; /* Real device instance in tunnel vector */
u32 user_instance; /* Instance name being shown to user */
- vnet_declare_rewrite (VLIB_BUFFER_PRE_DATA_SIZE);
+ VNET_DECLARE_REWRITE;
} vxlan_tunnel_t;
#define foreach_vxlan_input_next \