From 5f6950caa893921e7cfe3d5b26109f880e060f8f Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 8 Oct 2014 16:58:12 +0200 Subject: [PATCH] Cluster: process gossip section only for known nodes. With the exception of nodes sending MEET packets: we have to trust them since they can send us MEET packets only when the cluster is initially created or because sysadmin manual action. --- src/cluster.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 70fd6a434..8a788da67 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1533,7 +1533,7 @@ int clusterProcessPacket(clusterLink *link) { } } - /* Process packets by type. */ + /* Initial processing of PING and MEET requests replying with a PONG. */ if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_MEET) { redisLog(REDIS_DEBUG,"Ping packet received: %p", (void*)link->node); @@ -1571,14 +1571,17 @@ int clusterProcessPacket(clusterLink *link) { clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG); } - /* Get info from the gossip section */ - clusterProcessGossipSection(hdr,link); + /* If this is a MEET packet from an unknown node, we still process + * the gossip section here since we have to trust the sender because + * of the message type. */ + if (!sender && type == CLUSTERMSG_TYPE_MEET) + clusterProcessGossipSection(hdr,link); /* Anyway reply with a PONG */ clusterSendPing(link,CLUSTERMSG_TYPE_PONG); } - /* PING or PONG: process config information. */ + /* PING, PONG, MEET: process config information. */ if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_PONG || type == CLUSTERMSG_TYPE_MEET) { @@ -1775,7 +1778,7 @@ int clusterProcessPacket(clusterLink *link) { } /* Get info from the gossip section */ - clusterProcessGossipSection(hdr,link); + if (sender) clusterProcessGossipSection(hdr,link); } else if (type == CLUSTERMSG_TYPE_FAIL) { clusterNode *failing;