diff --git a/src/cluster.c b/src/cluster.c index 5819d872b..4e42737fb 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -1465,7 +1465,8 @@ int clusterProcessPacket(clusterLink *link) { /* Perform sanity checks */ if (totlen < 16) return 1; /* At least signature, version, totlen, count. */ - if (ntohs(hdr->ver) != 0) return 1; /* Can't handle versions other than 0.*/ + if (ntohs(hdr->ver) != CLUSTER_PROTO_VER) + return 1; /* Can't handle versions other than the current one.*/ if (totlen > sdslen(link->rcvbuf)) return 1; if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_PONG || type == CLUSTERMSG_TYPE_MEET) @@ -2029,6 +2030,7 @@ void clusterBuildMessageHdr(clusterMsg *hdr, int type) { myself->slaveof : myself; memset(hdr,0,sizeof(*hdr)); + hdr->ver = htons(CLUSTER_PROTO_VER); hdr->sig[0] = 'R'; hdr->sig[1] = 'C'; hdr->sig[2] = 'm'; diff --git a/src/cluster.h b/src/cluster.h index 7d6567d45..ef5caf0d6 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -163,10 +163,11 @@ typedef struct { char nodename[REDIS_CLUSTER_NAMELEN]; uint32_t ping_sent; uint32_t pong_received; - char ip[REDIS_IP_STR_LEN]; /* IP address last time it was seen */ - uint16_t port; /* port last time it was seen */ - uint16_t flags; - uint32_t notused; /* for 64 bit alignment */ + char ip[REDIS_IP_STR_LEN]; /* IP address last time it was seen */ + uint16_t port; /* port last time it was seen */ + uint16_t flags; /* node->flags copy */ + uint16_t notused1; /* Some room for future improvements. */ + uint32_t notused2; } clusterMsgDataGossip; typedef struct { @@ -211,6 +212,7 @@ union clusterMsgData { } update; }; +#define CLUSTER_PROTO_VER 0 /* Cluster bus protocol version. */ typedef struct { char sig[4]; /* Siganture "RCmb" (Redis Cluster message bus). */ diff --git a/src/redis.h b/src/redis.h index 89d97f55e..0c191d06f 100644 --- a/src/redis.h +++ b/src/redis.h @@ -131,7 +131,7 @@ typedef long long mstime_t; /* millisecond time type. */ #define REDIS_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC 1 #define REDIS_DEFAULT_MIN_SLAVES_TO_WRITE 0 #define REDIS_DEFAULT_MIN_SLAVES_MAX_LAG 10 -#define REDIS_IP_STR_LEN INET6_ADDRSTRLEN +#define REDIS_IP_STR_LEN 46 /* INET6_ADDRSTRLEN is 46, but we need to be sure */ #define REDIS_PEER_ID_LEN (REDIS_IP_STR_LEN+32) /* Must be enough for ip:port */ #define REDIS_BINDADDR_MAX 16 #define REDIS_MIN_RESERVED_FDS 32