summaryrefslogtreecommitdiffstats
path: root/src/vnet/dpo/load_balance.h
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2023-02-21 16:09:47 +0100
committerDave Wallace <dwallacelf@gmail.com>2023-05-19 21:14:52 +0000
commite211ac4886d0ae51c08f77c76ed37b76f01f7629 (patch)
tree040d3e41b1cbc4e3cf31fbfec9e3308786eb07cc /src/vnet/dpo/load_balance.h
parent168bb1d55efeba716bd3004a1f3d19cf25c15191 (diff)
fib: fix load-balance and replicate dpos buckets overflow
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 <bganne@cisco.com>
Diffstat (limited to 'src/vnet/dpo/load_balance.h')
-rw-r--r--src/vnet/dpo/load_balance.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/vnet/dpo/load_balance.h b/src/vnet/dpo/load_balance.h
index 5428e20e981..3605d82a207 100644
--- a/src/vnet/dpo/load_balance.h
+++ b/src/vnet/dpo/load_balance.h
@@ -50,6 +50,12 @@ typedef struct load_balance_main_t_
extern load_balance_main_t load_balance_main;
/**
+ * The maximum number of buckets that a load-balance object can have
+ * This must not overflow the lb_n_buckets field
+ */
+#define LB_MAX_BUCKETS 8192
+
+/**
* The number of buckets that a load-balance object can have and still
* fit in one cache-line
*/
@@ -176,6 +182,10 @@ typedef struct load_balance_t_ {
STATIC_ASSERT(sizeof(load_balance_t) <= CLIB_CACHE_LINE_BYTES,
"A load_balance object size exceeds one cacheline");
+STATIC_ASSERT (LB_MAX_BUCKETS <= CLIB_U16_MAX,
+ "Too many buckets for load_balance object");
+STATIC_ASSERT (LB_MAX_BUCKETS && !(LB_MAX_BUCKETS & (LB_MAX_BUCKETS - 1)),
+ "LB_MAX_BUCKETS must be a power of 2");
/**
* Flags controlling load-balance formatting/display