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.
This commit is contained in:
Frdric Lcaille 2017-07-06 15:02:16 +02:00 committed by Willy Tarreau
parent 570f799877
commit 37a72546f6

View File

@ -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);