From: Frédéric Lécaille Date: Thu, 6 Jul 2017 13:02:16 +0000 (+0200) Subject: MINOR: peers: Add additional information to stick-table definition messages. X-Git-Tag: v1.8-dev3~248 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=37a72546f6da720d99facc013ddc28a7f8f68ab9;p=thirdparty%2Fhaproxy.git MINOR: peers: Add additional information to stick-table definition messages. With this patch additional information are added to stick-table definition messages so that to make external application capable of learning peer stick-table configurations. First stick-table entries duration is added followed by the frequency counters type IDs and values. May be backported to 1.7 and 1.6. --- diff --git a/src/peers.c b/src/peers.c index 643b8c52a5..9847cbd0f8 100644 --- a/src/peers.c +++ b/src/peers.c @@ -383,7 +383,8 @@ static int peer_prepare_switchmsg(struct shared_table *st, char *msg, size_t siz { int len; unsigned short datalen; - char *cursor, *datamsg; + struct chunk *chunk; + char *cursor, *datamsg, *chunkp, *chunkq; uint64_t data = 0; unsigned int data_type; @@ -407,6 +408,8 @@ static int peer_prepare_switchmsg(struct shared_table *st, char *msg, size_t siz /* encode table key size */ intencode(st->table->key_size, &cursor); + chunk = get_trash_chunk(); + chunkp = chunkq = chunk->str; /* encode available known data types in table */ for (data_type = 0 ; data_type < STKTABLE_DATA_TYPES ; data_type++) { if (st->table->data_ofs[data_type]) { @@ -414,14 +417,27 @@ static int peer_prepare_switchmsg(struct shared_table *st, char *msg, size_t siz case STD_T_SINT: case STD_T_UINT: case STD_T_ULL: + data |= 1 << data_type; + break; case STD_T_FRQP: data |= 1 << data_type; + intencode(data_type, &chunkq); + intencode(st->table->data_arg[data_type].u, &chunkq); break; } } } intencode(data, &cursor); + /* Encode stick-table entries duration. */ + intencode(st->table->expire, &cursor); + + if (chunkq > chunkp) { + chunk->len = chunkq - chunkp; + memcpy(cursor, chunk->str, chunk->len); + cursor += chunk->len; + } + /* Compute datalen */ datalen = (cursor - datamsg);