From 0014966c1e39cf2dcb4ca271900b93990d823bec Mon Sep 17 00:00:00 2001 From: Matt Stancliff <matt@genges.com> Date: Tue, 28 Oct 2014 12:25:16 -0400 Subject: [PATCH] Networking: add more outbound IP binding fixes Same as the original bind fixes (we just missed these the first time around). This helps Redis not automatically send connections from the first IP on an interface if we are bound to a specific IP address (e.g. with multiple IP aliases on one interface, you want to send from _your_ IP, not from the first IP on the interface). --- src/cluster.c | 4 ++-- src/replication.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 8a788da6..1967b3f4 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -4307,8 +4307,8 @@ int migrateGetSocket(redisClient *c, robj *host, robj *port, long timeout) { } /* Create the socket */ - fd = anetTcpNonBlockConnect(server.neterr,c->argv[1]->ptr, - atoi(c->argv[2]->ptr)); + fd = anetTcpNonBlockBindConnect(server.neterr,c->argv[1]->ptr, + atoi(c->argv[2]->ptr),REDIS_BIND_ADDR); if (fd == -1) { sdsfree(name); addReplyErrorFormat(c,"Can't connect to target node: %s", diff --git a/src/replication.c b/src/replication.c index 77f9fa8b..1a4ca250 100644 --- a/src/replication.c +++ b/src/replication.c @@ -1357,7 +1357,8 @@ error: int connectWithMaster(void) { int fd; - fd = anetTcpNonBlockConnect(NULL,server.masterhost,server.masterport); + fd = anetTcpNonBlockBindConnect(NULL, + server.masterhost,server.masterport,REDIS_BIND_ADDR); if (fd == -1) { redisLog(REDIS_WARNING,"Unable to connect to MASTER: %s", strerror(errno));