2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
4 * Copyright (c) 2013, 2017, Intel Corporation.
6 * This file is part of Lustre, https://wiki.whamcloud.com/
8 * Portals is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Portals is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Portals; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 #include <sys/ioctl.h>
36 #include <linux/types.h>
38 #include <libcfs/util/ioctl.h>
39 #include <linux/lnet/libcfs_debug.h>
40 #include <linux/lnet/lnet-dlc.h>
41 #include <linux/lnet/lnetctl.h>
42 #include <linux/lnet/nidstr.h>
43 #include <linux/lnet/socklnd.h>
44 #include <lnetconfig/liblnetconfig.h>
45 #include <lustre/lustreapi.h>
47 unsigned int libcfs_debug;
48 unsigned int libcfs_printk = D_CANTMASK;
50 static bool g_net_interactive;
51 static bool g_net_set;
54 #define IOC_BUF_SIZE 8192
55 static char local_buf[IOC_BUF_SIZE];
56 static char *ioc_buf = local_buf;
58 /* Convert a string boolean to an int; "enable" -> 1 */
60 lnet_parse_bool (int *b, char *str)
62 if (!strcasecmp(str, "no") ||
63 !strcasecmp(str, "n") ||
64 !strcasecmp(str, "off") ||
65 !strcasecmp(str, "down") ||
66 !strcasecmp(str, "disable")) {
72 if (!strcasecmp(str, "yes") ||
73 !strcasecmp(str, "y") ||
74 !strcasecmp(str, "on") ||
75 !strcasecmp(str, "up") ||
76 !strcasecmp(str, "enable")) {
86 lnet_parse_port(int *port, char *str)
90 *port = strtol(str, &end, 0);
92 if (*end == 0 && /* parsed whole string */
93 *port > 0 && *port < 65536) /* minimal sanity check */
99 #ifdef HAVE_GETHOSTBYNAME
100 static struct hostent *
101 ptl_gethostbyname(char *hname)
105 he = gethostbyname(hname);
110 fprintf(stderr, "Unable to resolve hostname: %s\n",
114 fprintf(stderr, "gethostbyname error for %s: %s\n",
115 hname, strerror(h_errno));
125 lnet_parse_ipquad(__u32 *ipaddrp, char *str)
129 if (sscanf(str, "%d.%d.%d.%d", &a, &b, &c, &d) == 4 &&
130 (a & ~0xff) == 0 && (b & ~0xff) == 0 &&
131 (c & ~0xff) == 0 && (d & ~0xff) == 0) {
132 *ipaddrp = (a << 24) | (b << 16) | (c << 8) | d;
141 lnet_parse_ipaddr(__u32 *ipaddrp, char *str)
143 #ifdef HAVE_GETHOSTBYNAME
147 if (!strcmp(str, "_all_")) {
152 if (lnet_parse_ipquad(ipaddrp, str) == 0)
155 #ifdef HAVE_GETHOSTBYNAME
156 if ((('a' <= str[0] && str[0] <= 'z') ||
157 ('A' <= str[0] && str[0] <= 'Z')) &&
158 (he = ptl_gethostbyname(str)) != NULL) {
159 __u32 addr = *(__u32 *)he->h_addr;
161 *ipaddrp = ntohl(addr); /* HOST byte order */
170 ptl_ipaddr_2_str(__u32 ipaddr, char *str, size_t strsize, int lookup)
172 #ifdef HAVE_GETHOSTBYNAME
177 net_ip = htonl(ipaddr);
178 he = gethostbyaddr(&net_ip, sizeof(net_ip), AF_INET);
180 snprintf(str, strsize, "%s", he->h_name);
186 sprintf(str, "%d.%d.%d.%d",
187 (ipaddr >> 24) & 0xff, (ipaddr >> 16) & 0xff,
188 (ipaddr >> 8) & 0xff, ipaddr & 0xff);
193 lnet_parse_time(time_t *t, char *str)
199 *t = strtol(str, &end, 0);
200 if (*end == 0) /* parsed whole string */
203 memset(&tm, 0, sizeof(tm));
204 n = sscanf(str, "%d-%d-%d-%d:%d:%d",
205 &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
206 &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
210 tm.tm_mon--; /* convert to 0 == Jan */
211 tm.tm_year -= 1900; /* y2k quirk */
212 tm.tm_isdst = -1; /* dunno if it's daylight savings... */
215 if (*t == (time_t)-1)
222 lnet_parse_nid(char *nid_str, struct lnet_process_id *id_ptr)
224 id_ptr->pid = LNET_PID_ANY;
225 id_ptr->nid = libcfs_str2nid(nid_str);
226 if (id_ptr->nid == LNET_NID_ANY) {
227 fprintf(stderr, "Can't parse nid \"%s\"\n", nid_str);
234 static int g_net_is_set(char *cmd)
242 if (g_net_interactive)
248 "You must run '%s <network>' command before '%s'\n",
256 static int g_net_is_compatible(char *cmd, ...)
261 if (!g_net_is_set(cmd))
267 nal = va_arg(ap, int);
268 if (nal == LNET_NETTYP(g_net)) {
277 fprintf(stderr, "Command %s not compatible with %s NAL\n",
278 cmd, libcfs_lnd2str(LNET_NETTYP(g_net)));
283 int ptl_initialize(int argc, char **argv)
286 g_net_interactive = true;
288 register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH);
293 int jt_ptl_network(int argc, char **argv)
295 struct libcfs_ioctl_data data;
296 __u32 net = LNET_NET_ANY;
300 fprintf(stderr, "usage: %s <net>|up|down\n", argv[0]);
304 if (!strcmp(argv[1], "unconfigure") || !strcmp(argv[1], "down")) {
305 LIBCFS_IOC_INIT(data);
306 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_UNCONFIGURE, &data);
309 printf("LNET ready to unload\n");
313 if (errno == ENODEV) {
314 printf("LNET is currently not loaded.");
319 fprintf(stderr, "LNET busy\n");
321 fprintf(stderr, "LNET unconfigure error %d: %s\n",
322 errno, strerror(errno));
324 } else if (!strcmp(argv[1], "configure") || !strcmp(argv[1], "up")) {
325 LIBCFS_IOC_INIT(data);
326 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_CONFIGURE, &data);
329 printf("LNET configured\n");
333 fprintf(stderr, "LNET configure error %d: %s\n",
334 errno, strerror(errno));
338 net = libcfs_str2net(argv[1]);
339 if (net == LNET_NET_ANY) {
340 fprintf(stderr, "Can't parse net %s\n", argv[1]);
349 #define IOC_LIBCFS_GET_NI _IOWR('e', 50, IOCTL_LIBCFS_TYPE)
352 jt_ptl_list_nids(int argc, char **argv)
354 struct libcfs_ioctl_data data;
355 int all = 0, return_nid = 0;
356 yaml_emitter_t request;
364 all = (argc == 2) && (strcmp(argv[1], "all") == 0);
365 /* Hack to pass back value */
366 return_nid = (argc == 2) && (argv[1][0] == 1);
368 if ((argc > 2) && !(all || return_nid)) {
369 fprintf(stderr, "usage: %s [all]\n", argv[0]);
373 sk = nl_socket_alloc();
377 /* Setup parser to receive Netlink packets */
378 rc = yaml_parser_initialize(&reply);
380 yaml_parser_log_error(&reply, stderr, NULL);
384 rc = yaml_parser_set_input_netlink(&reply, sk, false);
386 yaml_parser_log_error(&reply, stderr, NULL);
387 yaml_parser_delete(&reply);
391 /* Create Netlink emitter to send request to kernel */
392 rc = yaml_emitter_initialize(&request);
394 yaml_parser_log_error(&reply, stderr, NULL);
395 yaml_parser_delete(&reply);
399 rc = yaml_emitter_set_output_netlink(&request, sk, LNET_GENL_NAME, 1,
400 LNET_CMD_NETS, NLM_F_DUMP);
402 yaml_emitter_log_error(&request, stderr);
403 yaml_emitter_delete(&request);
404 yaml_parser_delete(&reply);
408 yaml_emitter_open(&request);
409 yaml_document_start_event_initialize(&event, NULL, NULL, NULL, 0);
410 rc = yaml_emitter_emit(&request, &event);
414 yaml_mapping_start_event_initialize(&event, NULL,
415 (yaml_char_t *)YAML_MAP_TAG,
416 1, YAML_ANY_MAPPING_STYLE);
417 rc = yaml_emitter_emit(&request, &event);
421 yaml_scalar_event_initialize(&event, NULL,
422 (yaml_char_t *)YAML_STR_TAG,
423 (yaml_char_t *)"net",
425 YAML_PLAIN_SCALAR_STYLE);
426 rc = yaml_emitter_emit(&request, &event);
431 if (!g_net_set || g_net == LNET_NET_ANY) {
432 yaml_scalar_event_initialize(&event, NULL,
433 (yaml_char_t *)YAML_STR_TAG,
436 YAML_PLAIN_SCALAR_STYLE);
437 rc = yaml_emitter_emit(&request, &event);
441 char *net_id = libcfs_net2str(g_net);
443 yaml_sequence_start_event_initialize(&event, NULL,
444 (yaml_char_t *)YAML_SEQ_TAG,
445 1, YAML_ANY_SEQUENCE_STYLE);
446 rc = yaml_emitter_emit(&request, &event);
450 yaml_mapping_start_event_initialize(&event, NULL,
451 (yaml_char_t *)YAML_MAP_TAG,
452 1, YAML_ANY_MAPPING_STYLE);
453 rc = yaml_emitter_emit(&request, &event);
457 yaml_scalar_event_initialize(&event, NULL,
458 (yaml_char_t *)YAML_STR_TAG,
459 (yaml_char_t *)"net type",
461 1, 0, YAML_PLAIN_SCALAR_STYLE);
462 rc = yaml_emitter_emit(&request, &event);
466 yaml_scalar_event_initialize(&event, NULL,
467 (yaml_char_t *)YAML_STR_TAG,
468 (yaml_char_t *)net_id,
469 strlen(net_id), 1, 0,
470 YAML_PLAIN_SCALAR_STYLE);
471 rc = yaml_emitter_emit(&request, &event);
475 yaml_mapping_end_event_initialize(&event);
476 rc = yaml_emitter_emit(&request, &event);
480 yaml_sequence_end_event_initialize(&event);
481 rc = yaml_emitter_emit(&request, &event);
485 yaml_mapping_end_event_initialize(&event);
486 rc = yaml_emitter_emit(&request, &event);
490 yaml_document_end_event_initialize(&event, 0);
491 rc = yaml_emitter_emit(&request, &event);
495 rc = yaml_emitter_close(&request);
498 yaml_emitter_log_error(&request, stderr);
501 yaml_emitter_delete(&request);
504 rc = yaml_parser_parse(&reply, &event);
508 if (event.type == YAML_SCALAR_EVENT &&
509 strcmp((char *)event.data.scalar.value, "nid") == 0) {
512 yaml_event_delete(&event);
513 rc = yaml_parser_parse(&reply, &event);
515 yaml_event_delete(&event);
519 tmp = (char *)event.data.scalar.value;
520 if (all || strcmp(tmp, "0@lo") != 0) {
523 *(__u64 *)(argv[1]) = libcfs_str2nid(tmp);
528 done = (event.type == YAML_STREAM_END_EVENT);
529 yaml_event_delete(&event);
533 yaml_parser_log_error(&reply, stderr, NULL);
534 yaml_parser_delete(&reply);
541 for (count = 0;; count++) {
542 LIBCFS_IOC_INIT(data);
543 data.ioc_count = count;
544 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_NI, &data);
547 if ((count > 0) && (errno == ENOENT))
548 /* We found them all */
550 fprintf(stderr, "IOC_LIBCFS_GET_NI error %d: %s\n",
551 errno, strerror(errno));
555 if (all || (data.ioc_nid != LNET_NID_LO_0)) {
556 printf("%s\n", libcfs_nid2str(data.ioc_nid));
558 *(__u64 *)(argv[1]) = data.ioc_nid;
568 jt_ptl_which_nid(int argc, char **argv)
570 struct libcfs_ioctl_data data;
573 lnet_nid_t best_nid = LNET_NID_ANY;
582 fprintf(stderr, "usage: %s NID [NID...]\n", argv[0]);
586 for (i = 1; i < argc; i++) {
588 nid = libcfs_str2nid(nidstr);
589 if (nid == LNET_NID_ANY) {
590 fprintf(stderr, "Can't parse NID %s\n", nidstr);
594 LIBCFS_IOC_INIT(data);
597 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_LNET_DIST, &data);
599 fprintf(stderr, "Can't get distance to %s: %s\n",
600 nidstr, strerror(errno));
604 dist = data.ioc_u32[0];
605 order = data.ioc_u32[1];
608 if (dist == -EHOSTUNREACH)
611 fprintf(stderr, "Unexpected distance to %s: %d\n",
616 if (best_nid == LNET_NID_ANY ||
618 (dist == best_dist && order < best_order)) {
625 if (best_nid == LNET_NID_ANY) {
626 fprintf(stderr, "No reachable NID\n");
630 printf("%s\n", libcfs_nid2str(best_nid));
635 jt_ptl_print_interfaces(int argc, char **argv)
637 struct libcfs_ioctl_data data;
638 char buffer[3][HOST_NAME_MAX + 1];
642 if (!g_net_is_compatible(argv[0], SOCKLND, 0))
645 for (index = 0; ; index++) {
646 LIBCFS_IOC_INIT(data);
647 data.ioc_net = g_net;
648 data.ioc_count = index;
650 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_INTERFACE, &data);
654 printf("%s: (%s/%s) npeer %d nroute %d\n",
655 ptl_ipaddr_2_str(data.ioc_u32[0], buffer[2],
656 sizeof(buffer[2]), 1),
657 ptl_ipaddr_2_str(data.ioc_u32[0], buffer[0],
658 sizeof(buffer[0]), 0),
659 ptl_ipaddr_2_str(data.ioc_u32[1], buffer[1],
660 sizeof(buffer[1]), 0),
661 data.ioc_u32[2], data.ioc_u32[3]);
665 if (errno == ENOENT) {
666 printf("<no interfaces>\n");
669 "Error getting interfaces: %s: check dmesg.\n",
678 jt_ptl_add_interface(int argc, char **argv)
680 struct libcfs_ioctl_data data;
683 __u32 netmask = 0xffffff00;
688 if (argc < 2 || argc > 3) {
689 fprintf(stderr, "usage: %s ipaddr [netmask]\n", argv[0]);
693 if (!g_net_is_compatible(argv[0], SOCKLND, 0))
696 if (lnet_parse_ipaddr(&ipaddr, argv[1]) != 0) {
697 fprintf(stderr, "Can't parse ip: %s\n", argv[1]);
702 count = strtol(argv[2], &end, 0);
703 if (count > 0 && count < 32 && *end == 0) {
705 for (i = count; i > 0; i--)
706 netmask = netmask | (1 << (32 - i));
707 } else if (lnet_parse_ipquad(&netmask, argv[2]) != 0) {
708 fprintf(stderr, "Can't parse netmask: %s\n", argv[2]);
713 LIBCFS_IOC_INIT(data);
714 data.ioc_net = g_net;
715 data.ioc_u32[0] = ipaddr;
716 data.ioc_u32[1] = netmask;
718 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_ADD_INTERFACE, &data);
720 fprintf(stderr, "failed to add interface: %s\n",
729 jt_ptl_del_interface(int argc, char **argv)
731 struct libcfs_ioctl_data data;
736 fprintf(stderr, "usage: %s [ipaddr]\n", argv[0]);
740 if (!g_net_is_compatible(argv[0], SOCKLND, 0))
744 lnet_parse_ipaddr(&ipaddr, argv[1]) != 0) {
745 fprintf(stderr, "Can't parse ip: %s\n", argv[1]);
749 LIBCFS_IOC_INIT(data);
750 data.ioc_net = g_net;
751 data.ioc_u32[0] = ipaddr;
753 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_DEL_INTERFACE, &data);
755 fprintf(stderr, "failed to delete interface: %s\n",
764 jt_ptl_print_peers(int argc, char **argv)
766 struct libcfs_ioctl_data data;
767 struct lnet_process_id id;
768 char buffer[2][HOST_NAME_MAX + 1];
772 if (!g_net_is_compatible(argv[0], SOCKLND, O2IBLND, GNILND,
776 for (index = 0; ; index++) {
777 LIBCFS_IOC_INIT(data);
778 data.ioc_net = g_net;
779 data.ioc_count = index;
781 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_PEER, &data);
785 if (g_net_is_compatible(NULL, SOCKLND, 0)) {
786 id.nid = data.ioc_nid;
787 id.pid = data.ioc_u32[4];
788 printf("%-20s [%d]%s->%s:%d #%d\n",
790 data.ioc_count, /* persistence */
792 ptl_ipaddr_2_str(data.ioc_u32[2], buffer[0],
793 sizeof(buffer[0]), 1),
795 ptl_ipaddr_2_str(data.ioc_u32[0], buffer[1],
796 sizeof(buffer[1]), 1),
797 data.ioc_u32[1], /* peer port */
798 data.ioc_u32[3]); /* conn_count */
799 } else if (g_net_is_compatible(NULL, GNILND, 0)) {
800 int disconn = data.ioc_flags >> 16;
806 state = data.ioc_flags & 0xffff ? "C" : "U";
808 printf("%-20s (%d) %s [%d] %ju sq %d/%d tx %d/%d/%d\n",
809 libcfs_nid2str(data.ioc_nid), /* peer nid */
810 data.ioc_net, /* gemini device id */
811 state, /* peer is Connecting, Up, or Down */
812 data.ioc_count, /* peer refcount */
813 (uintmax_t)data.ioc_u64[0], /* peerstamp */
814 data.ioc_u32[2], data.ioc_u32[3], /* tx and rx seq */
815 /* fmaq, nfma, nrdma */
816 data.ioc_u32[0], data.ioc_u32[1],
819 printf("%-20s [%d]\n",
820 libcfs_nid2str(data.ioc_nid), data.ioc_count);
825 if (errno == ENOENT) {
826 printf("<no peers>\n");
829 "Error getting peer list: %s: check dmesg.\n",
836 int jt_ptl_add_peer(int argc, char **argv)
838 struct libcfs_ioctl_data data;
844 if (!g_net_is_compatible(argv[0], SOCKLND, GNILND, 0))
848 fprintf(stderr, "usage(tcp,gni): %s nid ipaddr port\n",
853 nid = libcfs_str2nid(argv[1]);
854 if (nid == LNET_NID_ANY) {
855 fprintf(stderr, "Can't parse NID: %s\n", argv[1]);
859 if (lnet_parse_ipaddr(&ip, argv[2]) != 0) {
860 fprintf(stderr, "Can't parse ip addr: %s\n", argv[2]);
864 if (lnet_parse_port(&port, argv[3]) != 0) {
865 fprintf(stderr, "Can't parse port: %s\n", argv[3]);
869 LIBCFS_IOC_INIT(data);
870 data.ioc_net = g_net;
872 data.ioc_u32[0] = ip;
873 data.ioc_u32[1] = port;
875 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_ADD_PEER, &data);
877 fprintf(stderr, "failed to add peer: %s\n",
886 jt_ptl_del_peer(int argc, char **argv)
888 struct libcfs_ioctl_data data;
889 lnet_nid_t nid = LNET_NID_ANY;
890 lnet_pid_t pid = LNET_PID_ANY;
894 if (!g_net_is_compatible(argv[0], SOCKLND, O2IBLND, GNILND,
898 if (g_net_is_compatible(NULL, SOCKLND, 0)) {
900 fprintf(stderr, "usage: %s [nid] [ipaddr]\n", argv[0]);
903 } else if (argc > 2) {
904 fprintf(stderr, "usage: %s [nid]\n", argv[0]);
908 if (argc > 1 && !libcfs_str2anynid(&nid, argv[1])) {
909 fprintf(stderr, "Can't parse nid: %s\n", argv[1]);
913 if (g_net_is_compatible(NULL, SOCKLND, 0)) {
914 if (argc > 2 && lnet_parse_ipaddr(&ip, argv[2]) != 0) {
915 fprintf(stderr, "Can't parse ip addr: %s\n", argv[2]);
920 LIBCFS_IOC_INIT(data);
921 data.ioc_net = g_net;
923 data.ioc_u32[0] = ip;
924 data.ioc_u32[1] = pid;
926 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_DEL_PEER, &data);
928 fprintf(stderr, "failed to remove peer: %s\n", strerror(errno));
936 jt_ptl_print_connections(int argc, char **argv)
938 struct libcfs_ioctl_data data;
939 struct lnet_process_id id;
940 char buffer[2][HOST_NAME_MAX + 1];
944 if (!g_net_is_compatible(argv[0], SOCKLND, O2IBLND, GNILND, 0))
947 for (index = 0; ; index++) {
948 LIBCFS_IOC_INIT(data);
949 data.ioc_net = g_net;
950 data.ioc_count = index;
952 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_CONN, &data);
956 if (g_net_is_compatible(NULL, SOCKLND, 0)) {
957 id.nid = data.ioc_nid;
958 id.pid = data.ioc_u32[6];
959 printf("%-20s %s[%d]%s->%s:%d %d/%d %s\n",
961 (data.ioc_u32[3] == SOCKLND_CONN_ANY) ? "A" :
962 (data.ioc_u32[3] == SOCKLND_CONN_CONTROL) ? "C" :
963 (data.ioc_u32[3] == SOCKLND_CONN_BULK_IN) ? "I" :
964 (data.ioc_u32[3] == SOCKLND_CONN_BULK_OUT) ? "O" : "?",
965 data.ioc_u32[4], /* scheduler */
967 ptl_ipaddr_2_str(data.ioc_u32[2], buffer[0],
968 sizeof(buffer[0]), 1),
970 ptl_ipaddr_2_str(data.ioc_u32[0], buffer[1],
971 sizeof(buffer[1]), 1),
972 data.ioc_u32[1], /* remote port */
973 data.ioc_count, /* tx buffer size */
974 data.ioc_u32[5], /* rx buffer size */
975 data.ioc_flags ? "nagle" : "nonagle");
976 } else if (g_net_is_compatible(NULL, O2IBLND, 0)) {
977 printf("%s mtu %d\n",
978 libcfs_nid2str(data.ioc_nid),
979 data.ioc_u32[0]); /* path MTU */
980 } else if (g_net_is_compatible(NULL, GNILND, 0)) {
981 printf("%-20s [%d]\n",
982 libcfs_nid2str(data.ioc_nid),
983 data.ioc_u32[0] /* device id */);
985 printf("%s\n", libcfs_nid2str(data.ioc_nid));
990 if (errno == ENOENT) {
991 printf("<no connections>\n");
994 "Error getting connection list: %s: check dmesg.\n",
1001 int jt_ptl_disconnect(int argc, char **argv)
1003 struct libcfs_ioctl_data data;
1004 lnet_nid_t nid = LNET_NID_ANY;
1009 fprintf(stderr, "usage: %s [nid] [ipaddr]\n", argv[0]);
1013 if (!g_net_is_compatible(NULL, SOCKLND, O2IBLND, GNILND, 0))
1016 if (argc >= 2 && !libcfs_str2anynid(&nid, argv[1])) {
1017 fprintf(stderr, "Can't parse nid %s\n", argv[1]);
1021 if (g_net_is_compatible(NULL, SOCKLND, 0) && argc >= 3 &&
1022 lnet_parse_ipaddr(&ipaddr, argv[2]) != 0) {
1023 fprintf(stderr, "Can't parse ip addr %s\n", argv[2]);
1027 LIBCFS_IOC_INIT(data);
1028 data.ioc_net = g_net;
1030 data.ioc_u32[0] = ipaddr;
1032 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_CLOSE_CONNECTION, &data);
1034 fprintf(stderr, "failed to remove connection: %s\n",
1042 int jt_ptl_push_connection(int argc, char **argv)
1044 struct libcfs_ioctl_data data;
1046 lnet_nid_t nid = LNET_NID_ANY;
1049 fprintf(stderr, "usage: %s [nid]\n", argv[0]);
1053 if (!g_net_is_compatible(argv[0], SOCKLND, GNILND, 0))
1056 if (argc > 1 && !libcfs_str2anynid(&nid, argv[1])) {
1057 fprintf(stderr, "Can't parse nid: %s\n", argv[1]);
1061 LIBCFS_IOC_INIT(data);
1062 data.ioc_net = g_net;
1065 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_PUSH_CONNECTION, &data);
1067 fprintf(stderr, "failed to push connection: %s\n",
1075 int jt_ptl_ping(int argc, char **argv)
1079 struct lnet_process_id id;
1080 struct lnet_process_id ids[16];
1081 int maxids = sizeof(ids) / sizeof(ids[0]);
1082 struct libcfs_ioctl_data data;
1087 fprintf(stderr, "usage: %s id [timeout (secs)]\n", argv[0]);
1091 sep = strchr(argv[1], '-');
1093 rc = lnet_parse_nid(argv[1], &id);
1099 if (argv[1][0] == 'u' || argv[1][0] == 'U')
1100 id.pid = strtoul(&argv[1][1], &end, 0) |
1103 id.pid = strtoul(argv[1], &end, 0);
1105 if (end != sep) { /* assuming '-' is part of hostname */
1106 rc = lnet_parse_nid(argv[1], &id);
1110 id.nid = libcfs_str2nid(sep + 1);
1112 if (id.nid == LNET_NID_ANY) {
1114 "Can't parse process id \"%s\"\n",
1122 timeout = 1000 * atol(argv[2]);
1123 if (timeout > 120 * 1000) {
1124 fprintf(stderr, "Timeout %s is to large\n",
1129 timeout = 1000; /* default 1 second timeout */
1132 LIBCFS_IOC_INIT(data);
1133 data.ioc_nid = id.nid;
1134 data.ioc_u32[0] = id.pid;
1135 data.ioc_u32[1] = timeout;
1136 data.ioc_plen1 = sizeof(ids);
1137 data.ioc_pbuf1 = (char *)ids;
1139 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_PING, &data);
1141 fprintf(stderr, "failed to ping %s: %s\n",
1142 id.pid == LNET_PID_ANY ?
1143 libcfs_nid2str(id.nid) : libcfs_id2str(id),
1148 for (i = 0; i < data.ioc_count && i < maxids; i++)
1149 printf("%s\n", libcfs_id2str(ids[i]));
1151 if (data.ioc_count > maxids)
1152 printf("%d out of %d ids listed\n", maxids, data.ioc_count);
1157 int jt_ptl_mynid(int argc, char **argv)
1159 struct libcfs_ioctl_data data;
1164 fprintf(stderr, "usage: %s NID\n", argv[0]);
1168 nid = libcfs_str2nid(argv[1]);
1169 if (nid == LNET_NID_ANY) {
1170 fprintf(stderr, "Can't parse NID '%s'\n", argv[1]);
1174 LIBCFS_IOC_INIT(data);
1175 data.ioc_net = LNET_NIDNET(nid);
1178 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_REGISTER_MYNID, &data);
1180 fprintf(stderr, "setting my NID failed: %s\n",
1183 printf("registered my nid %s\n", libcfs_nid2str(nid));
1189 jt_ptl_fail_nid(int argc, char **argv)
1194 struct libcfs_ioctl_data data;
1196 if (argc < 2 || argc > 3) {
1197 fprintf(stderr, "usage: %s nid|\"*\" [count (0 == mend)]\n",
1202 if (!libcfs_str2anynid(&nid, argv[1])) {
1203 fprintf(stderr, "Can't parse nid \"%s\"\n", argv[1]);
1208 threshold = LNET_MD_THRESH_INF;
1209 } else if (sscanf(argv[2], "%i", &threshold) != 1) {
1210 fprintf(stderr, "Can't parse count \"%s\"\n", argv[2]);
1214 LIBCFS_IOC_INIT(data);
1216 data.ioc_count = threshold;
1218 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_FAIL_NID, &data);
1220 fprintf(stderr, "IOC_LIBCFS_FAIL_NID failed: %s\n",
1224 threshold == 0 ? "Unfailing" : "Failing", argv[1]);
1230 jt_ptl_add_route(int argc, char **argv)
1232 struct lnet_ioctl_config_data data;
1233 lnet_nid_t gateway_nid;
1234 __u32 hops = LNET_UNDEFINED_HOPS;
1235 unsigned int priority = 0;
1239 if (argc < 2 || argc > 4) {
1240 fprintf(stderr, "usage: %s gateway [hopcount [priority]]\n",
1245 if (g_net_is_set(argv[0]) == 0)
1248 gateway_nid = libcfs_str2nid(argv[1]);
1249 if (gateway_nid == LNET_NID_ANY) {
1250 fprintf(stderr, "Can't parse gateway NID \"%s\"\n", argv[1]);
1255 hops = strtol(argv[2], &end, 0);
1256 if (hops == 0 || hops >= 256 ||
1257 (end && *end != 0)) {
1258 fprintf(stderr, "Can't parse hopcount \"%s\"\n",
1263 priority = strtoul(argv[3], &end, 0);
1264 if (end && *end != 0) {
1266 "Can't parse priority \"%s\"\n",
1273 LIBCFS_IOC_INIT_V2(data, cfg_hdr);
1274 data.cfg_net = g_net;
1275 data.cfg_config_u.cfg_route.rtr_hop = hops;
1276 data.cfg_nid = gateway_nid;
1277 data.cfg_config_u.cfg_route.rtr_priority = priority;
1279 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_ADD_ROUTE, &data);
1281 fprintf(stderr, "IOC_LIBCFS_ADD_ROUTE failed: %s\n",
1290 jt_ptl_del_route(int argc, char **argv)
1292 struct lnet_ioctl_config_data data;
1297 fprintf(stderr, "usage: %s gatewayNID\n", argv[0]);
1301 if (libcfs_str2anynid(&nid, argv[1]) == 0) {
1302 fprintf(stderr, "Can't parse gateway NID \"%s\"\n", argv[1]);
1306 LIBCFS_IOC_INIT_V2(data, cfg_hdr);
1307 data.cfg_net = g_net_set ? g_net : LNET_NET_ANY;
1310 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_DEL_ROUTE, &data);
1312 fprintf(stderr, "IOC_LIBCFS_DEL_ROUTE (%s) failed: %s\n",
1313 libcfs_nid2str(nid), strerror(errno));
1321 jt_ptl_notify_router(int argc, char **argv)
1323 struct libcfs_ioctl_data data;
1331 fprintf(stderr, "usage: %s targetNID <up/down> [<time>]\n",
1336 nid = libcfs_str2nid(argv[1]);
1337 if (nid == LNET_NID_ANY) {
1338 fprintf(stderr, "Can't parse target NID \"%s\"\n", argv[1]);
1342 if (lnet_parse_bool (&enable, argv[2]) != 0) {
1343 fprintf(stderr, "Can't parse boolean %s\n", argv[2]);
1347 gettimeofday(&now, NULL);
1351 } else if (lnet_parse_time(&when, argv[3]) != 0) {
1353 "Can't parse time %s\n Please specify either 'YYYY-MM-DD-HH:MM:SS'\n or an absolute unix time in seconds\n",
1356 } else if (when > now.tv_sec) {
1357 fprintf(stderr, "%s specifies a time in the future\n",
1362 LIBCFS_IOC_INIT(data);
1364 data.ioc_flags = enable;
1365 /* Yeuch; 'cept I need a __u64 on 64 bit machines... */
1366 data.ioc_u64[0] = (__u64)when;
1368 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_NOTIFY_ROUTER, &data);
1370 fprintf(stderr, "IOC_LIBCFS_NOTIFY_ROUTER (%s) failed: %s\n",
1371 libcfs_nid2str(nid), strerror(errno));
1379 jt_ptl_print_routes(int argc, char **argv)
1381 struct lnet_ioctl_config_data data;
1390 for (index = 0; ; index++) {
1391 LIBCFS_IOC_INIT_V2(data, cfg_hdr);
1392 data.cfg_count = index;
1394 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_ROUTE, &data);
1399 hops = data.cfg_config_u.cfg_route.rtr_hop;
1401 alive = data.cfg_config_u.cfg_route.rtr_flags & LNET_RT_ALIVE;
1402 pri = data.cfg_config_u.cfg_route.rtr_priority;
1404 printf("net %18s hops %u gw %32s %s pri %u\n",
1405 libcfs_net2str(net), hops,
1406 libcfs_nid2str(nid), alive ? "up" : "down", pri);
1409 if (errno != ENOENT)
1410 fprintf(stderr, "Error getting routes: %s: check dmesg.\n",
1417 fault_attr_nid_parse(char *str, lnet_nid_t *nid_p)
1423 /* NB: can't support range ipaddress except * and *@net */
1424 if (strlen(str) > 2 && str[0] == '*' && str[1] == '@') {
1425 net = libcfs_str2net(str + 2);
1426 if (net == LNET_NET_ANY)
1429 nid = LNET_MKNID(net, LNET_NIDADDR(LNET_NID_ANY));
1431 rc = libcfs_str2anynid(&nid, str);
1439 fprintf(stderr, "Invalid NID : %s\n", str);
1444 fault_attr_msg_parse(char *msg_str, __u32 *mask_p)
1446 if (!strcasecmp(msg_str, "put")) {
1447 *mask_p |= LNET_PUT_BIT;
1450 } else if (!strcasecmp(msg_str, "ack")) {
1451 *mask_p |= LNET_ACK_BIT;
1454 } else if (!strcasecmp(msg_str, "get")) {
1455 *mask_p |= LNET_GET_BIT;
1458 } else if (!strcasecmp(msg_str, "reply")) {
1459 *mask_p |= LNET_REPLY_BIT;
1463 fprintf(stderr, "unknown message type %s\n", msg_str);
1468 fault_attr_ptl_parse(char *ptl_str, __u64 *mask_p)
1470 unsigned long rc = strtoul(optarg, NULL, 0);
1473 fprintf(stderr, "invalid portal: %lu\n", rc);
1477 *mask_p |= (1ULL << rc);
1482 fault_attr_health_error_parse(char *error, __u32 *mask)
1484 if (!strcasecmp(error, "local_interrupt")) {
1485 *mask |= HSTATUS_LOCAL_INTERRUPT_BIT;
1488 if (!strcasecmp(error, "local_dropped")) {
1489 *mask |= HSTATUS_LOCAL_DROPPED_BIT;
1492 if (!strcasecmp(error, "local_aborted")) {
1493 *mask |= HSTATUS_LOCAL_ABORTED_BIT;
1496 if (!strcasecmp(error, "local_no_route")) {
1497 *mask |= HSTATUS_LOCAL_NO_ROUTE_BIT;
1500 if (!strcasecmp(error, "local_error")) {
1501 *mask |= HSTATUS_LOCAL_ERROR_BIT;
1504 if (!strcasecmp(error, "local_timeout")) {
1505 *mask |= HSTATUS_LOCAL_TIMEOUT_BIT;
1508 if (!strcasecmp(error, "remote_error")) {
1509 *mask |= HSTATUS_REMOTE_ERROR_BIT;
1512 if (!strcasecmp(error, "remote_dropped")) {
1513 *mask |= HSTATUS_REMOTE_DROPPED_BIT;
1516 if (!strcasecmp(error, "remote_timeout")) {
1517 *mask |= HSTATUS_REMOTE_TIMEOUT_BIT;
1520 if (!strcasecmp(error, "network_timeout")) {
1521 *mask |= HSTATUS_NETWORK_TIMEOUT_BIT;
1524 if (!strcasecmp(error, "random")) {
1525 *mask = HSTATUS_RANDOM;
1533 fault_simul_rule_add(__u32 opc, char *name, int argc, char **argv)
1535 struct libcfs_ioctl_data data = { { 0 } };
1536 struct lnet_fault_attr attr;
1540 static const struct option opts[] = {
1541 { .name = "source", .has_arg = required_argument, .val = 's' },
1542 { .name = "dest", .has_arg = required_argument, .val = 'd' },
1543 { .name = "rate", .has_arg = required_argument, .val = 'r' },
1544 { .name = "interval", .has_arg = required_argument, .val = 'i' },
1545 { .name = "random", .has_arg = no_argument, .val = 'n' },
1546 { .name = "latency", .has_arg = required_argument, .val = 'l' },
1547 { .name = "portal", .has_arg = required_argument, .val = 'p' },
1548 { .name = "message", .has_arg = required_argument, .val = 'm' },
1549 { .name = "health_error", .has_arg = required_argument, .val = 'e' },
1550 { .name = "local_nid", .has_arg = required_argument, .val = 'o' },
1551 { .name = "drop_all", .has_arg = no_argument, .val = 'x' },
1556 "Failed, please provide source, destination and rate of rule\n");
1560 optstr = opc == LNET_CTL_DROP_ADD ? "s:d:o:r:i:p:m:e:nx" : "s:d:o:r:l:p:m:";
1561 memset(&attr, 0, sizeof(attr));
1563 int c = getopt_long(argc, argv, optstr, opts, NULL);
1570 rc = fault_attr_nid_parse(optarg, &attr.fa_local_nid);
1574 case 's': /* source NID/NET */
1575 rc = fault_attr_nid_parse(optarg, &attr.fa_src);
1580 case 'd': /* dest NID/NET */
1581 rc = fault_attr_nid_parse(optarg, &attr.fa_dst);
1586 case 'r': /* drop rate */
1587 if (opc == LNET_CTL_DROP_ADD)
1588 attr.u.drop.da_rate = strtoul(optarg, NULL, 0);
1590 attr.u.delay.la_rate = strtoul(optarg, NULL, 0);
1594 if (opc == LNET_CTL_DROP_ADD) {
1595 rc = fault_attr_health_error_parse(optarg,
1596 &attr.u.drop.da_health_error_mask);
1603 if (opc == LNET_CTL_DROP_ADD)
1604 attr.u.drop.da_drop_all = true;
1608 if (opc == LNET_CTL_DROP_ADD)
1609 attr.u.drop.da_random = true;
1612 case 'i': /* time interval (# seconds) for message drop */
1613 if (opc == LNET_CTL_DROP_ADD)
1614 attr.u.drop.da_interval = strtoul(optarg,
1617 attr.u.delay.la_interval = strtoul(optarg,
1621 case 'l': /* seconds to wait before activating rule */
1622 attr.u.delay.la_latency = strtoul(optarg, NULL, 0);
1625 case 'p': /* portal to filter */
1626 rc = fault_attr_ptl_parse(optarg, &attr.fa_ptl_mask);
1631 case 'm': /* message types to filter */
1632 rc = fault_attr_msg_parse(optarg, &attr.fa_msg_mask);
1638 fprintf(stderr, "error: %s: option '%s' unrecognized\n",
1639 argv[0], argv[optind - 1]);
1645 if (opc == LNET_CTL_DROP_ADD) {
1646 /* NB: drop rate and interval are exclusive to each other */
1647 if (!((attr.u.drop.da_rate == 0) ^
1648 (attr.u.drop.da_interval == 0))) {
1650 "please provide either drop rate or interval but not both at the same time.\n");
1654 if (attr.u.drop.da_random &&
1655 attr.u.drop.da_interval == 0) {
1657 "please provide an interval to randomize\n");
1660 } else if (opc == LNET_CTL_DELAY_ADD) {
1661 if (!((attr.u.delay.la_rate == 0) ^
1662 (attr.u.delay.la_interval == 0))) {
1664 "please provide either delay rate or interval but not both at the same time.\n");
1668 if (attr.u.delay.la_latency == 0) {
1669 fprintf(stderr, "latency cannot be zero\n");
1674 if (attr.fa_src == 0 || attr.fa_dst == 0) {
1676 "Please provide both source and destination of %s rule\n",
1681 if (attr.fa_local_nid == 0)
1682 attr.fa_local_nid = LNET_NID_ANY;
1684 data.ioc_flags = opc;
1685 data.ioc_inllen1 = sizeof(attr);
1686 data.ioc_inlbuf1 = (char *)&attr;
1687 if (libcfs_ioctl_pack(&data, &ioc_buf, IOC_BUF_SIZE) != 0) {
1688 fprintf(stderr, "libcfs_ioctl_pack failed\n");
1692 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_LNET_FAULT, ioc_buf);
1694 fprintf(stderr, "add %s rule %s->%s failed: %s\n",
1695 name, libcfs_nid2str(attr.fa_src),
1696 libcfs_nid2str(attr.fa_dst), strerror(errno));
1700 printf("Added %s rule %s->%s (1/%d)\n",
1701 name, libcfs_nid2str(attr.fa_src), libcfs_nid2str(attr.fa_dst),
1702 opc == LNET_CTL_DROP_ADD ?
1703 attr.u.drop.da_rate : attr.u.delay.la_rate);
1712 jt_ptl_drop_add(int argc, char **argv)
1714 return fault_simul_rule_add(LNET_CTL_DROP_ADD, "drop", argc, argv);
1718 jt_ptl_delay_add(int argc, char **argv)
1720 return fault_simul_rule_add(LNET_CTL_DELAY_ADD, "delay", argc, argv);
1724 fault_simul_rule_del(__u32 opc, char *name, int argc, char **argv)
1726 struct libcfs_ioctl_data data = { { 0 } };
1727 struct lnet_fault_attr attr;
1731 static const struct option opts[] = {
1732 { .name = "source", .has_arg = required_argument, .val = 's' },
1733 { .name = "dest", .has_arg = required_argument, .val = 'd' },
1734 { .name = "all", .has_arg = no_argument, .val = 'a' },
1739 "Failed, please provide source and destination of rule\n");
1743 memset(&attr, 0, sizeof(attr));
1745 int c = getopt_long(argc, argv, "s:d:a", opts, NULL);
1752 rc = fault_attr_nid_parse(optarg, &attr.fa_src);
1757 rc = fault_attr_nid_parse(optarg, &attr.fa_dst);
1768 fprintf(stderr, "error: %s: option '%s' unrecognized\n",
1769 argv[0], argv[optind - 1]);
1775 data.ioc_flags = opc;
1776 data.ioc_inllen1 = sizeof(attr);
1777 data.ioc_inlbuf1 = (char *)&attr;
1778 if (libcfs_ioctl_pack(&data, &ioc_buf, IOC_BUF_SIZE) != 0) {
1779 fprintf(stderr, "libcfs_ioctl_pack failed\n");
1783 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_LNET_FAULT, ioc_buf);
1785 fprintf(stderr, "remove %s rule %s->%s failed: %s\n", name,
1786 all ? "all" : libcfs_nid2str(attr.fa_src),
1787 all ? "all" : libcfs_nid2str(attr.fa_dst),
1792 libcfs_ioctl_unpack(&data, ioc_buf);
1793 printf("Removed %d %s rules\n", data.ioc_count, name);
1802 jt_ptl_drop_del(int argc, char **argv)
1804 return fault_simul_rule_del(LNET_CTL_DROP_DEL, "drop", argc, argv);
1808 jt_ptl_delay_del(int argc, char **argv)
1810 return fault_simul_rule_del(LNET_CTL_DELAY_DEL, "delay", argc, argv);
1814 fault_simul_rule_reset(__u32 opc, char *name, int argc, char **argv)
1816 struct libcfs_ioctl_data data = { { 0 } };
1819 LIBCFS_IOC_INIT(data);
1820 data.ioc_flags = opc;
1822 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_LNET_FAULT, &data);
1824 fprintf(stderr, "failed to reset %s stats: %s\n",
1825 name, strerror(errno));
1832 jt_ptl_drop_reset(int argc, char **argv)
1834 return fault_simul_rule_reset(LNET_CTL_DROP_RESET, "drop", argc, argv);
1838 jt_ptl_delay_reset(int argc, char **argv)
1840 return fault_simul_rule_reset(LNET_CTL_DELAY_RESET, "delay",
1845 fault_simul_rule_list(__u32 opc, char *name, int argc, char **argv)
1847 struct libcfs_ioctl_data data = { { 0 } };
1848 struct lnet_fault_attr attr;
1849 struct lnet_fault_stat stat;
1852 printf("LNet %s rules:\n", name);
1853 for (pos = 0;; pos++) {
1856 memset(&attr, 0, sizeof(attr));
1857 memset(&stat, 0, sizeof(stat));
1859 data.ioc_count = pos;
1860 data.ioc_flags = opc;
1861 data.ioc_inllen1 = sizeof(attr);
1862 data.ioc_inlbuf1 = (char *)&attr;
1863 data.ioc_inllen2 = sizeof(stat);
1864 data.ioc_inlbuf2 = (char *)&stat;
1865 if (libcfs_ioctl_pack(&data, &ioc_buf, IOC_BUF_SIZE) != 0) {
1866 fprintf(stderr, "libcfs_ioctl_pack failed\n");
1870 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_LNET_FAULT, ioc_buf);
1874 libcfs_ioctl_unpack(&data, ioc_buf);
1876 if (opc == LNET_CTL_DROP_LIST) {
1877 printf("%s->%s (1/%d | %d) ptl %#jx, msg %x, %ju/%ju, PUT %ju, ACK %ju, GET %ju, REP %ju\n",
1878 libcfs_nid2str(attr.fa_src),
1879 libcfs_nid2str(attr.fa_dst),
1880 attr.u.drop.da_rate, attr.u.drop.da_interval,
1881 (uintmax_t)attr.fa_ptl_mask, attr.fa_msg_mask,
1882 (uintmax_t)stat.u.drop.ds_dropped,
1883 (uintmax_t)stat.fs_count,
1884 (uintmax_t)stat.fs_put,
1885 (uintmax_t)stat.fs_ack,
1886 (uintmax_t)stat.fs_get,
1887 (uintmax_t)stat.fs_reply);
1889 } else if (opc == LNET_CTL_DELAY_LIST) {
1890 printf("%s->%s (1/%d | %d, latency %d) ptl %#jx, msg %x, %ju/%ju, PUT %ju, ACK %ju, GET %ju, REP %ju\n",
1891 libcfs_nid2str(attr.fa_src),
1892 libcfs_nid2str(attr.fa_dst),
1893 attr.u.delay.la_rate, attr.u.delay.la_interval,
1894 attr.u.delay.la_latency,
1895 (uintmax_t)attr.fa_ptl_mask, attr.fa_msg_mask,
1896 (uintmax_t)stat.u.delay.ls_delayed,
1897 (uintmax_t)stat.fs_count,
1898 (uintmax_t)stat.fs_put,
1899 (uintmax_t)stat.fs_ack,
1900 (uintmax_t)stat.fs_get,
1901 (uintmax_t)stat.fs_reply);
1904 printf("found total %d\n", pos);
1910 jt_ptl_drop_list(int argc, char **argv)
1912 return fault_simul_rule_list(LNET_CTL_DROP_LIST, "drop", argc, argv);
1916 jt_ptl_delay_list(int argc, char **argv)
1918 return fault_simul_rule_list(LNET_CTL_DELAY_LIST, "delay", argc, argv);
1922 get_cycles_per_usec()
1924 FILE *f = fopen("/proc/cpuinfo", "r");
1929 while (fgets(line, sizeof(line), f))
1930 if (sscanf(line, "cpu MHz : %lf", &mhz) == 1) {
1937 fprintf(stderr, "Can't read/parse /proc/cpuinfo\n");
1941 int jt_ptl_testprotocompat(int argc, char **argv)
1943 struct libcfs_ioctl_data data;
1949 fprintf(stderr, "usage: %s <number>\n", argv[0]);
1953 flags = strtol(argv[1], &end, 0);
1954 if (flags < 0 || *end != 0) {
1955 fprintf(stderr, "Can't parse flags '%s'\n", argv[1]);
1959 LIBCFS_IOC_INIT(data);
1960 data.ioc_flags = flags;
1961 rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_TESTPROTOCOMPAT, &data);
1964 fprintf(stderr, "test proto compat %x failed: %s\n",
1965 flags, strerror(errno));
1969 printf("test proto compat %x OK\n", flags);