From c72ca4f5f9f9d5412259dcac44bd13b7ad3910eb Mon Sep 17 00:00:00 2001 From: Maxim Patlasov Date: Sun, 22 Aug 2010 18:42:10 +0400 Subject: [PATCH] b=22430 parse names with hiphen properly 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 | 37 +++++++++++++++++++++++++++---------- lustre/tests/sanity.sh | 13 +++++++++++++ 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c index c994f66..6ee2cef 100644 --- a/lnet/utils/portals.c +++ b/lnet/utils/portals.c @@ -195,6 +195,19 @@ lnet_parse_time (time_t *t, char *str) 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) @@ -946,12 +959,9 @@ int jt_ptl_ping(int argc, char **argv) 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; - } } else { char *end; @@ -961,12 +971,19 @@ int jt_ptl_ping(int argc, char **argv) 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; + } } } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 5ccee9b..9945365 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -7594,6 +7594,19 @@ test_216() { # bug 20317 } 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 # -- 1.8.3.1