[PATCH] Convert the nodeid byte order to be aligned with network order

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
 exec/totemip.c |    2 +-
 test/testcpg.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/exec/totemip.c b/exec/totemip.c
index 77bcad5..7ba746e 100644
--- a/exec/totemip.c
+++ b/exec/totemip.c
@@ -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) {
diff --git a/test/testcpg.c b/test/testcpg.c
index 67c2d7c..911140c 100644
--- a/test/testcpg.c
+++ b/test/testcpg.c
@@ -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;
-- 
1.6.0.2

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux