diff options
author | Ronnie Sahlberg <sahlberg@ronnie> | 2007-09-10 16:23:06 +1000 |
---|---|---|
committer | Ronnie Sahlberg <sahlberg@ronnie> | 2007-09-10 16:23:06 +1000 |
commit | 9c1b2f4856de9247dcc485252575adeef3ebe5ec (patch) | |
tree | 56451c6d8fdebc4c7594484614c0536f4c003535 /ctdb/common/system_linux.c | |
parent | 50381480eb4c9dda78074dea5b10c504a2ea9fc5 (diff) | |
parent | f3927719c980d38d8839d8f99ae7c67b7c44840f (diff) | |
download | samba-9c1b2f4856de9247dcc485252575adeef3ebe5ec.tar.gz samba-9c1b2f4856de9247dcc485252575adeef3ebe5ec.tar.xz samba-9c1b2f4856de9247dcc485252575adeef3ebe5ec.zip |
merged patch from tridge
(This used to be ctdb commit 90ab044093f67b656e21861ce12d6fee5794d21f)
Diffstat (limited to 'ctdb/common/system_linux.c')
-rw-r--r-- | ctdb/common/system_linux.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c index fc94bd14ee..82a6575bab 100644 --- a/ctdb/common/system_linux.c +++ b/ctdb/common/system_linux.c @@ -246,9 +246,8 @@ int ctdb_sys_send_tcp(int s, ifname, if non-NULL, will return the name of the interface this ip is tied to */ -bool ctdb_sys_have_ip(const char *ip, bool *is_loopback, TALLOC_CTX *mem_ctx, char **ifname) +bool ctdb_sys_have_ip(struct sockaddr_in ip, bool *is_loopback, TALLOC_CTX *mem_ctx, char **ifname) { - struct sockaddr_in sin; struct ifreq *ifr = NULL; struct ifconf ifc; int s, i, num_ifs; @@ -261,14 +260,12 @@ bool ctdb_sys_have_ip(const char *ip, bool *is_loopback, TALLOC_CTX *mem_ctx, ch *ifname = NULL; } - sin.sin_port = 0; - inet_aton(ip, &sin.sin_addr); - sin.sin_family = AF_INET; + ip.sin_port = 0; s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (s == -1) { return false; } - ret = bind(s, (struct sockaddr *)&sin, sizeof(sin)); + ret = bind(s, (struct sockaddr *)&ip, sizeof(ip)); if (ret) { goto finished; } @@ -305,7 +302,7 @@ bool ctdb_sys_have_ip(const char *ip, bool *is_loopback, TALLOC_CTX *mem_ctx, ch } /* this is not the interface you are looking for */ - if(strcmp(inet_ntoa(sa->sin_addr), ip)){ + if (!ctdb_same_ip(sa, &ip)) { continue; } @@ -320,7 +317,7 @@ bool ctdb_sys_have_ip(const char *ip, bool *is_loopback, TALLOC_CTX *mem_ctx, ch } /* was this ip tied to a loopback interface ? */ - if(ifr[i].ifr_flags & IFF_LOOPBACK) { + if (ifr[i].ifr_flags & IFF_LOOPBACK) { if (is_loopback != NULL) { *is_loopback = true; } |