diff --git a/exec/totemip.c b/exec/totemip.c index 02841072..287f3833 100644 --- a/exec/totemip.c +++ b/exec/totemip.c @@ -376,7 +376,8 @@ static void parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int l int totemip_iface_check(struct totem_ip_address *bindnet, struct totem_ip_address *boundto, int *interface_up, - int *interface_num) + int *interface_num, + int mask_high_bit) { int fd; struct { @@ -514,6 +515,18 @@ int totemip_iface_check(struct totem_ip_address *bindnet, } } finished: + /* + * Mask 32nd bit off to workaround bugs in other poeples code + * if configuration requests it. + */ + if (ipaddr.family == AF_INET && ipaddr.nodeid == 0) { + unsigned int nodeid = 0; + memcpy (&nodeid, ipaddr.addr, sizeof (int)); + if ((nodeid & 0x7FFFFFFF) && mask_high_bit) { + nodeid &= 0x7FFFFFFF; + } + ipaddr.nodeid = nodeid; + } totemip_copy (boundto, &ipaddr); close(fd); return 0; diff --git a/exec/totemnet.c b/exec/totemnet.c index ba740487..9df7d85a 100644 --- a/exec/totemnet.c +++ b/exec/totemnet.c @@ -699,18 +699,9 @@ static int netif_determine ( int res; res = totemip_iface_check (bindnet, bound_to, - interface_up, interface_num); + interface_up, interface_num, ++ 0); // TODO andrew can address this instance->totem_config->clear_node_high_bit); - /* - * If the desired binding is to an IPV4 network and nodeid isn't - * specified, retrieve the node id from this_ip network address - * - * IPV6 networks must have a node ID specified since the node id - * field is only 32 bits. - */ - if (bound_to->family == AF_INET && bound_to->nodeid == 0) { - memcpy (&bound_to->nodeid, bound_to->addr, sizeof (int)); - } return (res); } diff --git a/include/corosync/totem/totemip.h b/include/corosync/totem/totemip.h index 36336372..08d7b71e 100644 --- a/include/corosync/totem/totemip.h +++ b/include/corosync/totem/totemip.h @@ -72,7 +72,7 @@ extern int totemip_sockaddr_to_totemip_convert(struct sockaddr_storage *saddr, s extern int totemip_totemip_to_sockaddr_convert(struct totem_ip_address *ip_addr, uint16_t port, struct sockaddr_storage *saddr, int *addrlen); extern int totemip_parse(struct totem_ip_address *totemip, char *addr, int family); -extern int totemip_iface_check(struct totem_ip_address *bindnet, struct totem_ip_address *boundto, int *interface_up, int *interface_num); +extern int totemip_iface_check(struct totem_ip_address *bindnet, struct totem_ip_address *boundto, int *interface_up, int *interface_num, int mask_high_bit); /* These two simulate a zero in_addr by clearing the family field */ static inline void totemip_zero_set(struct totem_ip_address *addr)