4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of the
9 * License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 * Copyright (c) 2014, 2017, Intel Corporation.
24 * Amir Shehata <amir.shehata@intel.com>
31 #include <libcfs/util/ioctl.h>
32 #include <libcfs/util/parser.h>
34 #include "lnetconfig/liblnetconfig.h"
36 #define LNET_CONFIGURE true
37 #define LNET_UNCONFIGURE false
39 static int jt_config_lnet(int argc, char **argv);
40 static int jt_unconfig_lnet(int argc, char **argv);
41 static int jt_add_route(int argc, char **argv);
42 static int jt_add_ni(int argc, char **argv);
43 static int jt_set_routing(int argc, char **argv);
44 static int jt_del_route(int argc, char **argv);
45 static int jt_del_ni(int argc, char **argv);
46 static int jt_show_route(int argc, char **argv);
47 static int jt_show_net(int argc, char **argv);
48 static int jt_show_routing(int argc, char **argv);
49 static int jt_show_stats(int argc, char **argv);
50 static int jt_show_peer(int argc, char **argv);
51 static int jt_show_recovery(int argc, char **argv);
52 static int jt_show_global(int argc, char **argv);
53 static int jt_set_tiny(int argc, char **argv);
54 static int jt_set_small(int argc, char **argv);
55 static int jt_set_large(int argc, char **argv);
56 static int jt_set_numa(int argc, char **argv);
57 static int jt_set_retry_count(int argc, char **argv);
58 static int jt_set_transaction_to(int argc, char **argv);
59 static int jt_set_recov_intrv(int argc, char **argv);
60 static int jt_set_hsensitivity(int argc, char **argv);
61 static int jt_add_peer_nid(int argc, char **argv);
62 static int jt_del_peer_nid(int argc, char **argv);
63 static int jt_set_max_intf(int argc, char **argv);
64 static int jt_set_discovery(int argc, char **argv);
65 static int jt_list_peer(int argc, char **argv);
66 /*static int jt_show_peer(int argc, char **argv);*/
67 static int lnetctl_list_commands(int argc, char **argv);
68 static int jt_import(int argc, char **argv);
69 static int jt_export(int argc, char **argv);
70 static int jt_ping(int argc, char **argv);
71 static int jt_discover(int argc, char **argv);
72 static int jt_lnet(int argc, char **argv);
73 static int jt_route(int argc, char **argv);
74 static int jt_net(int argc, char **argv);
75 static int jt_routing(int argc, char **argv);
76 static int jt_set(int argc, char **argv);
77 static int jt_debug(int argc, char **argv);
78 static int jt_stats(int argc, char **argv);
79 static int jt_global(int argc, char **argv);
80 static int jt_peers(int argc, char **argv);
81 static int jt_set_ni_value(int argc, char **argv);
82 static int jt_set_peer_ni_value(int argc, char **argv);
84 command_t cmd_list[] = {
85 {"lnet", jt_lnet, 0, "lnet {configure | unconfigure} [--all]"},
86 {"route", jt_route, 0, "route {add | del | show | help}"},
87 {"net", jt_net, 0, "net {add | del | show | help}"},
88 {"routing", jt_routing, 0, "routing {show | help}"},
89 {"set", jt_set, 0, "set {tiny_buffers | small_buffers | large_buffers"
90 " | routing | numa_range | max_interfaces"
92 {"import", jt_import, 0, "import FILE.yaml"},
93 {"export", jt_export, 0, "export FILE.yaml"},
94 {"stats", jt_stats, 0, "stats {show | help}"},
95 {"debug", jt_debug, 0, "debug recovery {local | peer}"},
96 {"global", jt_global, 0, "global {show | help}"},
97 {"peer", jt_peers, 0, "peer {add | del | show | help}"},
98 {"ping", jt_ping, 0, "ping nid,[nid,...]"},
99 {"discover", jt_discover, 0, "discover nid[,nid,...]"},
100 {"help", Parser_help, 0, "help"},
101 {"exit", Parser_quit, 0, "quit"},
102 {"quit", Parser_quit, 0, "quit"},
103 {"--list-commands", lnetctl_list_commands, 0, "list commands"},
107 command_t lnet_cmds[] = {
108 {"configure", jt_config_lnet, 0, "configure lnet\n"
109 "\t--all: load NI configuration from module parameters\n"},
110 {"unconfigure", jt_unconfig_lnet, 0, "unconfigure lnet\n"},
114 command_t route_cmds[] = {
115 {"add", jt_add_route, 0, "add a route\n"
116 "\t--net: net name (e.g. tcp0)\n"
117 "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp)\n"
118 "\t--hop: number to final destination (1 < hops < 255)\n"
119 "\t--priority: priority of route (0 - highest prio\n"},
120 {"del", jt_del_route, 0, "delete a route\n"
121 "\t--net: net name (e.g. tcp0)\n"
122 "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp)\n"},
123 {"show", jt_show_route, 0, "show routes\n"
124 "\t--net: net name (e.g. tcp0) to filter on\n"
125 "\t--gateway: gateway nid (e.g. 10.1.1.2@tcp) to filter on\n"
126 "\t--hop: number to final destination (1 < hops < 255) to filter on\n"
127 "\t--priority: priority of route (0 - highest prio to filter on\n"
128 "\t--verbose: display detailed output per route\n"},
132 command_t net_cmds[] = {
133 {"add", jt_add_ni, 0, "add a network\n"
134 "\t--net: net name (e.g. tcp0)\n"
135 "\t--if: physical interface (e.g. eth0)\n"
136 "\t--ip2net: specify networks based on IP address patterns\n"
137 "\t--peer-timeout: time to wait before declaring a peer dead\n"
138 "\t--peer-credits: define the max number of inflight messages\n"
139 "\t--peer-buffer-credits: the number of buffer credits per peer\n"
140 "\t--credits: Network Interface credits\n"
141 "\t--cpt: CPU Partitions configured net uses (e.g. [0,1]\n"},
142 {"del", jt_del_ni, 0, "delete a network\n"
143 "\t--net: net name (e.g. tcp0)\n"
144 "\t--if: physical interface (e.g. eth0)\n"},
145 {"show", jt_show_net, 0, "show networks\n"
146 "\t--net: net name (e.g. tcp0) to filter on\n"
147 "\t--verbose: display detailed output per network."
148 " Optional argument of '2' outputs more stats\n"},
149 {"set", jt_set_ni_value, 0, "set local NI specific parameter\n"
150 "\t--nid: NI NID to set the\n"
151 "\t--health: specify health value to set\n"
152 "\t--all: set all NIs value to the one specified\n"},
156 command_t routing_cmds[] = {
157 {"show", jt_show_routing, 0, "show routing information\n"},
161 command_t stats_cmds[] = {
162 {"show", jt_show_stats, 0, "show LNET statistics\n"},
166 command_t debug_cmds[] = {
167 {"recovery", jt_show_recovery, 0, "list recovery queues\n"
168 "\t--local : list local recovery queue\n"
169 "\t--peer : list peer recovery queue\n"},
173 command_t global_cmds[] = {
174 {"show", jt_show_global, 0, "show global variables\n"},
178 command_t set_cmds[] = {
179 {"tiny_buffers", jt_set_tiny, 0, "set tiny routing buffers\n"
180 "\tVALUE must be greater than 0\n"},
181 {"small_buffers", jt_set_small, 0, "set small routing buffers\n"
182 "\tVALUE must be greater than 0\n"},
183 {"large_buffers", jt_set_large, 0, "set large routing buffers\n"
184 "\tVALUE must be greater than 0\n"},
185 {"routing", jt_set_routing, 0, "enable/disable routing\n"
186 "\t0 - disable routing\n"
187 "\t1 - enable routing\n"},
188 {"numa_range", jt_set_numa, 0, "set NUMA range for NI selection\n"
189 "\tVALUE must be at least 0\n"},
190 {"max_interfaces", jt_set_max_intf, 0, "set the default value for "
192 "\tValue must be greater than 16\n"},
193 {"discovery", jt_set_discovery, 0, "enable/disable peer discovery\n"
194 "\t0 - disable peer discovery\n"
195 "\t1 - enable peer discovery (default)\n"},
196 {"retry_count", jt_set_retry_count, 0, "number of retries\n"
197 "\t0 - turn of retries\n"
198 "\t>0 - number of retries\n"},
199 {"transaction_timeout", jt_set_transaction_to, 0, "Message/Response timeout\n"
200 "\t>0 - timeout in seconds\n"},
201 {"health_sensitivity", jt_set_hsensitivity, 0, "sensitivity to failure\n"
202 "\t0 - turn off health evaluation\n"
203 "\t>0 - sensitivity value not more than 1000\n"},
204 {"recovery_interval", jt_set_recov_intrv, 0, "interval to ping in seconds (at least 1)\n"
205 "\t>0 - time in seconds between pings\n"},
209 command_t peer_cmds[] = {
210 {"add", jt_add_peer_nid, 0, "add a peer NID\n"
211 "\t--prim_nid: Primary NID of the peer. If not provided then the first\n"
212 "\t NID in the list becomes the Primary NID of a newly created\n"
214 "\t--nid: one or more peer NIDs\n"
215 "\t--non_mr: create this peer as not Multi-Rail capable\n"
216 "\t--ip2nets: specify a range of nids per peer"},
217 {"del", jt_del_peer_nid, 0, "delete a peer NID\n"
218 "\t--prim_nid: Primary NID of the peer.\n"
219 "\t--nid: list of NIDs to remove. If none provided,\n"
220 "\t peer is deleted\n"
221 "\t--ip2nets: specify a range of nids per peer"},
222 {"show", jt_show_peer, 0, "show peer information\n"
223 "\t--nid: NID of peer to filter on.\n"
224 "\t--verbose: display detailed output per peer."
225 " Optional argument of '2' outputs more stats\n"},
226 {"list", jt_list_peer, 0, "list all peers\n"},
227 {"set", jt_set_peer_ni_value, 0, "set peer ni specific parameter\n"
228 "\t--nid: Peer NI NID to set the\n"
229 "\t--health: specify health value to set\n"
230 "\t--all: set all peer_nis values to the one specified\n"},
234 static inline void print_help(const command_t cmds[], const char *cmd_type,
237 const command_t *cmd;
239 for (cmd = cmds; cmd->pc_name; cmd++) {
240 if (pc_name != NULL &&
241 strcmp(cmd->pc_name, pc_name) == 0) {
242 printf("%s %s: %s\n", cmd_type, cmd->pc_name,
245 } else if (pc_name != NULL) {
248 printf("%s %s: %s\n", cmd_type, cmd->pc_name, cmd->pc_help);
252 static int parse_long(const char *number, long int *value)
259 *value = strtol(number, &end, 0);
260 if (end != NULL && *end != 0)
266 static int check_cmd(const command_t *cmd_list, const char *cmd,
267 const char *sub_cmd, const int min_args,
268 int argc, char **argv)
275 const char *const short_options = "h";
276 static const struct option long_options[] = {
277 { .name = "help", .has_arg = no_argument, .val = 'h' },
281 if (argc < min_args) {
282 print_help(cmd_list, cmd, sub_cmd);
285 } else if (argc > 2) {
289 while ((opt = getopt_long(argc, argv, short_options,
290 long_options, NULL)) != -1) {
293 print_help(cmd_list, cmd, sub_cmd);
308 static int jt_set_max_intf(int argc, char **argv)
312 struct cYAML *err_rc = NULL;
314 rc = check_cmd(set_cmds, "set", "max_interfaces", 2, argc, argv);
318 rc = parse_long(argv[1], &value);
320 cYAML_build_error(-1, -1, "parser", "set",
321 "cannot parse max_interfaces value", &err_rc);
322 cYAML_print_tree2file(stderr, err_rc);
323 cYAML_free_tree(err_rc);
327 rc = lustre_lnet_config_max_intf(value, -1, &err_rc);
328 if (rc != LUSTRE_CFG_RC_NO_ERR)
329 cYAML_print_tree2file(stderr, err_rc);
331 cYAML_free_tree(err_rc);
336 static int jt_set_numa(int argc, char **argv)
340 struct cYAML *err_rc = NULL;
342 rc = check_cmd(set_cmds, "set", "numa_range", 2, argc, argv);
346 rc = parse_long(argv[1], &value);
348 cYAML_build_error(-1, -1, "parser", "set",
349 "cannot parse numa_range value", &err_rc);
350 cYAML_print_tree2file(stderr, err_rc);
351 cYAML_free_tree(err_rc);
355 rc = lustre_lnet_config_numa_range(value, -1, &err_rc);
356 if (rc != LUSTRE_CFG_RC_NO_ERR)
357 cYAML_print_tree2file(stderr, err_rc);
359 cYAML_free_tree(err_rc);
364 static int jt_set_recov_intrv(int argc, char **argv)
368 struct cYAML *err_rc = NULL;
370 rc = check_cmd(set_cmds, "set", "recovery_interval", 2, argc, argv);
374 rc = parse_long(argv[1], &value);
376 cYAML_build_error(-1, -1, "parser", "set",
377 "cannot parse recovery interval value", &err_rc);
378 cYAML_print_tree2file(stderr, err_rc);
379 cYAML_free_tree(err_rc);
383 rc = lustre_lnet_config_recov_intrv(value, -1, &err_rc);
384 if (rc != LUSTRE_CFG_RC_NO_ERR)
385 cYAML_print_tree2file(stderr, err_rc);
387 cYAML_free_tree(err_rc);
392 static int jt_set_hsensitivity(int argc, char **argv)
396 struct cYAML *err_rc = NULL;
398 rc = check_cmd(set_cmds, "set", "health_sensitivity", 2, argc, argv);
402 rc = parse_long(argv[1], &value);
404 cYAML_build_error(-1, -1, "parser", "set",
405 "cannot parse health sensitivity value", &err_rc);
406 cYAML_print_tree2file(stderr, err_rc);
407 cYAML_free_tree(err_rc);
411 rc = lustre_lnet_config_hsensitivity(value, -1, &err_rc);
412 if (rc != LUSTRE_CFG_RC_NO_ERR)
413 cYAML_print_tree2file(stderr, err_rc);
415 cYAML_free_tree(err_rc);
420 static int jt_set_transaction_to(int argc, char **argv)
424 struct cYAML *err_rc = NULL;
426 rc = check_cmd(set_cmds, "set", "transaction_timeout", 2, argc, argv);
430 rc = parse_long(argv[1], &value);
432 cYAML_build_error(-1, -1, "parser", "set",
433 "cannot parse transaction timeout value", &err_rc);
434 cYAML_print_tree2file(stderr, err_rc);
435 cYAML_free_tree(err_rc);
439 rc = lustre_lnet_config_transaction_to(value, -1, &err_rc);
440 if (rc != LUSTRE_CFG_RC_NO_ERR)
441 cYAML_print_tree2file(stderr, err_rc);
443 cYAML_free_tree(err_rc);
448 static int jt_set_retry_count(int argc, char **argv)
452 struct cYAML *err_rc = NULL;
454 rc = check_cmd(set_cmds, "set", "retry_count", 2, argc, argv);
458 rc = parse_long(argv[1], &value);
460 cYAML_build_error(-1, -1, "parser", "set",
461 "cannot parse retry_count value", &err_rc);
462 cYAML_print_tree2file(stderr, err_rc);
463 cYAML_free_tree(err_rc);
467 rc = lustre_lnet_config_retry_count(value, -1, &err_rc);
468 if (rc != LUSTRE_CFG_RC_NO_ERR)
469 cYAML_print_tree2file(stderr, err_rc);
471 cYAML_free_tree(err_rc);
476 static int jt_set_discovery(int argc, char **argv)
480 struct cYAML *err_rc = NULL;
482 rc = check_cmd(set_cmds, "set", "discovery", 2, argc, argv);
486 rc = parse_long(argv[1], &value);
488 cYAML_build_error(-1, -1, "parser", "set",
489 "cannot parse discovery value", &err_rc);
490 cYAML_print_tree2file(stderr, err_rc);
491 cYAML_free_tree(err_rc);
495 rc = lustre_lnet_config_discovery(value, -1, &err_rc);
496 if (rc != LUSTRE_CFG_RC_NO_ERR)
497 cYAML_print_tree2file(stderr, err_rc);
499 cYAML_free_tree(err_rc);
504 static int jt_set_tiny(int argc, char **argv)
508 struct cYAML *err_rc = NULL;
510 rc = check_cmd(set_cmds, "set", "tiny_buffers", 2, argc, argv);
514 rc = parse_long(argv[1], &value);
516 cYAML_build_error(-1, -1, "parser", "set",
517 "cannot parse tiny_buffers value", &err_rc);
518 cYAML_print_tree2file(stderr, err_rc);
519 cYAML_free_tree(err_rc);
523 rc = lustre_lnet_config_buffers(value, -1, -1, -1, &err_rc);
524 if (rc != LUSTRE_CFG_RC_NO_ERR)
525 cYAML_print_tree2file(stderr, err_rc);
527 cYAML_free_tree(err_rc);
532 static int jt_set_small(int argc, char **argv)
536 struct cYAML *err_rc = NULL;
538 rc = check_cmd(set_cmds, "set", "small_buffers", 2, argc, argv);
542 rc = parse_long(argv[1], &value);
544 cYAML_build_error(-1, -1, "parser", "set",
545 "cannot parse small_buffers value", &err_rc);
546 cYAML_print_tree2file(stderr, err_rc);
547 cYAML_free_tree(err_rc);
551 rc = lustre_lnet_config_buffers(-1, value, -1, -1, &err_rc);
552 if (rc != LUSTRE_CFG_RC_NO_ERR)
553 cYAML_print_tree2file(stderr, err_rc);
555 cYAML_free_tree(err_rc);
560 static int jt_set_large(int argc, char **argv)
564 struct cYAML *err_rc = NULL;
566 rc = check_cmd(set_cmds, "set", "large_buffers", 2, argc, argv);
570 rc = parse_long(argv[1], &value);
572 cYAML_build_error(-1, -1, "parser", "set",
573 "cannot parse large_buffers value", &err_rc);
574 cYAML_print_tree2file(stderr, err_rc);
575 cYAML_free_tree(err_rc);
579 rc = lustre_lnet_config_buffers(-1, -1, value, -1, &err_rc);
580 if (rc != LUSTRE_CFG_RC_NO_ERR)
581 cYAML_print_tree2file(stderr, err_rc);
583 cYAML_free_tree(err_rc);
588 static int jt_set_routing(int argc, char **argv)
591 struct cYAML *err_rc = NULL;
594 rc = check_cmd(set_cmds, "set", "routing", 2, argc, argv);
598 rc = parse_long(argv[1], &value);
599 if (rc != 0 || (value != 0 && value != 1)) {
600 cYAML_build_error(-1, -1, "parser", "set",
601 "cannot parse routing value.\n"
602 "must be 0 for disable or 1 for enable",
604 cYAML_print_tree2file(stderr, err_rc);
605 cYAML_free_tree(err_rc);
609 rc = lustre_lnet_enable_routing(value, -1, &err_rc);
611 if (rc != LUSTRE_CFG_RC_NO_ERR)
612 cYAML_print_tree2file(stderr, err_rc);
614 cYAML_free_tree(err_rc);
619 static int jt_config_lnet(int argc, char **argv)
621 struct cYAML *err_rc = NULL;
622 bool load_mod_params = false;
625 const char *const short_options = "a";
626 static const struct option long_options[] = {
627 { .name = "all", .has_arg = no_argument, .val = 'a' },
631 rc = check_cmd(lnet_cmds, "lnet", "configure", 0, argc, argv);
635 while ((opt = getopt_long(argc, argv, short_options,
636 long_options, NULL)) != -1) {
639 load_mod_params = true;
646 rc = lustre_lnet_config_ni_system(LNET_CONFIGURE, load_mod_params,
649 if (rc != LUSTRE_CFG_RC_NO_ERR)
650 cYAML_print_tree2file(stderr, err_rc);
652 cYAML_free_tree(err_rc);
657 static int jt_unconfig_lnet(int argc, char **argv)
659 struct cYAML *err_rc = NULL;
662 rc = check_cmd(lnet_cmds, "lnet", "unconfigure", 0, argc, argv);
666 rc = lustre_lnet_config_ni_system(LNET_UNCONFIGURE, 0, -1, &err_rc);
668 if (rc != LUSTRE_CFG_RC_NO_ERR)
669 cYAML_print_tree2file(stderr, err_rc);
671 cYAML_free_tree(err_rc);
675 static int jt_add_route(int argc, char **argv)
677 char *network = NULL, *gateway = NULL;
678 long int hop = -1, prio = -1;
679 struct cYAML *err_rc = NULL;
682 const char *const short_options = "n:g:c:p:";
683 static const struct option long_options[] = {
684 { .name = "net", .has_arg = required_argument, .val = 'n' },
685 { .name = "gateway", .has_arg = required_argument, .val = 'g' },
686 { .name = "hop-count", .has_arg = required_argument, .val = 'c' },
687 { .name = "priority", .has_arg = required_argument, .val = 'p' },
690 rc = check_cmd(route_cmds, "route", "add", 0, argc, argv);
694 while ((opt = getopt_long(argc, argv, short_options,
695 long_options, NULL)) != -1) {
704 rc = parse_long(optarg, &hop);
712 rc = parse_long(optarg, &prio);
720 print_help(route_cmds, "route", "add");
726 rc = lustre_lnet_config_route(network, gateway, hop, prio, -1, &err_rc);
728 if (rc != LUSTRE_CFG_RC_NO_ERR)
729 cYAML_print_tree2file(stderr, err_rc);
731 cYAML_free_tree(err_rc);
736 static int jt_add_ni(int argc, char **argv)
739 long int pto = -1, pc = -1, pbc = -1, cre = -1;
740 struct cYAML *err_rc = NULL;
741 int rc, opt, cpt_rc = -1;
742 struct lnet_dlc_network_descr nw_descr;
743 struct cfs_expr_list *global_cpts = NULL;
744 struct lnet_ioctl_config_lnd_tunables tunables;
747 memset(&tunables, 0, sizeof(tunables));
748 lustre_lnet_init_nw_descr(&nw_descr);
750 const char *const short_options = "n:i:p:t:c:b:r:s:";
751 static const struct option long_options[] = {
752 { .name = "net", .has_arg = required_argument, .val = 'n' },
753 { .name = "if", .has_arg = required_argument, .val = 'i' },
754 { .name = "ip2net", .has_arg = required_argument, .val = 'p' },
755 { .name = "peer-timeout", .has_arg = required_argument, .val = 't' },
756 { .name = "peer-credits", .has_arg = required_argument, .val = 'c' },
757 { .name = "peer-buffer-credits",
758 .has_arg = required_argument, .val = 'b' },
759 { .name = "credits", .has_arg = required_argument, .val = 'r' },
760 { .name = "cpt", .has_arg = required_argument, .val = 's' },
763 rc = check_cmd(net_cmds, "net", "add", 0, argc, argv);
767 while ((opt = getopt_long(argc, argv, short_options,
768 long_options, NULL)) != -1) {
771 nw_descr.nw_id = libcfs_str2net(optarg);
774 rc = lustre_lnet_parse_interfaces(optarg, &nw_descr);
776 cYAML_build_error(-1, -1, "ni", "add",
777 "bad interface list",
786 rc = parse_long(optarg, &pto);
794 rc = parse_long(optarg, &pc);
802 rc = parse_long(optarg, &pbc);
810 rc = parse_long(optarg, &cre);
818 cpt_rc = cfs_expr_list_parse(optarg,
820 UINT_MAX, &global_cpts);
823 print_help(net_cmds, "net", "add");
829 if (pto > 0 || pc > 0 || pbc > 0 || cre > 0) {
830 tunables.lt_cmn.lct_peer_timeout = pto;
831 tunables.lt_cmn.lct_peer_tx_credits = pc;
832 tunables.lt_cmn.lct_peer_rtr_credits = pbc;
833 tunables.lt_cmn.lct_max_tx_credits = cre;
837 rc = lustre_lnet_config_ni(&nw_descr,
838 (cpt_rc == 0) ? global_cpts: NULL,
839 ip2net, (found) ? &tunables : NULL,
842 if (global_cpts != NULL)
843 cfs_expr_list_free(global_cpts);
846 if (rc != LUSTRE_CFG_RC_NO_ERR)
847 cYAML_print_tree2file(stderr, err_rc);
849 cYAML_free_tree(err_rc);
854 static int jt_del_route(int argc, char **argv)
856 char *network = NULL, *gateway = NULL;
857 struct cYAML *err_rc = NULL;
860 const char *const short_options = "n:g:";
861 static const struct option long_options[] = {
862 { .name = "net", .has_arg = required_argument, .val = 'n' },
863 { .name = "gateway", .has_arg = required_argument, .val = 'g' },
866 rc = check_cmd(route_cmds, "route", "del", 0, argc, argv);
870 while ((opt = getopt_long(argc, argv, short_options,
871 long_options, NULL)) != -1) {
880 print_help(route_cmds, "route", "del");
886 rc = lustre_lnet_del_route(network, gateway, -1, &err_rc);
888 if (rc != LUSTRE_CFG_RC_NO_ERR)
889 cYAML_print_tree2file(stderr, err_rc);
891 cYAML_free_tree(err_rc);
896 static int jt_del_ni(int argc, char **argv)
898 struct cYAML *err_rc = NULL;
900 struct lnet_dlc_network_descr nw_descr;
902 lustre_lnet_init_nw_descr(&nw_descr);
904 const char *const short_options = "n:i:";
905 static const struct option long_options[] = {
906 { .name = "net", .has_arg = required_argument, .val = 'n' },
907 { .name = "if", .has_arg = required_argument, .val = 'i' },
910 rc = check_cmd(net_cmds, "net", "del", 0, argc, argv);
914 while ((opt = getopt_long(argc, argv, short_options,
915 long_options, NULL)) != -1) {
918 nw_descr.nw_id = libcfs_str2net(optarg);
921 rc = lustre_lnet_parse_interfaces(optarg, &nw_descr);
923 cYAML_build_error(-1, -1, "ni", "add",
924 "bad interface list",
930 print_help(net_cmds, "net", "del");
936 rc = lustre_lnet_del_ni(&nw_descr, -1, &err_rc);
939 if (rc != LUSTRE_CFG_RC_NO_ERR)
940 cYAML_print_tree2file(stderr, err_rc);
942 cYAML_free_tree(err_rc);
947 static int jt_show_route(int argc, char **argv)
949 char *network = NULL, *gateway = NULL;
950 long int hop = -1, prio = -1;
951 int detail = 0, rc, opt;
952 struct cYAML *err_rc = NULL, *show_rc = NULL;
954 const char *const short_options = "n:g:h:p:v";
955 static const struct option long_options[] = {
956 { .name = "net", .has_arg = required_argument, .val = 'n' },
957 { .name = "gateway", .has_arg = required_argument, .val = 'g' },
958 { .name = "hop-count", .has_arg = required_argument, .val = 'c' },
959 { .name = "priority", .has_arg = required_argument, .val = 'p' },
960 { .name = "verbose", .has_arg = no_argument, .val = 'v' },
963 rc = check_cmd(route_cmds, "route", "show", 0, argc, argv);
967 while ((opt = getopt_long(argc, argv, short_options,
968 long_options, NULL)) != -1) {
977 rc = parse_long(optarg, &hop);
985 rc = parse_long(optarg, &prio);
996 print_help(route_cmds, "route", "show");
1002 rc = lustre_lnet_show_route(network, gateway, hop, prio, detail, -1,
1003 &show_rc, &err_rc, false);
1005 if (rc != LUSTRE_CFG_RC_NO_ERR)
1006 cYAML_print_tree2file(stderr, err_rc);
1008 cYAML_print_tree(show_rc);
1010 cYAML_free_tree(err_rc);
1011 cYAML_free_tree(show_rc);
1016 static int set_value_helper(int argc, char **argv,
1017 int (*cb)(int, bool, char*, int, struct cYAML**))
1020 long int healthv = -1;
1023 struct cYAML *err_rc = NULL;
1025 const char *const short_options = "t:n:a";
1026 static const struct option long_options[] = {
1027 { .name = "nid", .has_arg = required_argument, .val = 'n' },
1028 { .name = "health", .has_arg = required_argument, .val = 't' },
1029 { .name = "all", .has_arg = no_argument, .val = 'a' },
1032 rc = check_cmd(net_cmds, "net", "set", 0, argc, argv);
1036 while ((opt = getopt_long(argc, argv, short_options,
1037 long_options, NULL)) != -1) {
1043 if (parse_long(optarg, &healthv) != 0)
1054 rc = cb(healthv, all, nid, -1, &err_rc);
1056 if (rc != LUSTRE_CFG_RC_NO_ERR)
1057 cYAML_print_tree2file(stderr, err_rc);
1059 cYAML_free_tree(err_rc);
1064 static int jt_set_ni_value(int argc, char **argv)
1066 return set_value_helper(argc, argv, lustre_lnet_config_ni_healthv);
1069 static int jt_set_peer_ni_value(int argc, char **argv)
1071 return set_value_helper(argc, argv, lustre_lnet_config_peer_ni_healthv);
1074 static int jt_show_recovery(int argc, char **argv)
1077 struct cYAML *err_rc = NULL, *show_rc = NULL;
1079 const char *const short_options = "lp";
1080 static const struct option long_options[] = {
1081 { .name = "local", .has_arg = no_argument, .val = 'l' },
1082 { .name = "peer", .has_arg = no_argument, .val = 'p' },
1085 rc = check_cmd(debug_cmds, "recovery", NULL, 0, argc, argv);
1089 while ((opt = getopt_long(argc, argv, short_options,
1090 long_options, NULL)) != -1) {
1093 rc = lustre_lnet_show_local_ni_recovq(-1, &show_rc, &err_rc);
1096 rc = lustre_lnet_show_peer_ni_recovq(-1, &show_rc, &err_rc);
1103 if (rc != LUSTRE_CFG_RC_NO_ERR)
1104 cYAML_print_tree2file(stderr, err_rc);
1106 cYAML_print_tree(show_rc);
1108 cYAML_free_tree(err_rc);
1109 cYAML_free_tree(show_rc);
1114 static int jt_show_net(int argc, char **argv)
1116 char *network = NULL;
1118 struct cYAML *err_rc = NULL, *show_rc = NULL;
1119 long int detail = 0;
1121 const char *const short_options = "n:v";
1122 static const struct option long_options[] = {
1123 { .name = "net", .has_arg = required_argument, .val = 'n' },
1124 { .name = "verbose", .has_arg = optional_argument, .val = 'v' },
1127 rc = check_cmd(net_cmds, "net", "show", 0, argc, argv);
1131 while ((opt = getopt_long(argc, argv, short_options,
1132 long_options, NULL)) != -1) {
1138 if ((!optarg) && (argv[optind] != NULL) &&
1139 (argv[optind][0] != '-')) {
1140 if (parse_long(argv[optind++], &detail) != 0)
1147 print_help(net_cmds, "net", "show");
1153 rc = lustre_lnet_show_net(network, (int) detail, -1, &show_rc, &err_rc,
1156 if (rc != LUSTRE_CFG_RC_NO_ERR)
1157 cYAML_print_tree2file(stderr, err_rc);
1159 cYAML_print_tree(show_rc);
1161 cYAML_free_tree(err_rc);
1162 cYAML_free_tree(show_rc);
1167 static int jt_show_routing(int argc, char **argv)
1169 struct cYAML *err_rc = NULL, *show_rc = NULL;
1172 rc = check_cmd(routing_cmds, "routing", "show", 0, argc, argv);
1176 rc = lustre_lnet_show_routing(-1, &show_rc, &err_rc, false);
1178 if (rc != LUSTRE_CFG_RC_NO_ERR)
1179 cYAML_print_tree2file(stderr, err_rc);
1181 cYAML_print_tree(show_rc);
1183 cYAML_free_tree(err_rc);
1184 cYAML_free_tree(show_rc);
1189 static int jt_show_stats(int argc, char **argv)
1192 struct cYAML *show_rc = NULL, *err_rc = NULL;
1194 rc = check_cmd(stats_cmds, "stats", "show", 0, argc, argv);
1198 rc = lustre_lnet_show_stats(-1, &show_rc, &err_rc);
1200 if (rc != LUSTRE_CFG_RC_NO_ERR)
1201 cYAML_print_tree2file(stderr, err_rc);
1203 cYAML_print_tree(show_rc);
1205 cYAML_free_tree(err_rc);
1206 cYAML_free_tree(show_rc);
1211 static int jt_show_global(int argc, char **argv)
1214 struct cYAML *show_rc = NULL, *err_rc = NULL;
1216 rc = check_cmd(global_cmds, "global", "show", 0, argc, argv);
1220 rc = lustre_lnet_show_numa_range(-1, &show_rc, &err_rc);
1221 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1222 cYAML_print_tree2file(stderr, err_rc);
1226 rc = lustre_lnet_show_max_intf(-1, &show_rc, &err_rc);
1227 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1228 cYAML_print_tree2file(stderr, err_rc);
1232 rc = lustre_lnet_show_discovery(-1, &show_rc, &err_rc);
1233 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1234 cYAML_print_tree2file(stderr, err_rc);
1238 rc = lustre_lnet_show_retry_count(-1, &show_rc, &err_rc);
1239 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1240 cYAML_print_tree2file(stderr, err_rc);
1244 rc = lustre_lnet_show_transaction_to(-1, &show_rc, &err_rc);
1245 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1246 cYAML_print_tree2file(stderr, err_rc);
1250 rc = lustre_lnet_show_hsensitivity(-1, &show_rc, &err_rc);
1251 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1252 cYAML_print_tree2file(stderr, err_rc);
1256 rc = lustre_lnet_show_recov_intrv(-1, &show_rc, &err_rc);
1257 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1258 cYAML_print_tree2file(stderr, err_rc);
1263 cYAML_print_tree(show_rc);
1266 cYAML_free_tree(err_rc);
1267 cYAML_free_tree(show_rc);
1272 static int jt_lnet(int argc, char **argv)
1276 rc = check_cmd(lnet_cmds, "lnet", NULL, 2, argc, argv);
1280 return Parser_execarg(argc - 1, &argv[1], lnet_cmds);
1283 static int jt_route(int argc, char **argv)
1287 rc = check_cmd(route_cmds, "route", NULL, 2, argc, argv);
1291 return Parser_execarg(argc - 1, &argv[1], route_cmds);
1294 static int jt_net(int argc, char **argv)
1298 rc = check_cmd(net_cmds, "net", NULL, 2, argc, argv);
1302 return Parser_execarg(argc - 1, &argv[1], net_cmds);
1305 static int jt_routing(int argc, char **argv)
1309 rc = check_cmd(routing_cmds, "routing", NULL, 2, argc, argv);
1313 return Parser_execarg(argc - 1, &argv[1], routing_cmds);
1316 static int jt_stats(int argc, char **argv)
1320 rc = check_cmd(stats_cmds, "stats", NULL, 2, argc, argv);
1324 return Parser_execarg(argc - 1, &argv[1], stats_cmds);
1327 static int jt_debug(int argc, char **argv)
1331 rc = check_cmd(debug_cmds, "recovery", NULL, 2, argc, argv);
1335 return Parser_execarg(argc - 1, &argv[1], debug_cmds);
1338 static int jt_global(int argc, char **argv)
1342 rc = check_cmd(global_cmds, "global", NULL, 2, argc, argv);
1346 return Parser_execarg(argc - 1, &argv[1], global_cmds);
1349 static int jt_peers(int argc, char **argv)
1353 rc = check_cmd(peer_cmds, "peer", NULL, 2, argc, argv);
1357 return Parser_execarg(argc - 1, &argv[1], peer_cmds);
1360 static int jt_set(int argc, char **argv)
1364 rc = check_cmd(set_cmds, "set", NULL, 2, argc, argv);
1368 return Parser_execarg(argc - 1, &argv[1], set_cmds);
1371 static int jt_import(int argc, char **argv)
1374 struct cYAML *err_rc = NULL;
1375 struct cYAML *show_rc = NULL;
1376 int rc = 0, return_rc = 0, opt, opt_found = 0;
1379 const char *const short_options = "adseh";
1380 static const struct option long_options[] = {
1381 { .name = "add", .has_arg = no_argument, .val = 'a' },
1382 { .name = "del", .has_arg = no_argument, .val = 'd' },
1383 { .name = "show", .has_arg = no_argument, .val = 's' },
1384 { .name = "exec", .has_arg = no_argument, .val = 'e' },
1385 { .name = "help", .has_arg = no_argument, .val = 'h' },
1388 while ((opt = getopt_long(argc, argv, short_options,
1389 long_options, NULL)) != -1) {
1403 printf("import FILE\n"
1404 "import < FILE : import a file\n"
1405 "\t--add: add configuration\n"
1406 "\t--del: delete configuration\n"
1407 "\t--show: show configuration\n"
1408 "\t--exec: execute command\n"
1409 "\t--help: display this help\n"
1410 "If no command option is given then --add"
1411 " is assumed by default\n");
1418 /* grab the file name if one exists */
1419 if (opt_found && argc == 3)
1421 else if (!opt_found && argc == 2)
1426 rc = lustre_yaml_config(file, &err_rc);
1427 return_rc = lustre_yaml_exec(file, &show_rc, &err_rc);
1428 cYAML_print_tree(show_rc);
1429 cYAML_free_tree(show_rc);
1432 rc = lustre_yaml_del(file, &err_rc);
1435 rc = lustre_yaml_show(file, &show_rc, &err_rc);
1436 cYAML_print_tree(show_rc);
1437 cYAML_free_tree(show_rc);
1440 rc = lustre_yaml_exec(file, &show_rc, &err_rc);
1441 cYAML_print_tree(show_rc);
1442 cYAML_free_tree(show_rc);
1446 if (rc || return_rc) {
1447 cYAML_print_tree2file(stderr, err_rc);
1448 cYAML_free_tree(err_rc);
1454 static int jt_export(int argc, char **argv)
1456 struct cYAML *show_rc = NULL;
1457 struct cYAML *err_rc = NULL;
1461 bool backup = false;
1464 const char *const short_options = "bh";
1465 static const struct option long_options[] = {
1466 { .name = "backup", .has_arg = no_argument, .val = 'b' },
1467 { .name = "help", .has_arg = no_argument, .val = 'h' },
1470 while ((opt = getopt_long(argc, argv, short_options,
1471 long_options, NULL)) != -1) {
1478 printf("export > FILE.yaml : export configuration\n"
1479 "\t--backup: export only what's necessary for reconfig\n"
1480 "\t--help: display this help\n");
1485 if (backup && argc >= 3)
1487 else if (!backup && argc >= 2)
1493 f = fopen(file, "w");
1498 rc = lustre_lnet_show_net(NULL, 2, -1, &show_rc, &err_rc, backup);
1499 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1500 cYAML_print_tree2file(stderr, err_rc);
1501 cYAML_free_tree(err_rc);
1505 rc = lustre_lnet_show_route(NULL, NULL, -1, -1, 1, -1, &show_rc,
1507 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1508 cYAML_print_tree2file(stderr, err_rc);
1509 cYAML_free_tree(err_rc);
1513 rc = lustre_lnet_show_routing(-1, &show_rc, &err_rc, backup);
1514 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1515 cYAML_print_tree2file(stderr, err_rc);
1516 cYAML_free_tree(err_rc);
1520 rc = lustre_lnet_show_peer(NULL, 2, -1, &show_rc, &err_rc, backup);
1521 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1522 cYAML_print_tree2file(stderr, err_rc);
1523 cYAML_free_tree(err_rc);
1527 rc = lustre_lnet_show_numa_range(-1, &show_rc, &err_rc);
1528 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1529 cYAML_print_tree2file(stderr, err_rc);
1530 cYAML_free_tree(err_rc);
1534 rc = lustre_lnet_show_max_intf(-1, &show_rc, &err_rc);
1535 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1536 cYAML_print_tree2file(stderr, err_rc);
1537 cYAML_free_tree(err_rc);
1541 rc = lustre_lnet_show_discovery(-1, &show_rc, &err_rc);
1542 if (rc != LUSTRE_CFG_RC_NO_ERR) {
1543 cYAML_print_tree2file(stderr, err_rc);
1544 cYAML_free_tree(err_rc);
1548 if (show_rc != NULL) {
1549 cYAML_print_tree2file(f, show_rc);
1550 cYAML_free_tree(show_rc);
1559 static int jt_add_peer_nid(int argc, char **argv)
1561 char *prim_nid = NULL;
1562 char **nids = NULL, **nids2 = NULL;
1564 struct cYAML *err_rc = NULL;
1565 int rc = LUSTRE_CFG_RC_NO_ERR, opt, i;
1566 bool non_mr = false;
1567 bool ip2nets = false, nid_list = false, prim_nid_present = false;
1569 const char *const short_opts = "k:mn:";
1570 const struct option long_opts[] = {
1571 { .name = "prim_nid", .has_arg = required_argument, .val = 'k' },
1572 { .name = "non_mr", .has_arg = no_argument, .val = 'm' },
1573 { .name = "nid", .has_arg = required_argument, .val = 'n' },
1574 { .name = "ip2nets", .has_arg = required_argument, .val = 'i' },
1577 rc = check_cmd(peer_cmds, "peer", "add", 2, argc, argv);
1581 while ((opt = getopt_long(argc, argv, short_opts,
1582 long_opts, NULL)) != -1) {
1585 prim_nid_present = true;
1587 cYAML_build_error(-1, -1, "peer", "add",
1588 "ip2nets can not be specified"
1589 " along side prim_nid parameter.",
1603 if (ip2nets && (nid_list || prim_nid_present)) {
1604 cYAML_build_error(-1, -1, "peer", "add",
1605 "ip2nets can not be specified"
1606 " along side nid or prim_nid"
1607 " parameters", &err_rc);
1611 size = lustre_lnet_parse_nids(optarg, nids, size,
1616 rc = LUSTRE_CFG_RC_OUT_OF_MEM;
1622 print_help(peer_cmds, "peer", "add");
1628 for (; optind < argc; optind++) {
1629 size = lustre_lnet_parse_nids(argv[optind], nids, size,
1636 rc = lustre_lnet_config_peer_nid(prim_nid, nids, size,
1637 !non_mr, ip2nets, -1, &err_rc);
1641 /* free the array of nids */
1642 for (i = 0; i < size; i++)
1647 if (rc != LUSTRE_CFG_RC_NO_ERR)
1648 cYAML_print_tree2file(stderr, err_rc);
1650 cYAML_free_tree(err_rc);
1655 static int jt_del_peer_nid(int argc, char **argv)
1657 char *prim_nid = NULL;
1658 char **nids = NULL, **nids2 = NULL;
1659 struct cYAML *err_rc = NULL;
1660 int rc = LUSTRE_CFG_RC_NO_ERR, opt, i, size = 0;
1661 bool ip2nets = false, nid_list = false, prim_nid_present = false;
1663 const char *const short_opts = "k:n:";
1664 const struct option long_opts[] = {
1665 { .name = "prim_nid", .has_arg = required_argument, .val = 'k' },
1666 { .name = "nid", .has_arg = required_argument, .val = 'n' },
1667 { .name = "ip2nets", .has_arg = required_argument, .val = 'i' },
1670 rc = check_cmd(peer_cmds, "peer", "del", 2, argc, argv);
1674 while ((opt = getopt_long(argc, argv, short_opts,
1675 long_opts, NULL)) != -1) {
1678 prim_nid_present = true;
1680 cYAML_build_error(-1, -1, "peer", "add",
1681 "ip2nets can not be specified"
1682 " along side prim_nid parameter.",
1696 if (ip2nets && (nid_list || prim_nid_present)) {
1697 cYAML_build_error(-1, -1, "peer", "add",
1698 "ip2nets can not be specified"
1699 " along side nid or prim_nid"
1700 " parameters", &err_rc);
1703 size = lustre_lnet_parse_nids(optarg, nids, size,
1708 rc = LUSTRE_CFG_RC_OUT_OF_MEM;
1711 print_help(peer_cmds, "peer", "del");
1717 for (; optind < argc; optind++) {
1718 size = lustre_lnet_parse_nids(argv[optind], nids, size,
1725 rc = lustre_lnet_del_peer_nid(prim_nid, nids, size, ip2nets, -1, &err_rc);
1729 for (i = 0; i < size; i++)
1734 if (rc != LUSTRE_CFG_RC_NO_ERR)
1735 cYAML_print_tree2file(stderr, err_rc);
1737 cYAML_free_tree(err_rc);
1742 static int jt_show_peer(int argc, char **argv)
1746 struct cYAML *err_rc = NULL, *show_rc = NULL;
1747 long int detail = 0;
1749 const char *const short_opts = "hn:v::";
1750 const struct option long_opts[] = {
1751 { .name = "help", .has_arg = no_argument, .val = 'h' },
1752 { .name = "nid", .has_arg = required_argument, .val = 'n' },
1753 { .name = "verbose", .has_arg = optional_argument, .val = 'v' },
1756 rc = check_cmd(peer_cmds, "peer", "show", 1, argc, argv);
1760 while ((opt = getopt_long(argc, argv, short_opts,
1761 long_opts, NULL)) != -1) {
1767 if ((!optarg) && (argv[optind] != NULL) &&
1768 (argv[optind][0] != '-')) {
1769 if (parse_long(argv[optind++], &detail) != 0)
1776 print_help(peer_cmds, "peer", "show");
1782 rc = lustre_lnet_show_peer(nid, (int) detail, -1, &show_rc, &err_rc,
1785 if (rc != LUSTRE_CFG_RC_NO_ERR)
1786 cYAML_print_tree2file(stderr, err_rc);
1788 cYAML_print_tree(show_rc);
1790 cYAML_free_tree(err_rc);
1791 cYAML_free_tree(show_rc);
1796 static int jt_list_peer(int argc, char **argv)
1799 struct cYAML *err_rc = NULL, *list_rc = NULL;
1801 rc = check_cmd(peer_cmds, "peer", "list", 0, argc, argv);
1805 rc = lustre_lnet_list_peer(-1, &list_rc, &err_rc);
1807 if (rc != LUSTRE_CFG_RC_NO_ERR)
1808 cYAML_print_tree2file(stderr, err_rc);
1810 cYAML_print_tree(list_rc);
1812 cYAML_free_tree(err_rc);
1813 cYAML_free_tree(list_rc);
1818 static int jt_ping(int argc, char **argv)
1820 struct cYAML *err_rc = NULL;
1821 struct cYAML *show_rc = NULL;
1825 const char *const short_options = "ht:";
1826 const struct option long_options[] = {
1827 { .name = "help", .has_arg = no_argument, .val = 'h' },
1828 { .name = "timeout", .has_arg = required_argument, .val = 't' },
1831 while ((opt = getopt_long(argc, argv, short_options,
1832 long_options, NULL)) != -1) {
1835 timeout = 1000 * atol(optarg);
1838 printf("ping nid[,nid,...]\n"
1839 "\t --timeout: ping timeout\n"
1840 "\t --help: display this help\n");
1847 for (; optind < argc; optind++)
1848 rc = lustre_lnet_ping_nid(argv[optind], timeout, -1, &show_rc, &err_rc);
1851 cYAML_print_tree(show_rc);
1854 cYAML_print_tree2file(stderr, err_rc);
1856 cYAML_free_tree(err_rc);
1857 cYAML_free_tree(show_rc);
1862 static int jt_discover(int argc, char **argv)
1864 struct cYAML *err_rc = NULL;
1865 struct cYAML *show_rc = NULL;
1869 const char *const short_options = "fh";
1870 const struct option long_options[] = {
1871 { .name = "force", .has_arg = no_argument, .val = 'f' },
1872 { .name = "help", .has_arg = no_argument, .val = 'h' },
1875 while ((opt = getopt_long(argc, argv, short_options,
1876 long_options, NULL)) != -1) {
1882 printf("discover nid[,nid,...]\n"
1883 "\t --force: force discovery\n"
1884 "\t --help: display this help\n");
1891 for (; optind < argc; optind++)
1892 rc = lustre_lnet_discover_nid(argv[optind], force, -1, &show_rc,
1896 cYAML_print_tree(show_rc);
1899 cYAML_print_tree2file(stderr, err_rc);
1901 cYAML_free_tree(err_rc);
1902 cYAML_free_tree(show_rc);
1907 static int lnetctl_list_commands(int argc, char **argv)
1909 char buffer[81] = ""; /* 80 printable chars + terminating NUL */
1911 Parser_list_commands(cmd_list, buffer, sizeof(buffer), NULL, 0, 4);
1916 int main(int argc, char **argv)
1919 struct cYAML *err_rc = NULL;
1921 rc = lustre_lnet_config_lib_init();
1923 cYAML_build_error(-1, -1, "lnetctl", "startup",
1924 "cannot register LNet device", &err_rc);
1925 cYAML_print_tree2file(stderr, err_rc);
1929 Parser_init("lnetctl > ", cmd_list);
1931 rc = Parser_execarg(argc - 1, &argv[1], cmd_list);