]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: peers: Add additional information to stick-table definition messages.
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 6 Jul 2017 13:02:16 +0000 (15:02 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Jul 2017 08:24:44 +0000 (10:24 +0200)
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.

src/peers.c

index 643b8c52a51be67699f96ac1097ed42d8ae3da72..9847cbd0f82caadbf70062e2eb7911b4777ff0ba 100644 (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);