From e211ac4886d0ae51c08f77c76ed37b76f01f7629 Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Tue, 21 Feb 2023 16:09:47 +0100 Subject: fib: fix load-balance and replicate dpos buckets overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit load-balance and replicate dpos both store their number of buckets as u16, which can overflow if too many paths are configured. For load-balance it can happens quite quickly because of weights normalization. Type: fix Change-Id: I0c78c39fc3d40626dfc58b49e7d99d71f9852b50 Signed-off-by: Benoît Ganne --- src/vnet/dpo/replicate_dpo.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/vnet/dpo/replicate_dpo.h') diff --git a/src/vnet/dpo/replicate_dpo.h b/src/vnet/dpo/replicate_dpo.h index 908c20c1d56..d21f52a4833 100644 --- a/src/vnet/dpo/replicate_dpo.h +++ b/src/vnet/dpo/replicate_dpo.h @@ -40,6 +40,12 @@ typedef struct replicate_main_t_ extern replicate_main_t replicate_main; +/** + * The number of buckets that a replicate object can have + * This must not overflow the rep_n_buckets field + */ +#define REP_MAX_BUCKETS 1024 + /** * The number of buckets that a load-balance object can have and still * fit in one cache-line @@ -108,6 +114,8 @@ typedef struct replicate_t_ { STATIC_ASSERT(sizeof(replicate_t) <= CLIB_CACHE_LINE_BYTES, "A replicate object size exceeds one cacheline"); +STATIC_ASSERT (REP_MAX_BUCKETS <= CLIB_U16_MAX, + "Too many buckets for replicate object"); /** * Flags controlling load-balance formatting/display -- cgit 1.2.3-korg