From: Willy Tarreau Date: Tue, 29 Sep 2026 14:19:07 +0000 (+0200) Subject: MINOR: stick-table: provide a function to estimate on-wire data size X-Git-Tag: v3.5-dev8~95 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=1e7260bc6948a57ac585b13d9ca8e57843a0f7f7;p=haproxy.git MINOR: stick-table: provide a function to estimate on-wire data size We'll need to estimate the on-wire size of the stored data as a majorant to adjust key sizes, so let's provide a new function for this. It considers all varint at their maximum size. --- diff --git a/include/haproxy/stick_table.h b/include/haproxy/stick_table.h index 37d85faf3..72bdc9558 100644 --- a/include/haproxy/stick_table.h +++ b/include/haproxy/stick_table.h @@ -141,6 +141,25 @@ static inline int stktable_type_size(int type) return 0; } +/* return upper protocol size for standard data type when transported + * over the peers protocol. + */ +static inline int stktable_type_proto_size(int type) +{ + switch(type) { + case STD_T_SINT: + case STD_T_UINT: + return 5; // 32-bit varint + case STD_T_ULL: + return 9; // 64-bit varint + case STD_T_FRQP: + return 15; // 3*32-bit varint + case STD_T_DICT: + return 5; // 32-bit varint + } + return 0; +} + int stktable_alloc_data_type(struct stktable *t, int type, const char *sa, const char *sa2); /* return pointer for data type in sticky session of table , all