diff options
author | Liu Zhen <zhenliu215252@sohu-inc.com> | 2020-05-27 11:55:23 +0800 |
---|---|---|
committer | Oran Agra <oran@redislabs.com> | 2020-10-27 08:49:22 +0200 |
commit | ee4696b1501c22f3dd79d3f89058ab603981a87a (patch) | |
tree | f188dddf7c2f0c074a0857da88011484e1d844e8 | |
parent | c9e370c6b8d8ccdbc211765bd6c313c5b1e1ca98 (diff) | |
download | redis-ee4696b1501c22f3dd79d3f89058ab603981a87a.tar.gz |
fix clusters mixing accidentally by gossip
`clusterStartHandshake` will start hand handshake
and eventually send CLUSTER MEET message, which is strictly prohibited
in the REDIS CLUSTER SPEC.
Only system administrator can initiate CLUSTER MEET message.
Futher, according to the SPEC, rather than IP/PORT pairs, only nodeid
can be trusted.
(cherry picked from commit 84a7a90586d9302ccd65fb61c47b9970c13cf363)
-rw-r--r-- | src/cluster.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cluster.c b/src/cluster.c index 78d7290c4..e33553479 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1434,7 +1434,10 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) { } } else { /* If it's not in NOADDR state and we don't have it, we - * start a handshake process against this IP/PORT pairs. + * add it to our trusted dict with exact nodeid and flag. + * Note that we cannot simply start a handshake against + * this IP/PORT pairs, since IP/PORT can be reused already, + * otherwise we risk joining another cluster. * * Note that we require that the sender of this gossip message * is a well known node in our cluster, otherwise we risk @@ -1443,7 +1446,12 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) { !(flags & CLUSTER_NODE_NOADDR) && !clusterBlacklistExists(g->nodename)) { - clusterStartHandshake(g->ip,ntohs(g->port),ntohs(g->cport)); + clusterNode *node; + node = createClusterNode(g->nodename, flags); + memcpy(node->ip,g->ip,NET_IP_STR_LEN); + node->port = ntohs(g->port); + node->cport = ntohs(g->cport); + clusterAddNode(node); } } |