MINOR: peers: Do not emit global stick-table names.
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.
diff --git a/src/peers.c b/src/peers.c
index 1cb7fe9..2a9fde1 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -524,9 +524,9 @@
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 @@
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;
}