]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: peers: Do not emit global stick-table names.
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 20 Mar 2019 14:09:45 +0000 (15:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 7 May 2019 04:54:07 +0000 (06:54 +0200)
This commit "MINOR: stick-table: Add prefixes to stick-table names"
prepended the "peers" section name to stick-table names declared in such "peers"
sections followed by a '/' character.  This is not this name which must be sent
over the network to avoid collisions with stick-table name declared as backends.
As the '/' character is forbidden as first character of a backend name, we prefix
the stick-table names declared in peers sections only with a '/' character.
With such declarations:

    peers mypeers
       table t1

backend t1
   stick-table ... peers mypeers

at peer protocol level, "t1" declared as stick-table in "mypeers" section is different
of "t1" stick-table declared as backend.

In src/peers.c, only two modifications were required: use ->nid stktable struct
member in place of ->id in peer_prepare_switchmsg() to prepare the stick-table
definition messages. Same thing in peer_treat_definemsg() to treat a stick-table
definition messages.

src/cfgparse.c
src/peers.c

index 9a086173698a51fcafac63f2f2551d019a24eb6d..b0d1f5df8c7d2f83f7be75e6416e5ea23355683b 100644 (file)
@@ -883,7 +883,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                 * followed by a '/' character and the table name argument.
                 */
                chunk_reset(&trash);
-               if (!chunk_strcpy(&trash, curpeers->id) || !chunk_memcat(&trash, "/", 1)) {
+               if (!chunk_strcpy(&trash, curpeers->id)) {
                        ha_alert("parsing [%s:%d]: '%s %s' : stick-table name too long.\n",
                                 file, linenum, args[0], args[1]);
                        err_code |= ERR_ALERT | ERR_FATAL;
@@ -891,7 +891,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                }
 
                prefix_len = trash.data;
-               if (!chunk_strcat(&trash, args[1])) {
+               if (!chunk_memcat(&trash, "/", 1) || !chunk_strcat(&trash, args[1])) {
                        ha_alert("parsing [%s:%d]: '%s %s' : stick-table name too long.\n",
                                 file, linenum, args[0], args[1]);
                        err_code |= ERR_ALERT | ERR_FATAL;
index 1cb7fe9fe7ac5a5998c2ada7803a72a308932a99..2a9fde1cca0140a3a6aefbe7a0b581de46e175ce 100644 (file)
@@ -524,9 +524,9 @@ static int peer_prepare_switchmsg(char *msg, size_t size, struct peer_prep_param
        intencode(st->local_id, &cursor);
 
        /* encode table name */
-       len = strlen(st->table->id);
+       len = strlen(st->table->nid);
        intencode(len, &cursor);
-       memcpy(cursor, st->table->id, len);
+       memcpy(cursor, st->table->nid, len);
        cursor += len;
 
        /* encode table type */
@@ -1483,8 +1483,8 @@ static inline int peer_treat_definemsg(struct appctx *appctx, struct peer *p,
                if (st->remote_id == table_id)
                        st->remote_id = 0;
 
-               if (!p->remote_table && (table_id_len == strlen(st->table->id)) &&
-                   (memcmp(st->table->id, *msg_cur, table_id_len) == 0))
+               if (!p->remote_table && (table_id_len == strlen(st->table->nid)) &&
+                   (memcmp(st->table->nid, *msg_cur, table_id_len) == 0))
                        p->remote_table = st;
        }