1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001, 2002 Cluster File Systems, Inc.
6 * This file is part of Portals, http://www.sf.net/projects/lustre/
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.
24 #include <sys/types.h>
26 #include <sys/socket.h>
27 #include <netinet/tcp.h>
32 #include <sys/ioctl.h>
37 #include <asm/byteorder.h>
39 #include <portals/api-support.h>
40 #include <portals/ptlctl.h>
41 #include <portals/list.h>
42 #include <portals/lib-types.h>
45 unsigned int portal_debug;
46 unsigned int portal_printk;
47 unsigned int portal_stack;
50 static unsigned int g_nal = 0;
52 static int g_socket_txmem = 0;
53 static int g_socket_rxmem = 0;
54 static int g_socket_nonagle = 1;
62 static name2num_t nalnames[] = {
67 {"scimac", SCIMACNAL},
72 name2num_lookup_name (name2num_t *table, char *str)
74 while (table->name != NULL)
75 if (!strcmp (str, table->name))
83 name2num_lookup_num (name2num_t *table, int num)
85 while (table->name != NULL)
86 if (num == table->num)
94 ptl_name2nal (char *str)
96 name2num_t *e = name2num_lookup_name (nalnames, str);
98 return ((e == NULL) ? 0 : e->num);
104 name2num_t *e = name2num_lookup_num (nalnames, nal);
106 return ((e == NULL) ? "???" : e->name);
109 static struct hostent *
110 ptl_gethostbyname(char * hname) {
112 he = gethostbyname(hname);
117 fprintf(stderr, "Unable to resolve hostname: %s\n",
121 fprintf(stderr, "gethostbyname error: %s\n",
131 ptl_parse_ipaddr (__u32 *ipaddrp, char *str)
139 if (!strcmp (str, "_all_"))
145 if (sscanf (str, "%d.%d.%d.%d", &a, &b, &c, &d) == 4 &&
146 (a & ~0xff) == 0 && (b & ~0xff) == 0 &&
147 (c & ~0xff) == 0 && (d & ~0xff) == 0)
149 *ipaddrp = (a<<24)|(b<<16)|(c<<8)|d;
153 if ((('a' <= str[0] && str[0] <= 'z') ||
154 ('A' <= str[0] && str[0] <= 'Z')) &&
155 (he = ptl_gethostbyname (str)) != NULL)
157 __u32 addr = *(__u32 *)he->h_addr;
159 *ipaddrp = ntohl(addr); /* HOST byte order */
167 ptl_ipaddr_2_str (__u32 ipaddr, char *str)
172 net_ip = htonl (ipaddr);
173 he = gethostbyaddr (&net_ip, sizeof (net_ip), AF_INET);
177 sprintf (str, "%d.%d.%d.%d",
178 (ipaddr >> 24) & 0xff, (ipaddr >> 16) & 0xff,
179 (ipaddr >> 8) & 0xff, ipaddr & 0xff);
184 ptl_parse_nid (ptl_nid_t *nidp, char *str)
189 if (!strcmp (str, "_all_")) {
194 if (ptl_parse_ipaddr (&ipaddr, str) == 0) {
195 *nidp = (ptl_nid_t)ipaddr;
199 if (sscanf (str, "%li", &lval) == 1)
201 *nidp = (ptl_nid_t)lval;
205 if (sscanf (str, "%lx", &lval) == 1)
207 *nidp = (ptl_nid_t)lval;
215 ptl_nid2str (char *buffer, ptl_nid_t nid)
217 __u32 addr = htonl((__u32)nid); /* back to NETWORK byte order */
218 struct hostent *he = gethostbyaddr ((const char *)&addr, sizeof (addr), AF_INET);
221 strcpy (buffer, he->h_name);
223 sprintf (buffer, "0x"LPX64, nid);
228 int g_nal_is_compatible (char *cmd, ...)
234 fprintf (stderr, "Error: you must run the 'network' command first.\n");
241 nal = va_arg (ap, int);
242 } while (nal != 0 && nal != g_nal);
249 fprintf (stderr, "Command %s not compatible with nal %s\n",
250 cmd, nal2name (g_nal));
255 sock_write (int cfd, void *buffer, int nob)
259 int rc = write (cfd, buffer, nob);
271 fprintf (stderr, "Unexpected zero sock_write\n");
276 buffer = (char *)buffer + nob;
283 sock_read (int cfd, void *buffer, int nob)
287 int rc = read (cfd, buffer, nob);
297 if (rc == 0) /* EOF */
299 errno = ECONNABORTED;
304 buffer = (char *)buffer + nob;
310 int ptl_initialize(int argc, char **argv)
312 register_ioc_dev(PORTALS_DEV_ID, PORTALS_DEV_PATH);
317 int jt_ptl_network(int argc, char **argv)
323 (nal = ptl_name2nal (argv[1])) != 0) {
328 fprintf(stderr, "usage: %s \n", argv[0]);
329 for (entry = nalnames; entry->name != NULL; entry++)
330 fprintf (stderr, "%s%s", entry == nalnames ? "<" : "|", entry->name);
331 fprintf(stderr, ">\n");
336 jt_ptl_print_autoconnects (int argc, char **argv)
338 struct portal_ioctl_data data;
343 if (!g_nal_is_compatible (argv[0], SOCKNAL, 0))
346 for (index = 0;;index++) {
347 PORTAL_IOC_INIT (data);
348 data.ioc_nal = g_nal;
349 data.ioc_nal_cmd = NAL_CMD_GET_AUTOCONN;
350 data.ioc_count = index;
352 rc = l_ioctl (PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
356 printf (LPX64"@%s:%d #%d buffer %d nonagle %s xchg %s affinity %s share %d\n",
357 data.ioc_nid, ptl_ipaddr_2_str (data.ioc_id, buffer),
358 data.ioc_misc, data.ioc_count, data.ioc_size,
359 (data.ioc_flags & 1) ? "on" : "off",
360 (data.ioc_flags & 2) ? "on" : "off",
361 (data.ioc_flags & 4) ? "on" : "off",
366 printf ("<no autoconnect routes>\n");
371 jt_ptl_add_autoconnect (int argc, char **argv)
373 struct portal_ioctl_data data;
377 int xchange_nids = 0;
378 int irq_affinity = 0;
382 if (argc < 4 || argc > 5) {
383 fprintf (stderr, "usage: %s nid ipaddr port [ixs]\n", argv[0]);
387 if (!g_nal_is_compatible (argv[0], SOCKNAL, 0))
390 if (ptl_parse_nid (&nid, argv[1]) != 0 ||
391 nid == PTL_NID_ANY) {
392 fprintf (stderr, "Can't parse NID: %s\n", argv[1]);
396 if (ptl_parse_ipaddr (&ip, argv[2]) != 0) {
397 fprintf (stderr, "Can't parse ip addr: %s\n", argv[2]);
401 port = atol (argv[3]);
404 char *opts = argv[4];
418 fprintf (stderr, "Can't parse options: %s\n",
424 PORTAL_IOC_INIT (data);
425 data.ioc_nal = g_nal;
426 data.ioc_nal_cmd = NAL_CMD_ADD_AUTOCONN;
429 data.ioc_misc = port;
430 /* only passing one buffer size! */
431 data.ioc_size = MAX (g_socket_rxmem, g_socket_txmem);
432 data.ioc_flags = (g_socket_nonagle ? 1 : 0) |
433 (xchange_nids ? 2 : 0) |
434 (irq_affinity ? 4 : 0) |
437 rc = l_ioctl (PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
439 fprintf (stderr, "failed to enable autoconnect: %s\n",
448 jt_ptl_del_autoconnect (int argc, char **argv)
450 struct portal_ioctl_data data;
451 ptl_nid_t nid = PTL_NID_ANY;
458 fprintf (stderr, "usage: %s [nid] [ipaddr] [sk]\n",
463 if (!g_nal_is_compatible (argv[0], SOCKNAL, 0))
467 ptl_parse_nid (&nid, argv[1]) != 0) {
468 fprintf (stderr, "Can't parse nid: %s\n", argv[1]);
473 ptl_parse_ipaddr (&ip, argv[2]) != 0) {
474 fprintf (stderr, "Can't parse ip addr: %s\n", argv[2]);
479 char *opts = argv[3];
490 fprintf (stderr, "Can't parse flags: %s\n",
496 PORTAL_IOC_INIT (data);
497 data.ioc_nal = g_nal;
498 data.ioc_nal_cmd = NAL_CMD_DEL_AUTOCONN;
501 data.ioc_flags = (share ? 1 : 0) |
504 rc = l_ioctl (PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
506 fprintf (stderr, "failed to remove autoconnect route: %s\n",
515 jt_ptl_print_connections (int argc, char **argv)
517 struct portal_ioctl_data data;
522 if (!g_nal_is_compatible (argv[0], SOCKNAL, 0))
525 for (index = 0;;index++) {
526 PORTAL_IOC_INIT (data);
527 data.ioc_nal = g_nal;
528 data.ioc_nal_cmd = NAL_CMD_GET_CONN;
529 data.ioc_count = index;
531 rc = l_ioctl (PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
535 printf (LPD64"@%s:%d\n",
537 ptl_ipaddr_2_str (data.ioc_id, buffer),
542 printf ("<no connections>\n");
547 exchange_nids (int cfd, ptl_nid_t my_nid, ptl_nid_t *peer_nid)
551 ptl_magicversion_t *hmv = (ptl_magicversion_t *)&hdr.dest_nid;
553 LASSERT (sizeof (*hmv) == sizeof (hdr.dest_nid));
555 memset (&hdr, 0, sizeof (hdr));
557 hmv->magic = __cpu_to_le32 (PORTALS_PROTO_MAGIC);
558 hmv->version_major = __cpu_to_le16 (PORTALS_PROTO_VERSION_MAJOR);
559 hmv->version_minor = __cpu_to_le16 (PORTALS_PROTO_VERSION_MINOR);
561 hdr.src_nid = __cpu_to_le64 (my_nid);
562 hdr.type = __cpu_to_le32 (PTL_MSG_HELLO);
564 /* Assume there's sufficient socket buffering for a portals HELLO header */
565 rc = sock_write (cfd, &hdr, sizeof (hdr));
567 perror ("Can't send initial HELLO");
571 /* First few bytes down the wire are the portals protocol magic and
572 * version, no matter what protocol version we're running. */
574 rc = sock_read (cfd, hmv, sizeof (*hmv));
576 perror ("Can't read from peer");
580 if (hmv->magic != __cpu_to_le32 (PORTALS_PROTO_MAGIC)) {
581 fprintf (stderr, "Bad magic %#08x (%#08x expected)\n",
582 __le32_to_cpu (hmv->magic), PORTALS_PROTO_MAGIC);
586 if (hmv->version_major != __cpu_to_le16 (PORTALS_PROTO_VERSION_MAJOR) ||
587 hmv->version_minor != __cpu_to_le16 (PORTALS_PROTO_VERSION_MINOR)) {
588 fprintf (stderr, "Incompatible protocol version %d.%d (%d.%d expected)\n",
589 __le16_to_cpu (hmv->version_major),
590 __le16_to_cpu (hmv->version_minor),
591 PORTALS_PROTO_VERSION_MAJOR,
592 PORTALS_PROTO_VERSION_MINOR);
595 /* version 0 sends magic/version as the dest_nid of a 'hello' header,
596 * so read the rest of it in now... */
597 LASSERT (PORTALS_PROTO_VERSION_MAJOR == 0);
598 rc = sock_read (cfd, hmv + 1, sizeof (hdr) - sizeof (*hmv));
600 perror ("Can't read rest of HELLO hdr");
604 /* ...and check we got what we expected */
605 if (hdr.type != __cpu_to_le32 (PTL_MSG_HELLO) ||
606 PTL_HDR_LENGTH (&hdr) != __cpu_to_le32 (0)) {
607 fprintf (stderr, "Expecting a HELLO hdr with 0 payload,"
608 " but got type %d with %d payload\n",
609 __le32_to_cpu (hdr.type),
610 __le32_to_cpu (PTL_HDR_LENGTH (&hdr)));
614 *peer_nid = __le64_to_cpu (hdr.src_nid);
618 int jt_ptl_connect(int argc, char **argv)
621 struct portal_ioctl_data data;
622 struct sockaddr_in srvaddr;
630 int xchange_nids = 0;
636 fprintf(stderr, "usage: %s ip port [xi]\n", argv[0]);
640 if (!g_nal_is_compatible (argv[0], SOCKNAL, TOENAL, 0))
643 rc = ptl_parse_ipaddr (&ipaddr, argv[1]);
645 fprintf(stderr, "Can't parse hostname: %s\n", argv[1]);
649 port = atol(argv[2]);
651 for (flag = argv[3]; *flag != 0; flag++)
663 fprintf (stderr, "unrecognised flag '%c'\n",
668 memset(&srvaddr, 0, sizeof(srvaddr));
669 srvaddr.sin_family = AF_INET;
670 srvaddr.sin_port = htons(port);
671 srvaddr.sin_addr.s_addr = htonl(ipaddr);
673 fd = socket(PF_INET, SOCK_STREAM, 0);
675 fprintf(stderr, "socket() failed: %s\n", strerror(errno));
679 if (g_socket_nonagle)
682 if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &o, sizeof (o)) != 0) {
683 fprintf(stderr, "cannot disable nagle: %s\n", strerror(errno));
688 if (g_socket_rxmem != 0) {
690 if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &o, sizeof (o)) != 0) {
691 fprintf(stderr, "cannot set receive buffer size: %s\n", strerror(errno));
696 if (g_socket_txmem != 0) {
698 if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &o, sizeof (o)) != 0) {
699 fprintf(stderr, "cannot set send buffer size: %s\n", strerror(errno));
704 rc = connect(fd, (struct sockaddr *)&srvaddr, sizeof(srvaddr));
706 fprintf(stderr, "connect() failed: %s\n", strerror(errno));
710 olen = sizeof (txmem);
711 if (getsockopt (fd, SOL_SOCKET, SO_SNDBUF, &txmem, &olen) != 0)
712 fprintf (stderr, "Can't get send buffer size: %s\n", strerror (errno));
713 olen = sizeof (rxmem);
714 if (getsockopt (fd, SOL_SOCKET, SO_RCVBUF, &rxmem, &olen) != 0)
715 fprintf (stderr, "Can't get receive buffer size: %s\n", strerror (errno));
716 olen = sizeof (nonagle);
717 if (getsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &nonagle, &olen) != 0)
718 fprintf (stderr, "Can't get nagle: %s\n", strerror (errno));
723 PORTAL_IOC_INIT (data);
724 data.ioc_nal = g_nal;
725 rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_GET_NID, &data);
727 fprintf (stderr, "failed to get my nid: %s\n",
733 rc = exchange_nids (fd, data.ioc_nid, &peer_nid);
739 printf("Connected host: %s NID "LPX64" snd: %d rcv: %d nagle: %s\n", argv[1],
740 peer_nid, txmem, rxmem, nonagle ? "Disabled" : "Enabled");
742 PORTAL_IOC_INIT(data);
744 data.ioc_nal = g_nal;
745 data.ioc_nal_cmd = NAL_CMD_REGISTER_PEER_FD;
746 data.ioc_nid = peer_nid;
747 data.ioc_flags = bind_irq;
749 rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
751 fprintf(stderr, "failed to register fd with portals: %s\n",
757 printf("Connection to "LPX64" registered with socknal\n", peer_nid);
761 fprintf(stderr, "close failed: %d\n", rc);
766 int jt_ptl_disconnect(int argc, char **argv)
768 struct portal_ioctl_data data;
769 ptl_nid_t nid = PTL_NID_ANY;
774 fprintf(stderr, "usage: %s [nid] [ipaddr]\n", argv[0]);
778 if (!g_nal_is_compatible (argv[0], SOCKNAL, TOENAL, 0))
782 ptl_parse_nid (&nid, argv[1]) != 0) {
783 fprintf (stderr, "Can't parse nid %s\n", argv[1]);
788 ptl_parse_ipaddr (&ipaddr, argv[2]) != 0) {
789 fprintf (stderr, "Can't parse ip addr %s\n", argv[2]);
793 PORTAL_IOC_INIT(data);
794 data.ioc_nal = g_nal;
795 data.ioc_nal_cmd = NAL_CMD_CLOSE_CONNECTION;
797 data.ioc_id = ipaddr;
799 rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
801 fprintf(stderr, "failed to remove connection: %s\n",
809 int jt_ptl_push_connection (int argc, char **argv)
811 struct portal_ioctl_data data;
813 ptl_nid_t nid = PTL_NID_ANY;
817 fprintf(stderr, "usage: %s [nid] [ip]\n", argv[0]);
821 if (!g_nal_is_compatible (argv[0], SOCKNAL, TOENAL, 0))
825 ptl_parse_nid (&nid, argv[1]) != 0) {
826 fprintf(stderr, "Can't parse nid: %s\n", argv[1]);
831 ptl_parse_ipaddr (&ipaddr, argv[2]) != 0) {
832 fprintf(stderr, "Can't parse ipaddr: %s\n", argv[2]);
835 PORTAL_IOC_INIT(data);
836 data.ioc_nal = g_nal;
837 data.ioc_nal_cmd = NAL_CMD_PUSH_CONNECTION;
839 data.ioc_id = ipaddr;
841 rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
843 fprintf(stderr, "failed to push connection: %s\n",
851 int jt_ptl_ping(int argc, char **argv)
858 struct portal_ioctl_data data;
861 fprintf(stderr, "usage: %s nid [count] [size] [timeout (secs)]\n", argv[0]);
866 fprintf(stderr, "Error: you must run the 'network' command "
871 if (ptl_parse_nid (&nid, argv[1]) != 0)
873 fprintf (stderr, "Can't parse nid \"%s\"\n", argv[1]);
879 count = atol(argv[2]);
881 if (count < 0 || count > 20000)
883 fprintf(stderr, "are you insane? %ld is a crazy count.\n", count);
892 timeout = atol (argv[4]);
894 PORTAL_IOC_INIT (data);
895 data.ioc_count = count;
896 data.ioc_size = size;
898 data.ioc_nal = g_nal;
899 data.ioc_timeout = timeout;
901 rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_PING, &data);
903 fprintf(stderr, "failed to start pinger: %s\n",
910 int jt_ptl_shownid(int argc, char **argv)
912 struct portal_ioctl_data data;
916 fprintf(stderr, "usage: %s\n", argv[0]);
921 fprintf(stderr, "Error: you must run the 'network' command first\n");
925 PORTAL_IOC_INIT (data);
926 data.ioc_nal = g_nal;
927 rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_GET_NID, &data);
929 fprintf(stderr, "getting my NID failed: %s\n",
932 printf(LPX64"\n", data.ioc_nid);
936 int jt_ptl_mynid(int argc, char **argv)
941 struct portal_ioctl_data data;
945 fprintf(stderr, "usage: %s [NID]\n", argv[0]);
946 fprintf(stderr, "NID defaults to the primary IP address of the machine.\n");
951 fprintf(stderr, "Error: you must run the 'network' command "
958 else if (gethostname(hostname, sizeof(hostname)) != 0) {
959 fprintf(stderr, "gethostname failed: %s\n",
966 rc = ptl_parse_nid (&mynid, nidstr);
968 fprintf (stderr, "Can't convert '%s' into a NID\n", nidstr);
972 PORTAL_IOC_INIT(data);
973 data.ioc_nid = mynid;
974 data.ioc_nal = g_nal;
975 data.ioc_nal_cmd = NAL_CMD_REGISTER_MYNID;
977 rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_NAL_CMD, &data);
979 fprintf(stderr, "setting my NID failed: %s\n",
982 printf("registered my nid "LPX64" (%s)\n", mynid, hostname);
987 jt_ptl_fail_nid (int argc, char **argv)
991 unsigned int threshold;
992 struct portal_ioctl_data data;
994 if (argc < 2 || argc > 3)
996 fprintf (stderr, "usage: %s nid|\"_all_\" [count (0 == mend)]\n", argv[0]);
1001 fprintf(stderr, "Error: you must run the 'network' command "
1006 if (!strcmp (argv[1], "_all_"))
1008 else if (ptl_parse_nid (&nid, argv[1]) != 0)
1010 fprintf (stderr, "Can't parse nid \"%s\"\n", argv[1]);
1015 threshold = PTL_MD_THRESH_INF;
1016 else if (sscanf (argv[2], "%i", &threshold) != 1) {
1017 fprintf (stderr, "Can't parse count \"%s\"\n", argv[2]);
1021 PORTAL_IOC_INIT (data);
1022 data.ioc_nal = g_nal;
1024 data.ioc_count = threshold;
1026 rc = l_ioctl (PORTALS_DEV_ID, IOC_PORTAL_FAIL_NID, &data);
1028 fprintf (stderr, "IOC_PORTAL_FAIL_NID failed: %s\n",
1031 printf ("%s %s\n", threshold == 0 ? "Unfailing" : "Failing", argv[1]);
1037 jt_ptl_rxmem (int argc, char **argv)
1043 if (Parser_size (&size, argv[1]) != 0 || size < 0)
1045 fprintf (stderr, "Can't parse size %s\n", argv[1]);
1049 g_socket_rxmem = size;
1051 printf ("Socket rmem = %d\n", g_socket_rxmem);
1056 jt_ptl_txmem (int argc, char **argv)
1062 if (Parser_size (&size, argv[1]) != 0 || size < 0)
1064 fprintf (stderr, "Can't parse size %s\n", argv[1]);
1067 g_socket_txmem = size;
1069 printf ("Socket txmem = %d\n", g_socket_txmem);
1074 jt_ptl_nagle (int argc, char **argv)
1080 if (Parser_bool (&enable, argv[1]) != 0)
1082 fprintf (stderr, "Can't parse boolean %s\n", argv[1]);
1085 g_socket_nonagle = !enable;
1087 printf ("Nagle %s\n", g_socket_nonagle ? "disabled" : "enabled");
1092 jt_ptl_add_route (int argc, char **argv)
1094 struct portal_ioctl_data data;
1097 ptl_nid_t gateway_nid;
1102 fprintf (stderr, "usage: %s gateway target [target]\n", argv[0]);
1107 fprintf(stderr, "Error: you must run the 'network' command "
1112 if (ptl_parse_nid (&gateway_nid, argv[1]) != 0)
1114 fprintf (stderr, "Can't parse gateway NID \"%s\"\n", argv[1]);
1118 if (ptl_parse_nid (&nid1, argv[2]) != 0)
1120 fprintf (stderr, "Can't parse first target NID \"%s\"\n", argv[2]);
1126 else if (ptl_parse_nid (&nid2, argv[3]) != 0)
1128 fprintf (stderr, "Can't parse second target NID \"%s\"\n", argv[4]);
1132 PORTAL_IOC_INIT(data);
1133 data.ioc_nid = gateway_nid;
1134 data.ioc_nal = g_nal;
1135 data.ioc_nid2 = MIN (nid1, nid2);
1136 data.ioc_nid3 = MAX (nid1, nid2);
1138 rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_ADD_ROUTE, &data);
1141 fprintf (stderr, "IOC_PORTAL_ADD_ROUTE failed: %s\n", strerror (errno));
1149 jt_ptl_del_route (int argc, char **argv)
1151 struct portal_ioctl_data data;
1157 fprintf (stderr, "usage: %s targetNID\n", argv[0]);
1161 if (ptl_parse_nid (&nid, argv[1]) != 0)
1163 fprintf (stderr, "Can't parse target NID \"%s\"\n", argv[1]);
1167 PORTAL_IOC_INIT(data);
1170 rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_DEL_ROUTE, &data);
1173 fprintf (stderr, "IOC_PORTAL_DEL_ROUTE ("LPX64") failed: %s\n", nid, strerror (errno));
1181 jt_ptl_print_routes (int argc, char **argv)
1183 char buffer[3][128];
1184 struct portal_ioctl_data data;
1188 ptl_nid_t gateway_nid;
1193 for (index = 0;;index++)
1195 PORTAL_IOC_INIT(data);
1196 data.ioc_count = index;
1198 rc = l_ioctl(PORTALS_DEV_ID, IOC_PORTAL_GET_ROUTE, &data);
1202 gateway_nal = data.ioc_nal;
1203 gateway_nid = data.ioc_nid;
1204 nid1 = data.ioc_nid2;
1205 nid2 = data.ioc_nid3;
1207 printf ("%8s %18s : %s - %s\n",
1208 nal2name (gateway_nal),
1209 ptl_nid2str (buffer[0], gateway_nid),
1210 ptl_nid2str (buffer[1], nid1),
1211 ptl_nid2str (buffer[2], nid2));