]> git.proxmox.com Git - mirror_corosync.git/commitdiff
Convert the nodeid byte order to be aligned with network order
authorXia Li <xli@suse.com>
Tue, 19 Mar 2013 07:08:13 +0000 (07:08 +0000)
committerJan Friesse <jfriesse@redhat.com>
Tue, 19 Mar 2013 15:39:59 +0000 (16:39 +0100)
When using corosync with clear_node_high_bit setting to yes,
the highest bit is cleared.  When all the cluster nodes are in
one subnet, we probably configure the IP addresses as follows:

node1: 147.2.207.64
node2: 147.2.207.192

If the byte order of the nodeid is little endian, wiping off the
highest bit will make the two nodes have the same nodeid!

This patch fixes this by converting the nodeid to network order.

Signed-off-by: Xia Li <xli@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
exec/totemip.c
test/testcpg.c

index 77bcad52901a5971358ac31c12cbbdc68c6454cb..7ba746e9cc43a2176702bbd9b00507a55e3cc91b 100644 (file)
@@ -466,7 +466,7 @@ int totemip_iface_check(struct totem_ip_address *bindnet,
                        if (boundto->family == AF_INET && boundto->nodeid == 0) {
                                unsigned int nodeid = 0;
                                memcpy (&nodeid, boundto->addr, sizeof (int));
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
                                 nodeid = swab32 (nodeid);
 #endif
                                if (mask_high_bit) {
index 67c2d7cd7654a33d0893f767133d44de5ec0d80b..911140c383fd1ede66430a70c723fb0f4f6ccea6 100644 (file)
@@ -84,7 +84,7 @@ static char * node_pid_format(unsigned int nodeid, unsigned int pid) {
        static char buffer[100];
        if (show_ip) {
                struct in_addr saddr;
-#if __BYTE_ORDER == __BIG_ENDIAN
+#if __BYTE_ORDER == __LITTLE_ENDIAN
                saddr.s_addr = swab32(nodeid);
 #else
                saddr.s_addr = nodeid;