Christine Caulfield pisze:
If you don't set the nodeid then it defaults to the IP address. But it's then an int, not an IP address, as far as corosync is concerned. The fact that it was an IP address is irrelevant, it's just a way of getting a unique node number.

The error here is in testcpg passing it into inet_ntoa. In many clusters - especially those using the Red Hat stack, the nodeIDs will be small integers, and the output from that will be rubbish.

So nodeid should never be used as IP address as testcpg suggests. I think this option should be removed from testcpg.
Attached patch does it.
Other option is to change default value from ip to ntohl(ip) (is it safe?)
and then in clients like testcpg use inet_ntoa(htonl(nodeid)).

Regards,
Wojtek
Index: testcpg.c
===================================================================
--- testcpg.c   (wersja 2374)
+++ testcpg.c   (kopia robocza)
@@ -50,7 +50,6 @@
 #include <corosync/cpg.h>
 
 static int quit = 0;
-static int show_ip = 0;
 
 static void print_cpgname (const struct cpg_name *name)
 {
@@ -69,18 +68,9 @@
        void *msg,
        size_t msg_len)
 {
-       if (show_ip) {
-               struct in_addr saddr;
-               saddr.s_addr = nodeid;
-               printf("DeliverCallback: message (len=%lu)from node/pid %s/%d: 
'%s'\n",
-                      (unsigned long int) msg_len,
-                      inet_ntoa(saddr), pid, (const char *)msg);
-       }
-       else {
-               printf("DeliverCallback: message (len=%lu)from node/pid %d/%d: 
'%s'\n",
-                      (unsigned long int) msg_len, nodeid, pid,
-                      (const char *)msg);
-       }
+       printf("DeliverCallback: message (len=%lu)from node/pid %d/%d: '%s'\n",
+                       (unsigned long int) msg_len, nodeid, pid,
+                       (const char *)msg);
 }
 
 static void ConfchgCallback (
@@ -91,51 +81,27 @@
        const struct cpg_address *joined_list, size_t joined_list_entries)
 {
        int i;
-       struct in_addr saddr;
 
        printf("\nConfchgCallback: group '");
        print_cpgname(groupName);
        printf("'\n");
        for (i=0; i<joined_list_entries; i++) {
-               if (show_ip) {
-                       saddr.s_addr = joined_list[i].nodeid;
-                       printf("joined node/pid: %s/%d reason: %d\n",
-                              inet_ntoa (saddr), joined_list[i].pid,
-                              joined_list[i].reason);
-               }
-               else {
-                       printf("joined node/pid: %d/%d reason: %d\n",
-                              joined_list[i].nodeid, joined_list[i].pid,
-                              joined_list[i].reason);
-               }
+               printf("joined node/pid: %d/%d reason: %d\n",
+                               joined_list[i].nodeid, joined_list[i].pid,
+                               joined_list[i].reason);
        }
 
        for (i=0; i<left_list_entries; i++) {
-               if (show_ip) {
-                       saddr.s_addr = left_list[i].nodeid;
-                       printf("left node/pid: %s/%d reason: %d\n",
-                              inet_ntoa (saddr), left_list[i].pid,
-                              left_list[i].reason);
-               }
-               else {
-                       printf("left node/pid: %d/%d reason: %d\n",
-                              left_list[i].nodeid, left_list[i].pid,
-                              left_list[i].reason);
-               }
+               printf("left node/pid: %d/%d reason: %d\n",
+                               left_list[i].nodeid, left_list[i].pid,
+                               left_list[i].reason);
        }
 
        printf("nodes in group now %lu\n",
               (unsigned long int) member_list_entries);
        for (i=0; i<member_list_entries; i++) {
-               if (show_ip) {
-                       saddr.s_addr = member_list[i].nodeid;
-                       printf("node/pid: %s/%d\n",
-                              inet_ntoa (saddr), member_list[i].pid);
-               }
-               else {
-                       printf("node/pid: %d/%d\n",
-                              member_list[i].nodeid, member_list[i].pid);
-               }
+               printf("node/pid: %d/%d\n",
+                               member_list[i].nodeid, member_list[i].pid);
        }
 
        /* Is it us??
@@ -162,22 +128,13 @@
        fd_set read_fds;
        int select_fd;
        int result;
-       const char *options = "i";
-       int opt;
        unsigned int nodeid;
        char *fgets_res;
 
-       while ( (opt = getopt(argc, argv, options)) != -1 ) {
-               switch (opt) {
-               case 'i':
-                       show_ip = 1;
-                       break;
-               }
-       }
 
-       if (argc > optind) {
-               strcpy(group_name.value, argv[optind]);
-               group_name.length = strlen(argv[optind])+1;
+       if (argc > 1) {
+               strcpy(group_name.value, argv[1]);
+               group_name.length = strlen(argv[1])+1;
        }
        else {
                strcpy(group_name.value, "GROUP");
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to