Whamcloud - gitweb
b=22430 parse names with hiphen properly
authorMaxim Patlasov <Maxim.Patlasov@sun.com>
Sun, 22 Aug 2010 14:42:10 +0000 (18:42 +0400)
committerMikhail Pershin <tappro@sun.com>
Fri, 27 Aug 2010 13:53:54 +0000 (17:53 +0400)
i=liang
The names like sfire13-ib@o2ib confuse lctl ping because it assumes
"[PID-]NID[@network]" format. The patch fixes the problem by trying
"PID-NID" format first and falling back to "NID" format if the attempt
failed.

lnet/utils/portals.c
lustre/tests/sanity.sh

index c994f66..6ee2cef 100644 (file)
@@ -195,6 +195,19 @@ lnet_parse_time (time_t *t, char *str)
         return (0);
 }
 
         return (0);
 }
 
+int
+lnet_parse_nid(char *nid_str, lnet_process_id_t *id_ptr)
+{
+        id_ptr->pid = LNET_PID_ANY;
+        id_ptr->nid = libcfs_str2nid(nid_str);
+        if (id_ptr->nid == LNET_NID_ANY) {
+                fprintf (stderr, "Can't parse nid \"%s\"\n", nid_str);
+                return -1;
+        }
+
+        return 0;
+}
+
 int g_net_is_set (char *cmd)
 {
         if (g_net_set)
 int g_net_is_set (char *cmd)
 {
         if (g_net_set)
@@ -946,12 +959,9 @@ int jt_ptl_ping(int argc, char **argv)
 
         sep = strchr(argv[1], '-');
         if (sep == NULL) {
 
         sep = strchr(argv[1], '-');
         if (sep == NULL) {
-                id.pid = LNET_PID_ANY;
-                id.nid = libcfs_str2nid(argv[1]);
-                if (id.nid == LNET_NID_ANY) {
-                        fprintf (stderr, "Can't parse nid \"%s\"\n", argv[1]);
+                rc = lnet_parse_nid(argv[1], &id);
+                if (rc != 0)
                         return -1;
                         return -1;
-                }
         } else {
                 char   *end;
 
         } else {
                 char   *end;
 
@@ -961,12 +971,19 @@ int jt_ptl_ping(int argc, char **argv)
                 else
                         id.pid = strtoul(argv[1], &end, 0);
 
                 else
                         id.pid = strtoul(argv[1], &end, 0);
 
-                id.nid = libcfs_str2nid(sep + 1);
+                if (end != sep) { /* assuming '-' is part of hostname */
+                        rc = lnet_parse_nid(argv[1], &id);
+                        if (rc != 0)
+                                return -1;
+                } else {
+                        id.nid = libcfs_str2nid(sep + 1);
 
 
-                if (end != sep ||
-                    id.nid == LNET_NID_ANY) {
-                        fprintf(stderr, "Can't parse process id \"%s\"\n", argv[1]);
-                        return -1;
+                        if (id.nid == LNET_NID_ANY) {
+                                fprintf(stderr,
+                                        "Can't parse process id \"%s\"\n",
+                                        argv[1]);
+                                return -1;
+                        }
                 }
         }
 
                 }
         }
 
index 5ccee9b..9945365 100755 (executable)
@@ -7594,6 +7594,19 @@ test_216() { # bug 20317
 }
 run_test 216 "check lockless direct write works and updates file size and kms correctly"
 
 }
 run_test 216 "check lockless direct write works and updates file size and kms correctly"
 
+test_217() { # bug 22430
+       local node
+       for node in $(nodes_list); do
+               if [[ $node = *-* ]] ; then
+                       echo "lctl ping $node@$NETTYPE"
+                       lctl ping $node@$NETTYPE
+               else
+                       echo "skipping $node (no hiphen detected)"
+               fi
+       done
+}
+run_test 217 "check lctl ping for hostnames with hiphen ('-')"
+
 #
 # tests that do cleanup/setup should be run at the end
 #
 #
 # tests that do cleanup/setup should be run at the end
 #