Cluster Project branch, master, updated. cluster-2.99.00-17-g4b49aac
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Cluster Project".
The branch, master has been updated
via 4b49aac718e1c8d703d4c4de6dd9fa9bfe83c932 (commit)
from 446a3d0249ea5f352047233103b9e0ade611466d (commit)Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 4b49aac718e1c8d703d4c4de6dd9fa9bfe83c932
Author: Christine Caulfield <[email protected]> Date: Tue May 6 11:48:13 2008 +0100
[CMAN] Fix localhost checking that I broke last week.
Signed-off-by Christine Caulfield <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
cman/daemon/cman-preconfig.c | 44 ++++++++++++++++++++++++++--------------- 1 files changed, 28 insertions(+), 16 deletions(-)
cman/daemon/cman-preconfig.c +28 -16
@@ -110,14 +110,14 @@ static int ipaddr_equal(struct sockaddr_storage *addr1, struct sockaddr_storagereturn 0 ;if (saddr1->sa_family ==AF_INET ) { - addrlen =sizeof (struct in_addr ); + addrlen =sizeof (struct sockaddr_in ); }if (saddr1->sa_family ==AF_INET6 ) { - addrlen =sizeof (struct in6_addr ); + addrlen =sizeof (struct sockaddr_in6 ); }assert (addrlen); -if (memcmp (saddr1->sa_data, saddr2->sa_data, addrlen) ==0 ) +if (memcmp (saddr1, saddr2, addrlen) ==0 )return 1 ;else return 0 ;
@@ -128,32 +128,39 @@ static int ipaddr_equal(struct sockaddr_storage *addr1, struct sockaddr_storagestatic int get_localhost (int family,struct sockaddr_storage *localhost) {char *addr_text; -struct sockaddr *saddr = (struct sockaddr *)localhost; - -memset (localhost,0 ,sizeof (struct sockaddr_storage )); +struct addrinfo *ainfo; +struct addrinfo ahints; +int ret;if (family ==AF_INET ) { addr_text =LOCALHOST_IPV4 ; -if (inet_pton (family, addr_text, (char *)&nodeid) <=0 ) { -return -1 ; - } }else { addr_text =LOCALHOST_IPV6 ; } -if (inet_pton (family, addr_text, (char *)saddr->sa_data) <=0 ) +memset (&ahints,0 ,sizeof (ahints)); + ahints.ai_socktype =SOCK_DGRAM ; + ahints.ai_protocol =IPPROTO_UDP ; + ahints.ai_family = family; + +/* Lookup the nodename address */ + ret =getaddrinfo (addr_text,NULL , &ahints, &ainfo); +if (ret)return -1 ; - localhost->ss_family = family; +memset (localhost,0 ,sizeof (struct sockaddr_storage )); +memcpy (localhost, ainfo->ai_addr, ainfo->ai_addrlen); +freeaddrinfo (ainfo);return 0 ; }/* Return the address family of an IP[46] name */ -static int address_family (char *addr) +static int address_family (char *addr,struct sockaddr_storage *ssaddr) {struct addrinfo *ainfo;struct addrinfo ahints; +int family;int ret;memset (&ahints,0 ,sizeof (ahints));
@@ -165,7 +172,12 @@ static int address_family(char *addr)if (ret)return -1 ; -return ainfo->ai_family; +memset (ssaddr,0 ,sizeof (struct sockaddr_storage )); +memcpy (ssaddr, ainfo->ai_addr, ainfo->ai_addrlen); + family = ainfo->ai_family; + +freeaddrinfo (ainfo); +return family; }
@@ -178,14 +190,14 @@ static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr,int ret =0 ;/* Check the families match */ -if (address_family (mcast) != -address_family (ifaddr)) { +if (address_family (mcast, &mcast_addr) != +address_family (ifaddr, &if_addr)) {sprintf (error_reason,"Node address family does not match multicast address family" );return -1 ; }/* Check it's not bound to localhost, sigh */ -get_localhost (mcast_addr.ss_family, &localhost); +get_localhost (if_addr.ss_family, &localhost);if (ipaddr_equal (&localhost, &if_addr)) {sprintf (error_reason,"Node address is localhost, please choose a real host address" );return -1 ;
hooks/post-receive
--
Cluster Project