Просмотр исходного кода

Convert the nodeid byte order to be aligned with network order

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>
Xia Li 13 лет назад
Родитель
Сommit
ca6051e80c
2 измененных файлов с 2 добавлено и 2 удалено
  1. 1 1
      exec/totemip.c
  2. 1 1
      test/testcpg.c

+ 1 - 1
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) {

+ 1 - 1
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;